Commit Graph

55 Commits

Author SHA1 Message Date
Akira Matsuda a3ebe7f3a7 Unused classes in AMo tests 2013-12-19 18:31:11 +09:00
Akira Matsuda 68db6bc431 Let validates_inclusion_of accept Time and DateTime ranges
fixes 4.0.0 regression introduced in 0317b93c17
2013-10-23 22:10:15 +09:00
Patrick Robertson eebb9ddf9b Convert ActiveModel to 1.9 hash syntax.
I also attempted to fix other styleguide violations such as
{ a: :b } over {a: :b} and foo(b: 'bar') over foo( b: 'bar' ).
2013-05-01 18:01:46 -07:00
Yves Senn bc19c0d09c test for ActiveModel::Conversion#to_partial_path and namespaced models 2013-01-14 21:17:22 +01:00
Rafael Mendonça França ccecab3ba9 Remove observers and sweepers
They was extracted from a plugin.

See https://github.com/rails/rails-observers

[Rafael Mendonça França + Steve Klabnik]
2012-11-28 22:46:49 -02:00
Francesco Rodriguez df2b60cd41 fix failing isolated tests 2012-10-26 23:03:36 -05:00
Francesco Rodriguez 070329596f AM::Serializers::Xml depends on AM::Naming 2012-10-26 21:45:40 -05:00
Guillermo Iguaran 9bfa13bb06 attr_accessible and attr_protected raise an exception pointing to use plugin or new protection model 2012-09-16 23:58:21 -05:00
Guillermo Iguaran f8c9a4d3e8 Remove MassAssignmentSecurity from ActiveModel
This will be moved out to protected_attributes gem
2012-09-16 23:58:19 -05:00
Guillermo Iguaran a8f6d5c645 Integrate ActiveModel::ForbiddenAttributesProtection from StrongParameters gem 2012-09-16 23:58:19 -05:00
Robby Grossman ad7f9cdf00 has_secure_password should not raise a 'digest missing' error if the calling class has specified for validations to be skipped. 2012-07-31 16:16:21 -04:00
Erich Menge f021377358 Updated tests for has_secure_password. 2012-05-08 18:08:55 -05:00
José Valim fd86a1b6b0 Rely on a public contract between railties instead of accessing railtie methods directly. 2011-11-23 19:06:45 +00:00
Grant Hutchins & Peter Jaros bf812074fd Let ActiveModel instances define partial paths.
Deprecate ActiveModel::Name#partial_path. Now you
should call #to_path directly on ActiveModel
instances.
2011-07-25 16:05:24 -04:00
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 8d30193b08.
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