Commit Graph

760 Commits

Author SHA1 Message Date
Robin Dupret 823e4e9115 Add the platform-specific skip helpers to ActiveModel 2015-03-02 14:05:07 +01:00
Robin Dupret 95c2fc9679 Follow-up to #10776
The name `ActiveModel::AttributeAssignment::UnknownAttributeError` is
too implementation specific so let's move the constant directly under
the ActiveModel namespace.

Also since this constant used to be under the ActiveRecord namespace, to
make the upgrade path easier, let's avoid raising the former constant
when we deal with this error on the Active Record side.
2015-02-26 15:40:03 +01:00
Ian Ker-Seymer c5d62cb86d activemodel: make .model_name json encodable
Previously, calling `User.model_name.to_json` would result in an infinite
recursion as `.model_name` inherited its `.as_json` behavior from Object. This
patch fixes that unexpected behavior by delegating `.as_json` to :name.
2015-02-24 11:00:32 -07:00
Wojciech Wnętrzak 9ebb778ca0 Simplify and alias ActiveModel::Errors methods where possible 2015-02-20 21:42:00 +01:00
Lucas Mazza 830b7041f2 Move the `validate!` method to `ActiveModel::Validations`. 2015-02-20 16:05:26 -02:00
Wojciech Wnętrzak fd38838f29 Deprecate `ActiveModel::Errors` `add_on_empty` and `add_on_blank` methods
without replacement.
2015-02-19 14:10:38 +01:00
Rafael Mendonça França 3c750c4c6c Merge pull request #18634 from morgoth/deprecate-some-errors-methods
Deprecate `ActiveModel::Errors` `get`, `set` and `[]=` methods.
2015-02-18 18:58:28 -02:00
Rafael Mendonça França 7919c29d50 Merge pull request #16381 from kakipo/validate-length-tokenizer
Allow symbol as values for `tokenizer` of `LengthValidator`
2015-02-13 12:09:36 -02:00
Vipul A M 6eced6a1fe Removed magic comments # encoding: utf-8 , since its default from ruby 2.0 onwards. 2015-02-03 20:51:40 +05:30
Wojciech Wnętrzak 6ec8ba16d8 Deprecate `ActiveModel::Errors` `get`, `set` and `[]=` methods.
They have inconsistent behaviour currently.
2015-02-01 13:14:00 +01:00
Yves Senn c8e39e2fd4 Merge pull request #18670 from morgoth/fix-duplicating-errors-details
Fixed duplicating ActiveModel::Errors#details
2015-01-24 15:08:11 +01:00
Wojciech Wnętrzak fb7d95b212 Fixed duplicating ActiveModel::Errors#details 2015-01-24 11:58:55 +01:00
Eugene Gilburg 5bdb42159e use attribute assignment module logic during active model initialization 2015-01-23 14:42:47 -08:00
Sean Griffin a225d4bec5 ✂️ and 💅 for #10776
Minor style changes across the board. Changed an alias to an explicit
method declaration, since the alias will not be documented otherwise.
2015-01-23 14:51:59 -07:00
Bogdan Gusiev 2606fb3397 Extracted `ActiveRecord::AttributeAssignment` to `ActiveModel::AttributesAssignment`
Allows to use it for any object as an includable module.
2015-01-23 23:43:22 +02:00
Wojciech Wnętrzak cb74473db6 Add ActiveModel::Errors#details
To be able to return type of validator, one can now call `details`
on Errors instance:

```ruby
class User < ActiveRecord::Base
  validates :name, presence: true
end
```

```ruby
user = User.new; user.valid?; user.errors.details
=> {name: [{error: :blank}]}
```
2015-01-20 22:33:42 +01:00
Sean Griffin 72570ea289 Merge pull request #18439 from mokhan/validates-acceptance-of-array
allow '1' or true for acceptance validation.
2015-01-12 12:06:00 -07:00
Carlos Antonio da Silva 8ee052cf84 Merge pull request #18454 from claudiob/test-on-option-for-amv-callbacks
Add test for AM::Validation::Callbacks with :on
2015-01-11 19:13:34 -02:00
claudiob d3927c8d18 Remove unused "deprecated_reload" method
The method was introduced in 66d0a01535 (diff-8cec05860729a3851ceb756f4dd90370R49)
for the "reset_changes is deprecated" test, but this test was successively
removed in 37175a24bd
2015-01-11 12:32:26 -08:00
claudiob 684cbee473 Add test for AM::Validation::Callbacks with :on
`before_validation` and `after_validation` from
ActiveModel::Validation::Callbacks accept an optional `:on` parameter
that was not previously documented or tested. For instance given

    before_validation :do_something, on: :create

then `object.valid?(:create)` will invoke `:do_something` while
`object.valid?` or `object.valid?(:anything_else)` will not.
2015-01-11 12:29:39 -08:00
mo khan 140557e85f allow '1' or true for acceptance validation. 2015-01-10 22:47:47 -07:00
Rafael Mendonça França 37175a24bd Remove deprecated `ActiveModel::Dirty#reset_#{attribute}` and `ActiveModel::Dirty#reset_changes`. 2015-01-04 11:58:42 -03:00
claudiob 91b8129320 Deprecate `false` as the way to halt AM callbacks
Before this commit, returning `false` in an ActiveModel `before_` callback
such as `before_create` would halt the callback chain.

After this commit, the behavior is deprecated: will still work until
the next release of Rails but will also display a deprecation warning.

The preferred way to halt a callback chain is to explicitly `throw(:abort)`.
2015-01-02 15:31:56 -08:00
claudiob f767981286 Deprecate `false` as the way to halt AM validation callbacks
Before this commit, returning `false` in an ActiveModel validation
callback such as `before_validation` would halt the callback chain.

After this commit, the behavior is deprecated: will still work until
the next release of Rails but will also display a deprecation warning.

