Commit Graph

485 Commits

Author SHA1 Message Date
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
ae196e85ee7169700afac2eecdc276bc06b10b8d.
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 0317b93c17a46d7663a8c36edc26ad0ba3d75f85
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