aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/test/cases
Commit message (Collapse)AuthorAgeFilesLines
* Don't pass `:within` option to the i18nRafael Mendonça França2012-07-201-0/+22
|
* `validates_inclusion_of` and `validates_exclusion_of` now acceptRafael Mendonça França2012-07-202-0/+20
| | | | | | `:within` option as alias of `:in` as documented. Fix #7118
* Merge pull request #6800 from mschneider/dynamic_finders_for_aliased_attributesRafael Mendonça França2012-06-221-0/+9
|\ | | | | Dynamic finders for aliased attributes
| * made dynamic finders alias_attribute awareMaximilian Schneider2012-06-221-0/+9
| | | | | | | | | | previously dynamic finders only worked in combination with the actual column name and not its alias defined with #alias_attribute
* | Add some coverage for AR serialization with serializable_hashCarlos Antonio da Silva2012-06-221-1/+1
|/ | | | | | ActiveRecord json/xml serialization should use as base serializable_hash, provided by ActiveModel. Add some more coverage around options :only and :except for both json and xml serialization.
* Simplify AR configuration code.Jon Leighton2012-06-151-154/+0
| | | | | Get rid of ActiveModel::Configuration, make better use of ActiveSupport::Concern + class_attribute, etc.
* prevent users from unknowingly using bad regexps that can compromise ↵MrBrdo2012-06-142-6/+16
| | | | security (http://homakov.blogspot.co.uk/2012/05/saferweb-injects-in-various-ruby.html)
* Merge pull request #6668 from pomnikita/masterPiotr Sarnacki2012-06-081-0/+6
|\ | | | | Compact array of values added to PermissionSet instance
| * Compact array of values added to PermissionSet instanceNikita Pomyashchiy2012-06-081-0/+6
| |
* | change AMS::JSON.include_root_in_json default value to falseFrancesco Rodriguez2012-06-061-50/+40
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Changes: * Update `include_root_in_json` default value to false for default value to false for `ActiveModel::Serializers::JSON`. * Remove unnecessary change to include_root_in_json option in wrap_parameters template. * Update `as_json` documentation. * Fix JSONSerialization tests. Problem: It's confusing that AM serializers behave differently from AR, even when AR objects include AM serializers module. class User < ActiveRecord::Base; end class Person include ActiveModel::Model include ActiveModel::AttributeMethods include ActiveModel::Serializers::JSON attr_accessor :name, :age def attributes instance_values end end user.as_json => {"id"=>1, "name"=>"Konata Izumi", "age"=>16, "awesome"=>true} # root is not included person.as_json => {"person"=>{"name"=>"Francesco", "age"=>22}} # root is included ActiveRecord::Base.include_root_in_json => false Person.include_root_in_json => true # different default values for include_root_in_json Proposal: Change the default value of AM serializers to false, update the misleading documentation and remove unnecessary change to false of include_root_in_json option with AR objects. class User < ActiveRecord::Base; end class Person include ActiveModel::Model include ActiveModel::AttributeMethods include ActiveModel::Serializers::JSON attr_accessor :name, :age def attributes instance_values end end user.as_json => {"id"=>1, "name"=>"Konata Izumi", "age"=>16, "awesome"=>true} # root is not included person.as_json => {"name"=>"Francesco", "age"=>22} # root is not included ActiveRecord::Base.include_root_in_json => false Person.include_root_in_json => false # same behaviour, more consistent Fixes #6578.
* Merge pull request #5843 from ↵José Valim2012-05-291-0/+5
|\ | | | | | | | | kuroda/translation_of_deeply_nested_model_attributes Fix human attribute_name to handle deeply nested attributes
| * Fix human attribute_name to handle deeply nested attributesTsutomu Kuroda2012-05-161-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | When a model nests another model that also nests yet another model using accepts_nested_attributes_for method, its Errors object can have an attribute name with "contacts.addresses.street" style. In this case, the dots within the namespace should be substituted with slashes so that we can provide the translation under the "activemodel.attributes.person/contacts/addresses.street" key. This commit is related to #3859.
* | Don't enable validations when passing false hash values to ActiveModel.validatesSteve Purcell2012-05-281-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Passing a falsey option value for a validator currently causes that validator to be enabled, just like "true": ActiveModel.validates :foo, :presence => false This is rather counterintuitive, and makes it inconvenient to wrap `validates` in methods which may conditionally enable different validators. As an example, one is currently forced to write: def has_slug(source_field, options={:unique => true}) slugger = Proc.new { |r| r[:slug] = self.class.sluggify(r[source_field]) if r[:slug].blank? } before_validation slugger validations = { :presence => true, :slug => true } if options[:unique] validations[:uniqueness] = true end validates :slug, validations end because the following reasonable-looking alternative fails to work as expected: def has_slug(source_field, options={:unique => true}) slugger = Proc.new { |r| r[:slug] = self.class.sluggify(r[source_field]) if r[:slug].blank? } before_validation slugger validates :slug, :presence => true, :slug => true, :uniqueness => options[:unique] end (This commit includes a test, and all activemodel and activerecord tests pass as before.)
* | Merge pull request #4785 from ↵José Valim2012-05-251-0/+22
|\ \ | | | | | | | | | | | | ayamomiji/add-self-to-allow-method-name-using-ruby-keyword add `self.` to allow method name using ruby keyword
| * | fix `alias_attribute` will raise a syntax error if make an alias on aayaya2012-05-141-0/+22
| | | | | | | | | | | | column that named as a ruby keyword
* | | changed xml type datetime to dateTime, fixes #6328Angelo capilleri2012-05-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | XmlMini define the xml 'datatime', but according to http://www.w3.org/TR/xmlschema-2/#dateTime could be better change this to 'dateTime' with upper case letter 'T. So 'DateTime' and 'Time' are redefined from 'datetime' to 'dateTime' add the changing to the changelog
* | | Merge pull request #6215 from erichmenge/fix_has_secure_passwordAaron Patterson2012-05-171-8/+22
|\ \ \ | | | | | | | | Fix has secure password
| * | | Updated tests for has_secure_password.Erich Menge2012-05-081-8/+22
| |/ /
* | / Improve logging of ActiveModel::MassAssignmentSecurity::SanitizerNaoto Takai2012-05-172-5/+5
| |/ |/|
* | Kill whitespaces :scissors:Carlos Antonio da Silva2012-05-151-1/+1
| |
* | Merge pull request #6284 from acapilleri/dup_validationCarlos Antonio da Silva2012-05-151-0/+15
|\ \ | | | | | | clean the erros if an object that includes validation is duped.
| * | clean the erros if an object that includes validations errors is duped. ↵Angelo Capilleri2012-05-131-0/+15
| | | | | | | | | | | | Fixes #5953
* | | updating define_attribute_methods documentationFrancesco Rodriguez2012-05-141-1/+1
| | |
* | | allow define_attribute_methods to pass multiple valuesFrancesco Rodriguez2012-05-141-6/+13
|/ /
* | Remove useless load path modificationsSantiago Pastorino2012-05-111-3/+0
| |
* | Use respond_to?(:to_ary) rather than is_a?(Enumerable) to detect ↵Jon Leighton2012-05-112-0/+35
|/ | | | collection-thing.
* notify_observers should be publicMarc-Andre Lafortune2012-04-301-2/+9
|
* Merge pull request #6063 from marcandre/observer_extra_argsAaron Patterson2012-04-301-2/+9
|\ | | | | Allow extra arguments for Observers
| * Allow extra arguments for ObserversMarc-Andre Lafortune2012-04-301-2/+9
| |
* | build fix for observing_test.rbArun Agrawal2012-04-301-1/+1
| | | | | | introduced here 17c990b153f8635874c006a7460ee95817543fc1
* | Merge pull request #6072 from marcandre/observer_simplify_testSantiago Pastorino2012-04-301-11/+4
|\ \ | | | | | | Observer: simplify tests
| * | Observer: simplify testsMarc-Andre Lafortune2012-04-291-11/+4
| |/
* | Merge pull request #6071 from marcandre/observer_redefJeremy Kemper2012-04-291-2/+13
|\ \ | | | | | | Fix Observer by acting on singleton class. Fixes #3505.
| * | Fix Observer by acting on singleton class [#3505]Marc-Andre Lafortune2012-04-291-2/+13
| |/ | | | | | | Also [issue #1034] [pull #6068]
* | Merge pull request #5942 from ↵Aaron Patterson2012-04-294-9/+33
|\ \ | | | | | | | | | | | | bcardarella/confirmation_error_message_on_confirmation_attribute confirmation validation error attribute
| * | Support i18n attributes for confirmationBrian Cardarella2012-04-242-2/+21
| | |
| * | confirmation validation error attributeBrian Cardarella2012-04-234-9/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This will render the error message on :#{attribute}_confirmation instead of on attribute itself. When rendering confirmation errors inline on the form with form builders such as SimpleForm and Formtastic it is confusing to the ender user to see the confirmation error message on the attribute element. Instead it makes more sense to have this validation error render on the confirmation field instead. The i18n message has been updated for the confirmation validator error message to include the original attribute name.
* | | Generate appropriate error more judiciouslyMarc-Andre Lafortune2012-04-291-0/+15
| |/ |/|
* | Do not modify options hash in human_attribute_name, remove reverse_mergeCarlos Antonio da Silva2012-04-281-2/+8
| |
* | Merge pull request #5841 from oscardelben/rename_count_observersJosé Valim2012-04-241-1/+1
|\ \ | | | | | | Rename Observing#count_observers to Observing#observers_count
| * | Rename Observing#count_observers to Observing#observers_countOscar Del Ben2012-04-141-1/+1
| |/
* / Fix secure_password setterOscar Del Ben2012-04-241-0/+6
|/
* test against ruby features in order to fix tests on Ruby 2.0Aaron Patterson2012-03-261-1/+9
|
* Merge pull request #5374 from ↵José Valim2012-03-231-24/+0
|\ | | | | | | | | nertzy/remove_deprecated_partial_path_from_active_model_naming Remove ActiveModel::Naming#partial_path
| * Remove ActiveModel::Naming#partial_pathGrant Hutchins2012-03-101-24/+0
| | | | | | It was deprecated in 3.2
* | Revert "AM::MassAssingmentSecurity: improve performance"José Valim2012-03-151-1/+1
| | | | | | | | | | | | It introduces backwards incompatible changes in the API. This reverts commit 7d1379ffdbbaf01e99833dc06611b7e4f3799522.
* | AM::MassAssingmentSecurity: improve performanceBogdan Gusiev2012-03-141-1/+1
| |
* | Fix comments about to_partial_pathGrant Hutchins2012-03-101-1/+1
|/
* Make sure serializable hash with :include always returns string keysCarlos Antonio da Silva2012-03-091-13/+13
|
* Add docs with usage examples for ActiveModel::ModelCarlos Antonio da Silva2012-03-031-0/+7
| | | | | Also add test to ensure basic model does not explode when initialized with nil.