The preferred way to halt a callback chain is to explicitly `throw(:abort)`.
2015-01-02 15:31:56 -08:00
Vipul A M 732bba8d4c - Fixed unused variable
- Changed test to verify complete message instead of verifying if message contains text.
2014-12-21 13:28:20 +05:30
claudiob b7bd7ffa63 Add AM test: after/around callback returning false
This stems from https://github.com/rails/rails/pull/17227#discussion_r21641358

It's simply a clarification of the current behavior by which if an
`after_` or `around_` ActiveModel callback returns +false+, then the callback
chain **is not halted**.

The callback chain in ActiveModel is only halted when a `before_`
callback returns `false`.
2014-12-14 21:20:49 -08:00
claudiob 9a6f20e8f0 Add AM test for after_validation returning false
This stems from https://github.com/rails/rails/pull/17227#discussion_r21641358

It's simply a clarification of the current behavior by which if an
`after_validation` ActiveModel callback returns +false+, then further
`after_` callbacks **are not halted**.
2014-12-14 21:18:31 -08:00
Godfrey Chan 4a19b3dea6 Pass through the `prepend` option to `AS::Callback`
I'm not sure what's the use case for this, but apparently it broke some apps.
Since it was not the intended result from #16210 I fixed it to not raise an
exception anymore. However, I didn't add documentation for it because I don't
know if this should be officially supported without knowing how it's meant to
be used.

In general, validations should be side-effect-free (other than adding to the
error message to `@errors`). Order-dependent validations seems like a bad idea.

Fixes #18002
2014-12-12 14:51:02 -08:00
Erik Michaels-Ober d1374f99bf Pass symbol as an argument instead of a block 2014-11-29 11:53:24 +01:00
Adam89 52720b46ea Remove redundant require of file
This file was required inside 'test/validators/namespace/email_validator.rb'
that's already required here. Therefore I removed the redundant required.
2014-11-01 19:00:12 +00:00
Garry Shutler 6c8cf21584 Add #key? to ActiveModel::Errors
Mirror Ruby's Hash#key?
2014-10-14 09:53:26 +01:00
Prathamesh Sonpatki a7ed62987c Added test for exception message for validate method
- Test case for https://github.com/rails/rails/pull/16851
2014-09-23 14:36:15 +09:00
Godfrey Chan 2b41343c34 Default to sorting user's test cases for now
Goals:

1. Default to :random for newly generated applications
2. Default to :sorted for existing applications with a warning
3. Only show the warning once
4. Only show the warning if the app actually uses AS::TestCase

Fixes #16769
2014-09-08 05:32:16 -07:00
Matthew Draper 2f52f96988 Leave all our tests as order_dependent! for now
We're seeing too many failures to believe otherwise.

This reverts commits bc116a55ca,
cbde413df3,
bf0a67931d, and
2440933fe2.
2014-09-02 23:55:34 +09:30
Akira Matsuda b23365fe5c Move model definition to test/models for test order indenendency 2014-08-28 16:56:53 +09:00
ankit1910 5284f98d79 [ci skip] make assert messages consistent 2014-08-25 22:07:27 +05:30
Akira Matsuda bc116a55ca AM, AP, AV, and AMo tests are already order_independent! 2014-08-13 21:25:10 +09:00
Rafael Mendonça França e81f3c210e Nobody sucks so nobody should call this awful method name 2014-08-12 10:51:41 -03:00
Akira Matsuda 6ffb29d24e users_dont_suck_but_only_we_suck_and_only_our_tests_are_order_dependent!
Calling ActiveSupport::TestCase.i_suck_and_my_tests_are_order_dependent! in AS::TestCase makes
everyone's tests order dependent, which should never be done by the framework.
2014-08-12 19:37:04 +09:00
Yevhene Shemet f8dcb365df Allow password to contain spaces only. 2014-08-06 22:11:06 +03:00
kakipo c3fa5c3d25 Allow symbol as values for `tokenize` of `LengthValidator` 2014-08-03 14:50:09 +09:00
Rafael Mendonça França 74c31ac5fe Merge pull request #15959 from aditya-kapoor/remove-unneeded-cases
remove unneeded test model for ActiveModel test cases.
2014-07-29 18:08:07 -03:00
Rafael Mendonça França 08754f12e6 Merge branch 'rm-remove-mocha'
Conflicts:
	actionpack/test/abstract_unit.rb
2014-07-19 18:17:13 -03:00
Rafael Mendonça França fd6aaaa0c3 Stop requiring mocha automatically
We are planning to remove mocha from our test suite because of
performance problems. To make this possible we should stop require mocha
on ActionSupport::TestCase.

This should not affect applications since users still need to add mocha
to Gemfile and this already load mocha.

Added FIXME notes to place that still need mocha removal
2014-07-19 17:35:12 -03:00
Matthew Draper e213b37fc1 Merge pull request #16210 from sonnym/assert_valid_keys_in_validate
Check for valid options in validate method
2014-07-18 07:10:49 +09:30
sonnym 0950d409b0 check for valid options in validate method
This change prevents a certain class of user error which results when
mistakenly using the `validate` class method instead of the `validates`
class method.

Only apply when all arguments are symbols, because some validations use
the `validate` method and pass in additional options, namely the
`LenghValidator` via the `ActiveMode::Validations::validates_with`
method.
2014-07-17 17:32:28 -04:00
Rafael Mendonça França 1a300b6748 Make restore_attributes public
Also make it accept a list of attributes to be changed. This will make
possible to restore only a subset of the changed attributes.

Closes #16203
2014-07-17 14:55:28 -03:00
Rafael Mendonça França 41fb06fa47 Deprecate `reset_#{attribute}` in favor of `restore_#{attribute}`.
These methods may cause confusion with the `reset_changes` that
behaves differently
of them.

