aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/test
Commit message (Collapse)AuthorAgeFilesLines
...
| * | Validate multiple contexts on `valid?` and `invalid?` at once.Dmitry Polushkin2015-07-301-0/+19
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Example: ```ruby class Person include ActiveModel::Validations attr_reader :name, :title validates_presence_of :name, on: :create validates_presence_of :title, on: :update end person = Person.new person.valid?([:create, :update]) # => true person.errors.messages # => {:name=>["can't be blank"], :title=>["can't be blank"]} ```
* | Removed unused config filePrakash Laxkar2015-09-032-4/+0
| |
* | Add missing test for #17351Aditya Kapoor2015-09-011-0/+14
| |
* | Removed duplicate requiring minitest/mock as it is already required in ↵Ronak Jangir2015-08-261-2/+0
| | | | | | | | method_call_assertions
* | Remove XML Serialization from core.Zachary Scott2015-08-072-252/+0
| | | | | | | | | | | | | | This includes the following classes: - ActiveModel::Serializers::Xml - ActiveRecord::Serialization::XmlSerializer
* | pass the correct argument to mock on a test of `validates_length_of`yuuji.yaginuma2015-07-281-1/+1
|/
* Removes unnecessary comments from i18n validations tests [ci skip]Zamith2015-07-111-61/+2
| | | | | | These comments do not add a lot to the readability, grepability or overall understanding of the tests, therefore I believe they can be safely removed.
* Remove the reference to mocha in activemodelZamith2015-07-111-27/+27
| | | | | Activemodel is no longer dependent on mocha, so we can make the comments more generic.
* Use private method call assertions in Active Model tests.Kasper Timm Hansen2015-07-104-59/+46
| | | | Also fix Minitest constant reference.
* Improve Validation Helpers' documentation comments and testsRadan Skoric2015-06-272-0/+31
|
* Fix typo in AM I18n validation test name [skip ci]Anton Davydov2015-06-091-1/+1
|
* Require yaml for isolation testRafael Mendonça França2015-05-291-0/+1
| | | | | It was removed when we removed mocha at 5a6ae7f7539216931f2b3f4aa53394ac4136c74e
* Remove use of mocha from Active ModelRoque Pinel2015-05-284-59/+117
|
* Stop skipping a test that now works on Rubiniusclaudiob2015-05-101-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The test was skipped because of an issue that, in the meantime, has been fixed: https://github.com/rubinius/rubinius/issues/3328. Using the latest Rubinius (the one currently on Travis CI), this is the result: ```sh $ ruby --version rubinius 2.5.3 (2.1.0 2482b093 2015-05-10 3.5.1 JI) [x86_64-darwin14.3.0] ``` **Before this PR** ```sh $ ruby -Itest test/cases/attribute_assignment_test.rb Run options: --seed 58569 .....S... Finished in 0.048278s, 186.4203 runs/s, 269.2738 assertions/s. 9 runs, 13 assertions, 0 failures, 0 errors, 1 skips You have skipped tests. Run with --verbose for details. ``` **After this PR** $ ruby -Itest test/cases/attribute_assignment_test.rb Run options: --seed 35720 ......... Finished in 0.029441s, 305.6961 runs/s, 475.5273 assertions/s. 9 runs, 14 assertions, 0 failures, 0 errors, 0 skips ```
* Adds/Corrects use case for adding an error messageZamith2015-05-041-0/+6
| | | | | I believe this is a use case that was supposed to be supported, and it's a small fix.
* ensure `method_missing` called for non-existing methods passed toJay Elaraj2015-04-281-9/+16
| | | | `ActiveModel::Serialization#serializable_hash`
* Add `ActiveModel::Dirty#[attr_name]_previously_changed?` andFernando Tapia Rico2015-04-211-0/+13
| | | | | | | | `ActiveModel::Dirty#[attr_name]_previous_change` to improve access to recorded changes after the model has been saved. It makes the dirty-attributes query methods consistent before and after saving.
* Merge pull request #19021 from morgoth/activemodel-errors-refactoringRafael Mendonça França2015-03-301-0/+6
|\ | | | | Simplify and alias ActiveModel::Errors methods where possible
| * Simplify and alias ActiveModel::Errors methods where possibleWojciech Wnętrzak2015-02-201-0/+6
| |
* | Deprecate the `:tokenizer` option to `validates_length_of`Sean Griffin2015-03-291-4/+16
| | | | | | | | | | | | | | | | As demonstrated by #19570, this option is severely limited, and satisfies an extremely specific use case. Realistically, there's not much reason for this option to exist. Its functionality can be trivially replicated with a normal Ruby method. Let's deprecate this option, in favor of the simpler solution.
* | Fix arguments order on assertionCarlos Antonio da Silva2015-03-221-1/+1
| | | | | | | | The expected value comes first. Related to #19465.
* | Fix ActiveModel::Errors#delete return value to stay backward compatibleRadan Skoric2015-03-221-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | Rails 5.0 changes to ActiveModel::Errors include addition of `details` that also accidentally changed the return value of `delete`. Since there was no test for that behavior it went unnoticed. This commit adds a test and fixes the regression. Small improvements to comments have also been made. Since `get` is getting deprecated it is better to use `[]` in other methods' code examples. Also, in the module usage example, `def Person.method` was replaced with a more commonly used `def self.method` code style.
* | Revert "Leave all our tests as order_dependent! for now"Matthew Draper2015-03-061-5/+0
| | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 2f52f969885b2834198de0045748436a4651a94e. Conflicts: actionmailer/test/abstract_unit.rb actionview/test/abstract_unit.rb activemodel/test/cases/helper.rb activerecord/test/cases/helper.rb activesupport/test/abstract_unit.rb railties/test/abstract_unit.rb
* | Merge pull request #19173 from robin850/rbx-buildRafael Mendonça França2015-03-022-0/+11
|\ \ | | | | | | Improve the Rubinius build
| * | Skip the failing tests on Rubinius for nowRobin Dupret2015-03-021-0/+2
| | |
| * | Add the platform-specific skip helpers to ActiveModelRobin Dupret2015-03-021-0/+9
| | |
* | | Follow-up to #10776Robin Dupret2015-02-262-3/+3
|/ / | | | | | | | | | | | | | | | | | | 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.
* / activemodel: make .model_name json encodableIan Ker-Seymer2015-02-241-0/+4
|/ | | | | | 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.
* Move the `validate!` method to `ActiveModel::Validations`.Lucas Mazza2015-02-201-0/+19
|
* Deprecate `ActiveModel::Errors` `add_on_empty` and `add_on_blank` methodsWojciech Wnętrzak2015-02-192-8/+22
| | | | without replacement.
* Merge pull request #18634 from morgoth/deprecate-some-errors-methodsRafael Mendonça França2015-02-181-15/+21
|\ | | | | | | Deprecate `ActiveModel::Errors` `get`, `set` and `[]=` methods.
| * Deprecate `ActiveModel::Errors` `get`, `set` and `[]=` methods.Wojciech Wnętrzak2015-02-011-15/+21
| | | | | | | | They have inconsistent behaviour currently.
* | Merge pull request #16381 from kakipo/validate-length-tokenizerRafael Mendonça França2015-02-132-0/+17
|\ \ | | | | | | | | | Allow symbol as values for `tokenizer` of `LengthValidator`
| * | Allow symbol as values for `tokenize` of `LengthValidator`kakipo2014-08-032-0/+17
| | |
* | | Removed magic comments # encoding: utf-8 , since its default from ruby 2.0 ↵Vipul A M2015-02-0316-17/+0
| |/ |/| | | | | onwards.
* | Merge pull request #18670 from morgoth/fix-duplicating-errors-detailsYves Senn2015-01-241-1/+1
|\ \ | | | | | | Fixed duplicating ActiveModel::Errors#details
| * | Fixed duplicating ActiveModel::Errors#detailsWojciech Wnętrzak2015-01-241-1/+1
| | |
* | | use attribute assignment module logic during active model initializationEugene Gilburg2015-01-231-1/+3
|/ /
* | ✂️ and 💅 for #10776Sean Griffin2015-01-231-29/+30
| | | | | | | | | | Minor style changes across the board. Changed an alias to an explicit method declaration, since the alias will not be documented otherwise.
* | Extracted `ActiveRecord::AttributeAssignment` to ↵Bogdan Gusiev2015-01-231-0/+106
| | | | | | | | | | | | `ActiveModel::AttributesAssignment` Allows to use it for any object as an includable module.
* | Add ActiveModel::Errors#detailsWojciech Wnętrzak2015-01-201-0/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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}]} ```
* | Merge pull request #18439 from mokhan/validates-acceptance-of-arraySean Griffin2015-01-121-0/+6
|\ \ | | | | | | allow '1' or true for acceptance validation.
| * | allow '1' or true for acceptance validation.mo khan2015-01-101-0/+6
| | |
* | | Merge pull request #18454 from claudiob/test-on-option-for-amv-callbacksCarlos Antonio da Silva2015-01-111-0/+26
|\ \ \ | | | | | | | | Add test for AM::Validation::Callbacks with :on
| * | | Add test for AM::Validation::Callbacks with :onclaudiob2015-01-111-0/+26
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `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.
* / / Remove unused "deprecated_reload" methodclaudiob2015-01-111-4/+0
|/ / | | | | | | | | | | The method was introduced in https://github.com/rails/rails/commit/66d0a0153578ce760d822580c5b8c0b726042ac2#diff-8cec05860729a3851ceb756f4dd90370R49 for the "reset_changes is deprecated" test, but this test was successively removed in https://github.com/rails/rails/commit/37175a24bd508e2983247ec5d011d57df836c743
* | Remove deprecated `ActiveModel::Dirty#reset_#{attribute}` and ↵Rafael Mendonça França2015-01-041-17/+0
| | | | | | | | `ActiveModel::Dirty#reset_changes`.
* | Deprecate `false` as the way to halt AM callbacksclaudiob2015-01-021-3/+13
| | | | | | | | | | | | | | | | | | | | 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)`.
* | Deprecate `false` as the way to halt AM validation callbacksclaudiob2015-01-021-3/+17
| | | | | | | | | | | | | | | | | | | | 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)`.
* | - Fixed unused variableVipul A M2014-12-211-3/+2
| | | | | | | | - Changed test to verify complete message instead of verifying if message contains text.