Commit Graph

1426 Commits

Author SHA1 Message Date
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
Peter Markou
f6ab778297 Fix errors for four of the code samples
The four code samples that fail to run are:

- Add attribute magic to objects. Fixed by introducing a Person
  instance variable.

- Tracking value changes. Fixed by replacing `attr_accessor` with
  `define_attribute_methods`, providing getter and setter methods
  for `name` and providing the missing `Person#save` method. A
  call to `Person#save` has to precede the `person.name = 'robert'`
  assignment, if we want `previous_changes` to include 'bob'.

- Adding `errors` interface to objects. Fixed by introducing a
  Person instance variable, assigning `nil` to its name and calling
  `Person#validate!`.

- Custom validators. Fixed by defining `HasNameValidator` before
  it is used by `ValidatorPerson`.

All the code samples can now be run smoothly.

Call Dirty#changes_applied in Person#save, instead of modifying instance vars.
2014-03-08 21:19:42 +02:00
Pavel Penkov
62e8145430 Tests for indifferent access using full_messages_for. Closes #11916 2014-03-08 13:28:43 +01:00
Prem Sichanugrist
2dd2fcf896
Introduce Rails.gem_version
This method return `Gem::Version.new(Rails.version)`, suggesting a more
reliable way to perform version comparison.

Example:

    Rails.version #=> "4.1.2"
    Rails.gem_version #=> #<Gem::Version "4.1.2">

    Rails.version > "4.1.10" #=> false
    Rails.gem_version > Gem::Version.new("4.1.10") #=> true
    Gem::Requirement.new("~> 4.1.2") =~ Rails.gem_version #=> true

This was originally introduced as `.version` by @charliesome in #8501
but got reverted in #10002 since it was not backward compatible.

Also, updating template for `rake update_versions`.
2014-03-05 12:37:38 -05: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
Carlos Antonio da Silva
c20fe91b05 Pass strings to demodulize method
Goes along with fea1cdcff4d50d302d8e8532432c3ab107ff816d and
59ec4562a2e70df455b2e44a67c340fa5254e26e.
2014-02-26 21:20:56 -03:00
Aaron Patterson
fea1cdcff4 pass the class name to tableize
We should not rely on to_s to return the name of the class
2014-02-26 15:02:57 -08:00
T.J. Schuck
53f1ab523b Bump version of bcrypt gem 2014-02-25 09:52:32 -05:00
Carlos Antonio da Silva
71b3910a7d Point master changelogs to 4-1-stable branch
Remove 4-1 related entries from master [ci skip]
2014-02-25 09:14:36 -03:00
Yves Senn
c554d170e6 update version to 4.2.0.alpha 2014-02-23 13:14:43 +01:00
Rafael Mendonça França
1879c259b8 Merge branch '4-1-0-beta2'
Conflicts:
	actionview/CHANGELOG.md
	activerecord/CHANGELOG.md
2014-02-18 16:00:47 -03:00
Rafael Mendonça França
8b20c72dd8 Preparing for 4.1.0.beta2 release 2014-02-18 15:45:20 -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
Yves Senn
02f9f33142 tidy CHANGELOGs [ci skip] 2014-01-30 11:12: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
26fb57b58d Fix doc markup of clear_validators! 2014-01-27 08:26:54 -02:00
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
Xavier Noria
0df1f91410 revises references to :allow_(nil|blank) in some docs [ci skip] [Steven Yang & Xavier Noria]
Closes #11247.
2014-01-26 20:50:18 +01: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
8ca59237dd Got all the new tests passing 2014-01-24 19:49:30 -08:00
Godfrey Chan
20490adcbf Restored the ability to clear the password with user.password= nil (see the docs) 2014-01-24 19:49:30 -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
b97035df64 Fix ActiveModel::Errors#has_key? return value 2014-01-22 21:01:41 +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
b8302bcfda Forgot to push this change in the parent commit 2014-01-20 23:00:17 -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
Carlos Antonio da Silva
486db21f91 Fix eager load of Serializers on Active Model 2014-01-17 15:30:09 -02:00
Yves Senn
8c0d5e0d1c doc proc/lambda arg on inclusion validation. Closes #13689. [ci skip] 2014-01-13 11:25:58 +01:00
Carlos Antonio da Silva
3a33e8ea85 Use a better method name to check the requirement of password confirmation
Also improve changelog entries related to secure password to proper
highlight.
2014-01-07 07:59:44 -02:00
Carlos Antonio da Silva
a6da73f975 Fix typo in AMo docs [ci skip] 2014-01-06 08:45:21 -02:00
T.J. Schuck
72bb3fc297 Change all "can not"s to the correct "cannot". 2014-01-03 17:02:31 -05:00
Vipul A M
98cb3e69af update copyright notices to 2014. [ci skip] 2014-01-01 23:59:49 +05:30
Vijay Dev
c4fb191a4c Merge branch 'master' of github.com:lifo/docrails 2013-12-31 22:44:34 +05:30
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
Yves Senn
864514a460 Merge pull request #13483 from aditya-kapoor/add-missing-slashes
Adding missing backslashes in active_model files so as to avoid unwanted [ci skip]
2013-12-27 01:13:02 -08:00
aditya-kapoor
fe49f432c9 Adding missing backslashes in active_model files so as to avoid unwanted links in rdoc [ci skip] 2013-12-27 13:58:31 +05:30
Godfrey Chan
87323487ce Merge pull request #13442 from aditya-kapoor/update-docs
Updated documentation for Attribute Methods [ci skip]
2013-12-26 02:02:53 -08:00
aditya-kapoor
1dae89ccce Added Backslashes to ActiveModel::AttributeMethods to prevent unwanted links in the rdoc + some other doc fixes.[ci skip] 2013-12-25 18:34:11 +05:30
Robin Dupret
6e2d35df3c Fix few typos and improve markup at some levels 2013-12-24 12:39:41 +01: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
Robin Dupret
b894b7b90a Fix few typos in the documentation [ci skip] 2013-12-21 18:59:55 +01:00