Also rename undo_changes to restore_changes to match this new set of
methods.
2014-07-15 18:09:38 -03:00
Rafael Mendonça França 66d0a01535 Deprecate ActiveModel::Dirty#reset_changes in favor of #clear_changes_information
This method name is causing confusion with the `reset_#{attribute}`
methods. While `reset_name` set the value of the name attribute for the
previous value the `reset_changes` only discard the changes and previous
changes.
2014-07-15 16:04:31 -03:00
Godfrey Chan 9eb15ed6a0 Only automatically include validations when enabled
This is a follow up to #16024.
2014-07-02 15:07:57 -07:00
Aditya Kapoor 7b1a42c057 automatically include ActiveModel::Validations when include ActiveModel::SecurePassword 2014-07-03 02:51:12 +05:30
Rafael Mendonça França dc67d3d2a1 Rename rollback_changes to undo_changes
To avoid overload with database rollback
2014-06-30 16:55:01 -03:00
Rafael Mendonça França bada1d3ed6 Merge pull request #14861 from igor04/dirty-rollback
Added rollback method to ActiveModel::Dirty
2014-06-30 15:37:06 -03:00
Aditya Kapoor 94b6207910 remove unneeded test model for ActiveModel test cases. 2014-06-28 22:27:06 +05:30
Rafael Mendonça França 6099b643e6 Merge pull request #15834 from rmehner/allow_proc_and_symbol_for_only_integer
Allow proc and symbol as values for `only_integer` of `NumericalityValidator`
2014-06-26 07:03:31 -03:00
David Heinemeier Hansson d5d94a7750 Merge pull request #15871 from yuki24/add-model-name-instance-method
Add #model_name instance method to ActiveModel::Naming
2014-06-24 13:54:58 +02:00
igor04 552d4d85f3 Added rollback method to ActiveModel::Dirty 2014-06-23 23:19:43 +03:00
Aditya Kapoor d770ec0909 remove unnecessary require for json serialization test cases 2014-06-24 00:03:02 +05:30
Yuki Nishijima 10adc2ee90 Delegate #model_name method to self.class 2014-06-22 19:14:25 -07:00
Robin Mehner 64a05a928c `only_integer` of `NumericalityValidator` now allows procs and symbols 2014-06-22 12:22:27 +02:00
Akshay Vishnoi 73dc6d790c Correct typo, add test for validates_absence_of, correct method names 2014-06-16 08:22:11 +05:30
Akshay Vishnoi 9bc91260ac Use `@existing_user` while updating existing user, fixing - #ee4e86 2014-06-14 14:42:52 +05:30
Godfrey Chan ee4e86fa4b Cleaned up the `has_secure_password` test cases
* Grouped the valid test cases in one place
* Make the length of the generated password obvious
* Removed two wrong (copy-and-pasted) test cases
2014-06-14 00:43:47 -07:00
Akshay Vishnoi cabbc8f6a5 SecurePassword - Validate password must be less than or equal to 72
See #14591, Reason - BCrypt hash function can handle maximum 72 characters.
2014-06-14 12:35:31 +05:30
Aditya Kapoor 2399207789 [ci skip] add tests for ActionModel::Conversion 2014-06-11 23:18:47 +05:30
Kuldeep Aggarwal e5cc892ce6 remove depricated Validatior#setup 2014-06-10 12:27:17 +05:30
Abd ar-Rahman Hamidi 6604ce63e8 Add singular and plural form for some validation messages 2014-05-02 18:32:11 +02:00
Musannif Zahir 8753ce1a37 Fix warning for overshadowing XML variable 2014-03-28 20:11:58 +08:00
Henrik Nyh 2e70f44123 ActiveRecord/ActiveModel '#validate' alias for 'valid?'
It's unintuitive to call '#valid?' when you want to run validations but
don't care about the return value.

The alias in ActiveRecord isn't strictly necessary (the ActiveModel
alias is still in effect), but it clarifies.
2014-03-27 17:56:14 +01:00
Yves Senn 6868265fe3 comment why we are modifying global state. [ci skip] 2014-03-11 08:34:51 +01:00
Zuhao Wan cc6bc1cc46 Completely remove potential global state leaks in ActiveModel tests.
ActiveModel tests can now be run in random order.
2014-03-11 00:48:25 +08:00
Yves Senn 29bd586fed Merge pull request #14315 from zuhao/activemodel_tests_in_random_order
Run ActiveModel test suites in random order.
2014-03-09 21:03:13 +01:00
Zuhao Wan 9ffeb36265 Run ActiveModel test suites in random order.
This gets the whole ActiveModel test suites working even if
`self.i_suck_and_my_tests_are_order_dependent!` is disabled
in `ActiveSupport::TestCase`.

Two places are found that potentially leak global state. This patch
makes sure states are restored so that none of the changes happen in
a single test will be carried over to subsequence tests.
2014-03-10 03:52:51 +08:00
Pavel Penkov 62e8145430 Tests for indifferent access using full_messages_for. Closes #11916 2014-03-08 13:28:43 +01:00
Eric Hutzelman 088c11658a Fix some validators when used on model instance
Now that Validator #setup is called from the initializer, we need a
reference to the model's class to be passed in to allow the validators
to continue functioning when used at the instance level.

