Commit Graph

41 Commits

Author SHA1 Message Date
Alexander Uvarov
528f405cdc Allow to specify mass-assignment roles as array 2011-06-23 12:56:39 +06:00
Joshua Wehner
2cef2d411a Methods that return nil should not be considered YAML 2011-05-10 12:06:09 -04:00
Myron Marston
1f8cc446d9 Allow observers to be enabled and disabled.
This is useful in situations like model unit tests and the occasional rake task to backfill old data.
2011-04-28 10:23:49 +08:00
Josh Kalderimis
1054ebd613 AM mass assignment security attr_accessible and attr_protected now allow for scopes using :as => scope eg.
attr_accessible :name
    attr_accessible :name, :admin, :as => :admin
2011-04-24 09:53:18 +02:00
Santiago Pastorino
a00bed0c48 Revert "Properly interpolate i18n keys in modules [#5572 state:resolved]"
This breaks #6448, you should use :"module/class" as key for namespacing
[#6448 state:committed]

This reverts commit 8d30193b08bd2321a7a78a1f481bd5e4d4d45557.
2011-02-27 21:30:03 -02:00
Santiago Pastorino
acf0688fdd failing test for i18n key collision with namespaced models 2011-02-27 21:23:52 -02:00
Tsutomu Kuroda
ad31549ab3 Override attributes_protected_by_default when has_secure_password is called.
attr_protected should not be called, because it nullifies the
mass assignment protection that has been set by attr_accessible.

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2011-02-09 18:35:15 -02:00
Carl Lerche
cd13fbd8d8 Optionally pass in the attribute being validated to an instance method validator 2011-02-05 16:44:35 -08:00
Carl Lerche
e9e9ed6b60 Be able to pass a validator method to #validates 2011-02-05 16:33:00 -08:00
Carl Lerche
ed7614aa7d Provide a way to specify alternate option keys for validates 2011-02-05 16:00:57 -08:00
David Heinemeier Hansson
bcf4e4f2b0 Added ActiveRecord::Base#has_secure_password (via ActiveModel::SecurePassword) to encapsulate dead-simple password usage with SHA2 encryption and salting 2010-12-18 13:38:05 -08:00
José Valim
232e56ce87 No need to pass self as parameter here. 2010-10-04 22:32:29 +02:00
Ernie Miller
21cb1d40b9 Test to_model being called in ActiveModel::Naming helpers
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-10-04 21:26:42 +02:00
Rodrigo Rosenfeld Rosas
8d30193b08 Properly interpolate i18n keys in modules [#5572 state:resolved] 2010-09-24 20:41:12 +02:00
Obie Fernandez
275f922a23 Better shortcut options for custom validators [#5672 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-09-24 12:49:16 +02:00
Piotr Sarnacki
6e5aed057f Prepared ActiveModel::Naming to handle cases for namespaced isolated engines 2010-09-03 22:59:15 +02:00
Neeraj Singh
2ffa50f5a9 after_validation should be called irrespective of the result of validation.
I confirmed that this is the behavior on 2.3.x .

[5419 state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
2010-08-20 11:24:43 -03:00
Santiago Pastorino
b451de0d6d Deletes trailing whitespaces (over text files only find * -type f -exec sed 's/[ \t]*$//' -i {} \;) 2010-08-14 04:12:33 -03:00
José Valim
53310614d7 Reuse already existing classes for ActiveModel tests. 2010-07-21 13:00:56 +02:00
Josh Kalderimis
4b66aab00f mass_assignment_security moved from AR to AMo, and minor test cleanup
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-07-08 18:28:45 +02:00
Josh Kalderimis
9131a88bb8 validation macros can now be used within an instance 2010-05-13 13:57:37 -07:00
Josh Kalderimis
88ad3ed8b5 removed an old unused model in the AMo tests which also removes another AR dependency 2010-05-09 00:08:11 +03:00
Josh Kalderimis
66913a76af removed use of AR in AMo tests and removed testing of scopes (:on) in individual validation tests and moved them to their own test file 2010-05-08 23:51:36 +03:00
Neeraj Singh
883f27aa9a test cases for record.to_xml [#458 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-04-30 13:19:30 +02:00
José Valim
6fa2bbfd10 Fix AMo isolated tests. 2010-02-22 08:45:41 +01:00
José Valim
250c809246 Require persisted? in ActiveModel::Lint and remove new_record? and destroyed? methods. ActionPack does not care if the resource is new or if it was destroyed, it cares only if it's persisted somewhere or not. 2010-02-21 11:12:14 +01:00
José Valim
9dd67fce25 Add to_key and to_param methods to ActiveModel::Conversion. 2010-02-21 09:08:59 +01:00
José Valim
017f5d5308 Fix typo by renaming :genre to :gender. 2010-01-09 00:18:07 +01:00
José Valim
7045c4c279 Allow validates to map some types to specific options. So now you can do:
validates :email, :presence => true, :format => /@/
  validates :genre, :inclusion => %w(m f)
  validates :password, :length => 6..20
2010-01-08 21:36:04 +01:00
José Valim
47a5fd4c4b Allow :if, :unless, :on, :allow_nil and :allow_blank as shared options in validates. 2010-01-07 19:23:59 +01:00
jamie
0a79eb7889 Add validates method as shortcut to setup validators for a given set of attributes:
class Person < ActiveRecord::Base
  include MyValidators

  validates :name, :presence => true, :uniqueness => true, :length => { :maximum => 100 }
  validates :email, :presence => true, :email => true
end

[#3058 status:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
2010-01-07 19:23:59 +01:00
José Valim
74098e4cb6 No need to use ValidationsRepairHelper hack on ActiveModel anymore, Model.reset_callbacks(:validate) is enough. However, tests in ActiveRecord are still coupled, so moved ValidationsRepairHelper back there. 2009-12-23 13:30:58 +01:00
José Valim
e31077c9aa Small clean up in Naming and TTranslation tests. 2009-12-23 12:28:02 +01:00
José Valim
4f37b97033 Changed ActiveRecord to use new callbacks and speed up observers by only notifying events that are actually being consumed.
Signed-off-by: Joshua Peek <josh@joshpeek.com>
2009-09-08 10:26:39 -05:00
James Hill
cfd421daa2 Allow validations to use values from custom readers [#2936 state:resolved]
Signed-off-by: Joshua Peek <josh@joshpeek.com>
2009-08-05 11:45:01 -05:00
Joshua Peek
272c504f91 Dasherize XML root by default to avoid invalid tags "<admin/posts>...</admin/posts>" [#2875 state:resolved] 2009-07-22 21:06:34 -05:00
Joshua Peek
d2b78b3594 Initial extraction of AMo xml serializer 2009-07-03 21:38:14 -05:00
Pratik Naik
d758d996d1 Deprecate Model#validate/validate_on_create/validate_on_update. Use Model.validate :method and likewise 2009-03-21 19:07:15 +00:00
Pratik Naik
6173e5bfae Add ActiveModel::Validations tests for regular ruby classes 2009-03-20 22:21:27 +00:00
Pratik Naik
08a99d0eac Add I18n translations to ActiveModel and move more AR specific parts to ActiveRecord::Validations 2009-03-20 21:45:13 +00:00
Pratik Naik
60756ad4ec Move relevant validation tests from Active Record to Active Model 2009-03-20 15:07:49 +00:00