Closes #14134.
2014-02-26 21:35:49 -03:00
Dmitry Polushkin 8acd58f23c add test coverage for activemodel Dirty#reset_changes 2014-02-09 18:44:24 +00:00
Yves Senn 7d196cf360 `#to_param` returns `nil` if `to_key` returns `nil`. Closes #11399.
The documentation of `#to_key` (http://api.rubyonrails.org/classes/ActiveModel/Conversion.html#method-i-to_key)
states that it returns `nil` if there are no key attributes. `to_param` needs
to be aware of that fact and return `nil` as well.

Previously it raised the following exception:

```
  1) Error:
ConversionTest#test_to_param_returns_nil_if_to_key_is_nil:
NoMethodError: undefined method `join' for nil:NilClass
    /Users/senny/Projects/rails/activemodel/lib/active_model/conversion.rb:65:in `to_param'
    /Users/senny/Projects/rails/activemodel/test/cases/conversion_test.rb:34:in `block in <class:ConversionTest>'
```
2014-02-04 10:27:46 +01:00
Kuldeep Aggarwal 20317f3d4d use the new clear_validators! api everywhere to reset validators in tests 2014-01-28 00:13:35 +05:30
Carlos Antonio da Silva 801baeed69 Use the new clear_validators! api to reset validators in tests 2014-01-27 08:26:54 -02:00
Carlos Antonio da Silva 5336ce265a Merge tests about multiple validation contexts 2014-01-27 08:26:54 -02:00
Vince Puzzella 8855163bdb Ability to specify multiple contexts when defining a validation.
Example:

validates_presence_of :name, on: [:update, :custom_validation_context]
2014-01-27 03:26:27 -05:00
Godfrey Chan 98705d88cd Some minor fixes 2014-01-24 20:06:31 -08:00
Godfrey Chan b6ddbfb158 Removed old tests 2014-01-24 19:49:31 -08:00
Godfrey Chan 19a4ef305d Rewrote the tests for has_secure_password 2014-01-24 19:49:30 -08:00
Adrien Coquio db95c7dceb Update ActiveModel::Errors.has_key? test 2014-01-22 21:26:53 +01:00
Adrien Coquio 1c2c552703 Add failing test for ActiveModel::Errors#has_key? method
From the doc, this method should return false and not nil if there is no errors for this key
2014-01-22 15:49:08 +01:00
Rafael Mendonça França fc913d4016 Fix typo 2014-01-21 22:38:07 -02:00
Rafael Mendonça França 06a00038ef When applying changes or reseting changes create the right class
Before this patch after the changes are applied the changes can be only
accessed using string keys, but before symbols are also accepted.

After this change every state of the model will be consistent.
2014-01-20 22:58:14 -02:00
T.J. Schuck 72bb3fc297 Change all "can not"s to the correct "cannot". 2014-01-03 17:02:31 -05:00
Godfrey Chan f3a8be3b8b Merge pull request #13131 from gja/changed-accepts-values
Allows you to check if a field has changed to a particular value
2013-12-30 22:05:56 -08:00
Carlos Antonio da Silva 7530c82e82 Disable locale checks to avoid warnings in Active Model tests [ci skip]
Missed AMo when adding to the other components in
ae196e85ee.
2013-12-23 17:51:07 -02:00
Akira Matsuda a3ebe7f3a7 Unused classes in AMo tests 2013-12-19 18:31:11 +09:00
Tejas Dinkar da2b05bb6b Allows you to check if an attribute has changed to a particular value
model.name_changed?(from: "Pete", to: "Ringo")
2013-12-15 12:13:31 +05:30
Guillermo Iguaran 87e1e86640 Merge pull request #13273 from robertomiranda/test-remove-require
Remove require 'models/administrator', Administrator is not used in secure password test
2013-12-11 05:39:14 -08:00
robertomiranda df7e5b69de Remove require 'models/administrator', Administrator is not used in secure password test 2013-12-11 08:34:28 -05: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
T.J. Schuck 5d7b413d84 Use bcrypt's public cost attr, not internal constant
See:

- https://github.com/codahale/bcrypt-ruby/pull/63
- https://github.com/codahale/bcrypt-ruby/pull/64
- https://github.com/codahale/bcrypt-ruby/pull/65
2013-10-10 11:46:59 -04:00
Rafael Mendonça França c48c111bb2 Merge pull request #8791 from griffinmyers/master
Updated DirtyModel's @changed_attributes hash to be symbol/string agnostic

Conflicts:
	activemodel/CHANGELOG.md
2013-10-03 11:37:10 -03:00
Rafael Mendonça França 9aa1a3d853 Merge pull request #10816 from bogdan/less-dirty-dirty
Make AM::Dirty less dirty to plugin into AR or other library
2013-09-23 10:59:05 -03:00
Rajarshi Das 782d794c20 use assert_empty in activemodel conditional validation test cases 2013-09-10 17:26:39 +05:30
Rajarshi Das e21a18bed0 fix actionview and activemodel test cases typos 2013-09-05 14:21:57 +05:30
Rajarshi Das 9f478deaab remove unused instance variable 2013-08-23 16:04:08 +05:30
Guillermo Iguaran 99e33c03b7 Dont' check for any order in hash since we aren't sorting it and this is determinated only by the used interpreter 2013-08-18 16:40:21 -05:00
Guillermo Iguaran c40111c346 Refactor serialization test for hash order 2013-08-18 09:04:09 -05:00
Gaurish Sharma 90c450f6cd Avoid Skip in test, have a unified test for order 2013-08-09 15:27:21 +05:30
Gaurish Sharma 9f8116fb77 Add tests for ActiveModel::Serializers::JSON#as_json ordering 2013-08-09 04:32:00 +05:30
Max Shytikov af1e3b7c48 fix tests 2013-07-30 20:03:57 +03:00
Vladimir Kiselev 3be0cdfa55 Fix secure_password password_confirmation validations 2013-07-24 03:14:15 +04:00
Vipul A M 404a61e19c Remove redundant escapes from xml serialization test 2013-07-01 10:17:33 +05:30
Paul Nikitochkin e63ba910ae Remove deprecation warning from AttributeMethodsMatcher 2013-06-28 00:16:42 +03:00
Łukasz Strzałkowski 468939297d Remove deprecated attr_protected/accessible
Rails 4.0 has removed attr_protected and attr_accessible feature in favor of Strong Parameters.
2013-06-27 20:38:30 +02:00
Carlos Antonio da Silva 61346d1b42 Merge pull request #10774 from chuckbergeron/validates-inclusion-of-accuracy-for-non-numeric-ranges
Greater accuracy for validates_inclusion_of on non-numeric ranges

Closes #10774, fixes #10593
2013-06-25 21:48:41 -03:00
Fred Wu 85750d43fa ActiveModel::Model inclusion chain backward compatibility 2013-06-20 12:16:17 +10:00
Fred Wu 0b502cb879 Fixes AciveModel::Model with no ancestors, fixes #11004
Signed-off-by: José Valim <jose.valim@plataformatec.com.br>
2013-06-19 17:16:04 +02:00
Fred Wu e3dc10f133 Fixed ActiveModel::Model's inclusion chain 2013-06-19 11:25:10 +10:00
Andrey Koleshko 120f6e07f6 Stub logger for tests 2013-06-06 19:47:57 +03:00
Phil Calvin 5d93ef8f45 Fix regression in has_secure_password.
If the confirmation was blank, but the password wasn't, it would still save.
2013-05-30 11:18:43 -07:00
Charles Bergeron 0317b93c17 Use Range#cover? for Numeric ranges (tests via endpoints) and use Range#include? for non-numeric ranges
added changelog message
2013-05-27 23:54:25 -07:00
William Myers 0e655873d4 DirtyModel uses a hash to keep track of any changes made to attributes
of an instance. When using the attribute_will_change! method, you must
supply a string and not a symbol or the *_changed? method will break
(because it is looking for the attribute name as a string in the keys
of the underlying hash). To remedy this, I simply made the underlying
hash a HashWithIndifferentAccess so it won't matter if you supply
the attribute name as a symbol or string to attribute_will_change!.
2013-05-27 23:41:26 -04:00
Nick Sutterer 7d84c3a2f7 deprecate Validator#setup (to get rid of a respond_to call). validators do their setup in their constructor now. 2013-05-23 10:00:44 -03:00
Aaron Patterson 9fef7c8dc9 Merge pull request #10527 from zenspider/squishy_minitest5
Squishy minitest5
2013-05-16 13:41:54 -07:00
Aaron Patterson 23122ab2d4 callbacks are wrapped with lambdas 2013-05-10 10:13:21 -07:00
Ryan Davis 3073c53198 Updates to make rails 4 happy with minitest 5:
+ Namespace changes, overhaul of runners.
+ Internal ivar name changes
- Removed a logger globally applied to tests that spew everywhere?!?
+ Override Minitest#__run to sort tests by name.
+ Reworked testing isolation to work with the new cleaner architecture.
- Removed a bunch of tests that just test minitest straight up. I think these changes were all merged to minitest 4 a long time ago.
- Minor report output differences.
2013-05-06 17:38:45 -07: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
Carlos Antonio da Silva 3e47e193c6 Merge pull request #10286 from neerajdotname/fix-wrong-test-name-and-failure-message
fix wrong test description and failure message
2013-04-21 09:22:51 -07:00
Neeraj Singh 2242317fdd fix wrong test description and failure message 2013-04-21 12:00:38 -04:00
Neeraj Singh cf69d527fe Added tests for if condition in Active Model callbacks 2013-04-21 11:34:12 -04:00
Anupam Choudhury e000aa92dd Removed unused setup 2013-04-09 20:57:55 +05:30
Carlos Antonio da Silva 09c55dcc5d Review some tests from AMo::Errors to remove "should" usage
Also remove duplicated tests for Errors#as_json and minor improvements
in some tests.
2013-03-30 15:04:09 -03:00
Rafael Mendonça França b8b3df0e63 Merge pull request #8527 from shockone/patch-1
Add a method full_messages_for to the Errors class
2013-03-25 09:04:25 -07:00
shock_one ec1b715b0e Add a method full_messages_for to the Errors class 2013-03-24 09:38:28 +02:00
Vipul A M 24fee97581 Add Error#full_message test; Fix typos
Introduce test on Error#full_message for attribute with underscores; Fix
some typos
2013-03-22 14:53:32 +05:30
Vipul A M 233737706c fix some typos found in activemodel 2013-03-18 17:20:05 +05:30
Vipul A M 29dcf096b0 Small typos here and there. 2013-03-15 11:55:03 +05:30
Yves Senn 8c1687bbf8 `has_secure_password` is not invalid when assigning empty Strings.
Closes #9535.

With 692b3b6 the `password=` setter does no longer set blank passwords.
This triggered validation errors when assigning empty Strings to `password`
and `password_confirmation`.

This patch only sets the confirmation if it is not `blank?`.
2013-03-04 18:56:05 +01:00
Yves Senn b501ee47fa `validates_confirmation_of` does not override writer methods. 2013-03-04 18:51:34 +01:00
Angelo capilleri 40c1ee8b7d added more accurate test for add_on_empty
with the current tests, if delete the assignment of is_empty in add_on_empty method
the tests not fail. With this test, if we delete is_empty, the test fails
2013-02-19 18:48:37 +01:00
Rafael Mendonça França e16110c4b8 Take care of whitespaces and changing the hash syntax 2013-02-04 09:59:22 -02:00
David 6e2cba1c8b test for issue 8931 2013-02-02 13:00:52 +08:00
Attila Domokos 69b6129fd4 Adding the route_key and param_key tests
This way all the tests are testing the same fields
2013-01-22 22:13:43 -05:00
Carlos Antonio da Silva 203f787321 Merge pull request #8940 from adomokos/adding_tests_for_changed_attributes
Cleaning up ActiveModel::Dirty tests
2013-01-15 13:02:57 -08:00
Attila Domokos 63333e600f Cleaning up ActiveModel::Dirty tests
* Clarifying what the #changed method returns
* Adding tests to describe what the #changed_attributes returns
* Updating test name based on pull request comment
* Moving the test lower in the file per pull request comment
2013-01-15 10:24:57 -05:00
Yves Senn bc19c0d09c test for ActiveModel::Conversion#to_partial_path and namespaced models 2013-01-14 21:17:22 +01:00
Attila Domokos 01434a5ee6 Adding tests for ActiveModel::Model
* Verifying persisted? is false when Model initialized
* Passing nil to Model should not blow up
* Changing test name to the one suggested in pull request comment
2013-01-12 20:04:24 -05:00
Attila Domokos 7171f9cc8f Covering untested methods for ActiveModel::Errors 2013-01-10 21:41:35 -05:00
Rafael Mendonça França 5da4d5142a Add active_support/testing/autorun
minitest/autorun load minitest/spec polluting the global namespace with
the DSL that we don't want on Rails
2012-12-31 13:57:24 -03:00
Rafael Mendonça França 9647d4b6f4 Add CHANGELOG entry for #8622 2012-12-26 19:22:38 -03:00
Rafael Mendonça França 78fd14c8de Revert the change at ActiveModel::Errors#add_on_blank and fix in the
right place.

The EachValidator#validate already handle :allow_blank and :allow_nil,
correctly.

Closes #8622.

Fix #8621.
2012-12-26 18:55:47 -03:00
Colin Kelley d4c30a0226 Tests and fix for validates_presence of :allow_nil, :allow_blank
Conflicts:
	activemodel/lib/active_model/errors.rb
2012-12-26 18:19:27 -03:00
Akira Matsuda 08cf17d708 chmod -x from non-script files 2012-12-24 23:36:19 +09:00
Roberto Vasquez Angel d72a07f1d1 Add `ActiveModel::Validations::AbsenceValidator`, a validator to check the absence of attributes.
Add `ActiveModel::Errors#add_on_present` method. Adds error messages to present attributes.
2012-12-15 16:27:44 -05:00
Renato Mascarenhas cc62ec1e8c Actually test that ActiveModel::Errors#add defaults to :invalid. 2012-12-01 22:30:34 -02:00
Renato Mascarenhas 703b6387ee Call `full_messages` instead of `to_a` in its spec. 2012-12-01 22:30:33 -02:00
Renato Mascarenhas cf7ab6056a Reset attributes should not report changes.
When resetting an attribute, you expect it to return to the state it was
before any changes. Namely, this fixes this unexpected behavior:

~~~ruby
model.name = "Bob"
model.reset_name!
model.name_changed? #=> true
~~~
2012-12-01 16:58:09 -02:00
Carlos Antonio da Silva c2be9b0c3e Simplify keys order test for as_json in Active Model 2012-11-30 10:21:24 -02: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
Steve Klabnik 9504b44cf6 Specify type of singular association during serialization
When serialising a class, specify the type of any singular associations, if
necessary. Rails already correctly specifies the :type of any enumerable
association (e.g. a has_many association), but made no attempt to do so for
non-enumerables (e.g. a has_one association).
We must specify the :type of any STI association. A has_one
association to a class which uses single-table inheritance is an example of
this type of association.

Fixes #7471
2012-11-28 11:48:32 -08:00
Rafael Mendonça França 5658923daa Merge pull request #7282 from xHire/validates_length_of_fix
Length validation handles correctly nil. Fix #7180

Conflicts:
	activemodel/CHANGELOG.md
2012-11-26 18:44:07 -02:00
Carlos Antonio da Silva 26a3b70cc4 Merge pull request #8320 from senny/active_model_log_folder
Log output from activemodel's railtie_test directly to STDOUT.

There's no logging going on here, but since we initialize the app, the
logger is set and the folder is automatically created. With this change,
the default logger is not created, so there is no logging folder anymore.

Conflicts:
	activemodel/test/cases/railtie_test.rb
2012-11-26 15:32:25 -02:00
Yves Senn 6fc83201db log output from activemodel's railtie_test directly to STDOUT
after this patch, running the tests in activemodel will no longer
create an untracked log/ folder inside of activemodel
2012-11-26 17:23:20 +01:00
Michal Zima ea76e9a312 Length validation handles correctly nil. Fix #7180
When nil or empty string are not allowed, they are not valid.
2012-11-26 12:34:32 +01:00
Carlos Antonio da Silva 3da1649828 Require active_model/railtie directly instead of rails/all
Use Class.new with a block instead of tap to configure it.
2012-11-26 09:19:57 -02:00
Carlos Antonio da Silva c2c1ecb05e Use secure password min cost option in its own tests for a speed up
Around 0.564359s => 0.092244s speed up in my machine.
2012-11-21 19:34:55 -02:00
Trevor Turk 06faa6da80 Use BCrypt's MIN_COST in the test environment for speedier tests 2012-11-14 09:42:54 -06:00
Vasiliy Ermolovich 70ecf6c518 use Array() instead flatten
* move ActiveModel::Errors tests to errors_test.rb
* add spec coverage for add_on_empty and add_on_blank
2012-11-05 18:29:31 +03:00
Carlos Antonio da Silva b1fe78e0cb Raise ArgumentError when no attribute is given to AMo::EachValidator
ArgumentError is better suited than RuntimeError for this.
2012-11-04 11:41:05 -02:00
Vijay Dev 3b0bb08699 Merge branch 'master' of github.com:lifo/docrails
Conflicts:
	actionpack/lib/action_controller/metal/mime_responds.rb
	activerecord/lib/active_record/attribute_methods.rb
	guides/source/working_with_javascript_in_rails.md
2012-11-03 01:56:16 +05:30
Cédric FABIANSKI 3152ee878a Add test for code change introduced in this commit f20032f 2012-10-29 21:55:09 +01: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
AvnerCohen 77eb1fb22d convert comments to 1.9 hash syntax 2012-10-22 19:34:24 +02:00
dfens ab9140ff02 Cleanup trailing whitespaces 2012-10-12 09:56:39 +02:00
Rafael Mendonça França 86062005a7 Revert "Merge pull request #7826 from sikachu/master-validators-kind"
This reverts commit 4e9f53f973, reversing
changes made to 6b802cdb4f.

Revert "Don't use tap in this case."

This reverts commit 454d820bf0.

Reason: Is not a good idea to add options to this method since we can do
the same thing using method composition.

    Person.validators_on(:name).select { |v| v.kind == :presence }

Also it avoids to change the method again to add more options.
2012-10-02 23:57:00 -03:00
Prem Sichanugrist 4f9b59dba0 Make `.validators_on` accept `:kind` option
This will filter out the validators on a particular attribute based on
its kind.
2012-10-02 22:09:06 -04: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 8cfe95d719 Don't use assert_nothing_raised when assert_equal is used 2012-09-16 23:58:21 -05:00
Guillermo Iguaran 1fa4f9243d Rename ForbiddenAttributes exception to ForbiddenAttributesError 2012-09-16 23:58:21 -05:00
Guillermo Iguaran 52aa5343f4 Change AMo::ForbiddenAttributesProtection tests to use a subclass of Hash instead of monkey patch permitted? method in regular hashes 2012-09-16 23:58:19 -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
Carlos Antonio da Silva 0180e090ab Update Active Model xml serialization test to reflect a change in builder
Due to a change in builder, nil values and empty strings now generates
closed tags, so instead of this:

    <pseudonyms nil=\"true\"></pseudonyms>

It generates this:

    <pseudonyms nil=\"true\"/>

Document this change in Rails so that people can track it down easily if
necessary.
2012-09-07 13:08:30 -03:00
kennyj 9063f3729b Fix method redefined warnings. 2012-08-29 02:38:12 +09:00
Gabriel Sobrinho 2f3eb484f2 Accept a symbol for `:in` option on inclusion and exclusion validators 2012-08-24 15:26:17 -03:00
Francesco Rodriguez 961957d570 Fix ActiveModel tests that depend on run order 2012-08-23 16:00:58 -05:00
Rafael Mendonça França cfd7f4e9a0 Merge pull request #7024 from bogdan/strict_validation_custom_exception
AM::Validation#validates: custom exception for :strict option

Conflicts:
	activemodel/CHANGELOG.md
2012-08-16 16:59:04 -03:00
Anthony 78f5874c82 Following the false issue reporting I did here : https://github.com/rails/rails/issues/6958
- Enable propagation of :skip_types, :dasherize and :camelize on included models by default
- Adding the option to override this propagation on a per-include basis (:include => { :model => { :dasherize => false } }
- Enough tests to prove it works
- Updated activemodel CHANGELOG.md

Squashed my commits
2012-08-13 19:14:24 -07:00
Bogdan Gusiev 2e4f7986b8 AM::Validation#validates: ability to pass custom exception to `:strict` option 2012-08-06 13:45:27 +03:00
Xavier Noria 5ea6b0df9a load active_support/core_ext/object/inclusion in active_support/rails 2012-08-02 21:59:22 +02: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
Accessd f35f6ab003 fix typo in callbacks test 2012-07-24 12:01:41 +04:00
Rafael Mendonça França 770fa81bba Don't pass `:within` option to the i18n 2012-07-20 14:10:25 -03:00
Rafael Mendonça França 53edd32684 `validates_inclusion_of` and `validates_exclusion_of` now accept
`:within` option as alias of `:in` as documented.

Fix #7118
2012-07-20 13:53:31 -03:00
Rafael Mendonça França fb8cf55868 Merge pull request #6800 from mschneider/dynamic_finders_for_aliased_attributes
Dynamic finders for aliased attributes
2012-06-22 07:51:11 -07:00
Maximilian Schneider f984b8152f made dynamic finders alias_attribute aware
previously dynamic finders only worked in combination with the actual
column name and not its alias defined with #alias_attribute
2012-06-22 16:44:01 +02:00
Carlos Antonio da Silva 965b779eb2 Add some coverage for AR serialization with serializable_hash
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.
2012-06-22 08:28:03 -03:00
Jon Leighton e030f26ad3 Simplify AR configuration code.
Get rid of ActiveModel::Configuration, make better use of
ActiveSupport::Concern + class_attribute, etc.
2012-06-15 19:15:36 +01:00
MrBrdo bc7c0b5c10 prevent users from unknowingly using bad regexps that can compromise security (http://homakov.blogspot.co.uk/2012/05/saferweb-injects-in-various-ruby.html) 2012-06-14 18:10:49 +02:00
Piotr Sarnacki 41d63710f2 Merge pull request #6668 from pomnikita/master
Compact array of values added to PermissionSet instance
2012-06-08 11:35:13 -07:00
Nikita Pomyashchiy 00ff0a6776 Compact array of values added to PermissionSet instance 2012-06-08 01:00:34 +04:00
Francesco Rodriguez ab11a2780f change AMS::JSON.include_root_in_json default value to false
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.
2012-06-06 01:11:39 -05:00
José Valim 555d8152c7 Merge pull request #5843 from kuroda/translation_of_deeply_nested_model_attributes
Fix human attribute_name to handle deeply nested attributes
2012-05-29 23:26:26 -07:00
Steve Purcell b3ccd7b27a Don't enable validations when passing false hash values to ActiveModel.validates
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.)
2012-05-28 15:02:02 +01:00
José Valim 56417b4092 Merge pull request #4785 from ayamomiji/add-self-to-allow-method-name-using-ruby-keyword
add `self.` to allow method name using ruby keyword
2012-05-25 00:29:07 -07:00
Angelo capilleri 5646d65d01 changed xml type datetime to dateTime, fixes #6328
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
2012-05-23 14:45:56 +02:00
Aaron Patterson 1b604c73f1 Merge pull request #6215 from erichmenge/fix_has_secure_password
Fix has secure password
2012-05-17 10:32:15 -07:00
Naoto Takai 80a2c9e5db Improve logging of ActiveModel::MassAssignmentSecurity::Sanitizer 2012-05-17 06:55:41 +09:00
Tsutomu Kuroda b0e2fc843b Fix human attribute_name to handle deeply nested attributes
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.
2012-05-16 08:39:48 +09:00
Carlos Antonio da Silva 9b4f5041d2 Kill whitespaces ✂️ 2012-05-15 13:38:29 -03:00
Carlos Antonio da Silva 3d1b078a5b Merge pull request #6284 from acapilleri/dup_validation
clean the erros if an object that includes validation  is duped.
2012-05-15 05:20:57 -07:00
Francesco Rodriguez 00c94d7d94 updating define_attribute_methods documentation 2012-05-14 11:38:23 -05:00
Francesco Rodriguez 05234b358f allow define_attribute_methods to pass multiple values 2012-05-14 11:35:15 -05:00
Angelo Capilleri f9ae1baa0a clean the erros if an object that includes validations errors is duped. Fixes #5953 2012-05-13 23:24:05 +02:00
ayaya c140a27fc5 fix `alias_attribute` will raise a syntax error if make an alias on a
column that named as a ruby keyword
2012-05-14 00:57:29 +08:00
Santiago Pastorino 36dd1857dc Remove useless load path modifications 2012-05-11 19:00:35 -03:00
Jon Leighton a8637cf493 Use respond_to?(:to_ary) rather than is_a?(Enumerable) to detect collection-thing. 2012-05-11 20:11:04 +01:00
Erich Menge f021377358 Updated tests for has_secure_password. 2012-05-08 18:08:55 -05:00
Marc-Andre Lafortune dc74f0cb1b notify_observers should be public 2012-04-30 22:13:26 -04:00
Aaron Patterson 206b43a954 Merge pull request #6063 from marcandre/observer_extra_args
Allow extra arguments for Observers
2012-04-30 16:43:22 -07:00
Marc-Andre Lafortune 24c068d67d Allow extra arguments for Observers 2012-04-30 18:10:03 -04:00
Arun Agrawal 7f248076a3 build fix for observing_test.rb
introduced here 17c990b153
2012-04-30 15:27:18 +05:30
Santiago Pastorino 4cff1a2809 Merge pull request #6072 from marcandre/observer_simplify_test
Observer: simplify tests
2012-04-30 00:15:51 -07:00
Jeremy Kemper 0393c7cd51 Merge pull request #6071 from marcandre/observer_redef
Fix Observer by acting on singleton class. Fixes #3505.
2012-04-29 21:10:15 -07:00
Marc-Andre Lafortune 17c990b153 Observer: simplify tests 2012-04-29 22:02:02 -04:00
Marc-Andre Lafortune bad44e4f8f Fix Observer by acting on singleton class [#3505]
Also [issue #1034] [pull #6068]
2012-04-29 21:51:50 -04:00
Aaron Patterson f975a8663e Merge pull request #5942 from bcardarella/confirmation_error_message_on_confirmation_attribute
confirmation validation error attribute
2012-04-29 16:29:33 -07:00
Marc-Andre Lafortune 569fb1fffb Generate appropriate error more judiciously 2012-04-29 00:51:56 -04:00
Carlos Antonio da Silva cafe6a38f5 Do not modify options hash in human_attribute_name, remove reverse_merge 2012-04-28 11:23:29 -03:00
José Valim cd556c9388 Merge pull request #5841 from oscardelben/rename_count_observers
Rename Observing#count_observers to Observing#observers_count
2012-04-24 23:09:48 -07:00
Oscar Del Ben 692b3b6b6a Fix secure_password setter 2012-04-24 19:16:01 +02:00
Brian Cardarella 4433b1a99a Support i18n attributes for confirmation 2012-04-24 01:05:41 -04:00
Brian Cardarella fcc534ed76 confirmation validation error attribute
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.
2012-04-23 17:16:05 -04:00
Oscar Del Ben 27d6ccd8c8 Rename Observing#count_observers to Observing#observers_count 2012-04-14 10:48:53 +02:00
Aaron Patterson 6289f455ae test against ruby features in order to fix tests on Ruby 2.0 2012-03-26 11:32:21 -07:00
José Valim 35e8de6344 Merge pull request #5374 from nertzy/remove_deprecated_partial_path_from_active_model_naming
Remove ActiveModel::Naming#partial_path
2012-03-23 05:57:35 -07:00
José Valim eb8f0ddb67 Revert "AM::MassAssingmentSecurity: improve performance"
It introduces backwards incompatible changes in the API.

This reverts commit 7d1379ffdb.
2012-03-15 18:41:54 +01:00
Bogdan Gusiev 7d1379ffdb AM::MassAssingmentSecurity: improve performance 2012-03-14 14:11:52 +02:00
Grant Hutchins bf8d7574bf Remove ActiveModel::Naming#partial_path
It was deprecated in 3.2
2012-03-10 18:02:36 -05:00
Grant Hutchins e78c5eeba1 Fix comments about to_partial_path 2012-03-10 17:40:27 -05:00
Carlos Antonio da Silva 10c3304db6 Make sure serializable hash with :include always returns string keys 2012-03-09 21:51:12 -03:00
Carlos Antonio da Silva cb9d03f0d4 Add docs with usage examples for ActiveModel::Model
Also add test to ensure basic model does not explode when
initialized with nil.
2012-03-03 04:45:30 -03:00
Guillermo Iguaran 3b822e91d1 Add ActiveModel::Model, a mixin to make Ruby objects to work with AP inmediatly 2012-03-02 23:59:55 -05:00
Bogdan Gusiev 534dc4ca1a AM::Errors: allow :full_messages parameter for #as_json 2012-02-20 11:17:11 +02:00
Fabio Yamate d204918f91 Fix sanitize_for_mass_assigment when role is nil
There is an example in Rails documentation that suggests implementing
assign_attributes method for ActiveModel interface, that by default
sends option role with nil. Since mass_assignment_authorizer never
is called without args, we can move the default value internally.
2012-02-15 11:13:54 -02:00
Carlos Antonio da Silva ad9f968c4a Make sure serializable hash with :methods option returns always string keys 2012-02-13 11:22:59 -02:00
Carlos Antonio da Silva 5bcb4e3c18 Cleanup extra spaces 2012-02-13 11:20:19 -02:00
prasath 848ee296ec test title changed corresponding to the test 2012-02-09 02:11:36 +05:30
Aaron Patterson 06b9c905a9 Merge pull request #4930 from ask4prasath/ordered_hash_replaced
Replacing ordered hash to ruby hash on active model
2012-02-08 08:59:00 -08:00
José Valim a17d047a73 Trim down Active Model API by removing valid? and errors.full_messages 2012-02-07 23:10:43 +01:00
prasath 47628ec128 replacing ordered hash to ruby hash 2012-02-08 00:34:47 +05:30
Niels Ganser 60dad828ae To infinity… and beyond!
Allow infinite values for validates_length_of. Particularly useful
for prettily defining an open ended range such as

validates_length_of :human_stupidity, :within => 0..Float::INFINITY
2012-02-06 12:58:32 +01:00