Commit Graph

1620 Commits

Author SHA1 Message Date
Carlos Antonio da Silva
a3f030686b Fix arguments order on assertion
The expected value comes first. Related to #19465.
2015-03-22 20:25:27 -03:00
Radan Skoric
26b35a4096 Fix ActiveModel::Errors#delete return value to stay backward compatible
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.
2015-03-22 23:18:22 +01:00
Radan Skoric
cf7fac7e29 Fix ActiveModel::Errors deprecation messages failing when used on its own
Deprecation messages in ActiveModel::Errors are using String#squish
from ActiveSupport but were not explicitly requiring it, causing failures
when used outside rails.
2015-03-21 12:35:25 +01:00
Peter Suschlik
f0768eba28 Target Ruby 2.2.1 in gemspecs
This is a follow-up to #19257
2015-03-09 09:56:26 +01:00
Matthew Draper
e462021396 Revert "For now, we will keep sorting the tests."
This reverts commit 7025d7769dc53f0a3ffab8b537727ef3fee367fc.
2015-03-06 04:39:20 +10:30
Matthew Draper
b5eb0b6cc3 Revert "Leave all our tests as order_dependent! for now"
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
2015-03-06 04:38:54 +10:30
Melanie Gilman
9034938714 Fix spelling error in has_secure_password documentation [ci skip] 2015-03-03 20:05:02 -05:00
Rafael Mendonça França
ed6be59624 Merge pull request #19173 from robin850/rbx-build
Improve the Rubinius build
2015-03-02 13:48:45 -03:00
Robin Dupret
562b0b2368 Skip the failing tests on Rubinius for now 2015-03-02 17:28:12 +01:00
Sean Griffin
c0584ea034 Merge pull request #19077 from robin850/unknown-attribute-error
Move `UnknownAttributeError` to a more sane namespace
2015-03-02 09:21:42 -07:00
Robin Dupret
823e4e9115 Add the platform-specific skip helpers to ActiveModel 2015-03-02 14:05:07 +01:00
Vipul A M
cdaab2c479 Removed non-standard and unused require 'active_support/deprecation' from parts out of active_support. 2015-02-27 23:20:09 +05:30
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
Yves Senn
e71f5dad4e some indenting and punctuation fixes. [ci skip] 2015-02-23 16:54:40 +01:00
Rafael Mendonça França
f55bfe7260 Change the deprecation messages to show the preferred way to work with
ActiveModel::Errors
2015-02-20 20:58:58 -02:00
Lucas Mazza
830b7041f2 Move the validate! method to ActiveModel::Validations. 2015-02-20 16:05:26 -02:00
Rafael Mendonça França
e0f29c51b9 Merge pull request #17144 from skojin/patch-doc-validation-format-z-regexp
fix mistype in doc about \z regexp
2015-02-20 14:30:47 -02:00
yuuji.yaginuma
66e2e19bc0 use messages instead of deprecated ActiveModel::Errors#[]= method [ci skip] 2015-02-20 23:53:36 +09:00
Yves Senn
259d33db8c Merge pull request #18996 from morgoth/deprecate-more-errors-methods
Deprecate `ActiveModel::Errors` `add_on_empty` and `add_on_blank` methods
2015-02-19 14:16:47 +01: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
Robin Dupret
1747c4e2ce Tiny documentation edits [ci skip] 2015-02-15 19:19:04 +01:00
Vijay Dev
95546d4935 Merge branch 'master' of github.com:rails/docrails 2015-02-14 15:35:47 +00: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
Rafael Mendonça França
16809025fe Merge pull request #18388 from claudiob/better-docs-for-active-model-lint-tests
Better docs for AM::Lint::Tests
2015-02-06 11:06:59 -02:00
Xavier Noria
6f8d9bd6da revises AM:Dirty example [Godfrey Chan & Xavier Noria]
The existing example seems somewhat forced: is it realistic
to have a model that accepts state in its initializer but
considers it has not been changed? By allowing state changes
to happen only via accessors it seems more natural that new
instances are considered to be unchanged (as they are in AR).

[ci skip]
2015-02-06 10:29:05 +01:00
Xavier Noria
a2af7bb928 use parentheses here, for the beard of the Prophet! [ci skip] 2015-02-06 09:45:24 +01:00
Xavier Noria
4af4cead15 applies guidelines to dirty.rb [ci skip] 2015-02-06 09:36:28 +01:00
Jeremy Kemper
e30cb83c7a Merge pull request #18795 from vipulnsward/remove-magic-comments
Removed magic comments (`# encoding: utf-8`) from tests since it's default from ruby 2 onwards
2015-02-03 09:38:15 -07: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
Carlos Antonio da Silva
f44b437627 Wrap method arguments with parentheses in docs
As per Rails general coding conventions. Related to #18794 [ci skip]
2015-02-03 07:35:11 -02:00
Vipul A M
fc87123fe8 Person class doesn't contain finder methods, hence usage of Person.find_by is wrong.
Added simple initialize and made use of Person.new instead of Person.find_by to clarify the docs.
[ci skip]
2015-02-03 12:09:42 +05:30
eileencodes
27aa4dda7d Fix validations on child record when record parent has validate: false
Fixes #17621. This 5 year old (or older) issue causes validations to fire
when a parent record has `validate: false` option and a child record is
saved. It's not the responsibility of the model to validate an
associated object unless the object was created or modified by the
parent.

Clean up tests related to validations

`assert_nothing_raised` is not benefiting us in these tests
Corrected spelling of "respects"
It's better to use `assert_not_operator` over `assert !r.valid`
2015-02-01 16:03:49 -08:00
Carlos Antonio da Silva
fdeef19833 Move required error message and changelog to Active Record
The new association error belongs to Active Record, not Active Model.
See #18700 for reference.
2015-02-01 10:31:54 -02:00
Wojciech Wnętrzak
6ec8ba16d8 Deprecate ActiveModel::Errors get, set and []= methods.
They have inconsistent behaviour currently.
2015-02-01 13:14:00 +01:00
Vipul A M
0f67f00d94 AM#Dirty doc fixes
- Grammar fixes
- Add doc for changes_include?
-  implemntations => implementations
2015-02-01 13:43:35 +05:30
Aaron Patterson
6b4a5952d3 Merge pull request #18700 from nygrenh/better-required-message
Provide a better error message on :required association
2015-01-31 14:10:23 -08:00
Yves Senn
afe402dac7 unify CHANGELOG format. [ci skip] 2015-01-31 11:54:00 +01:00
Vipul A M
db41078566 Fix description for AM::Callbacks 2015-01-31 11:59:02 +05:30
Henrik Nygren
9a6c6c6f09 Provide a better error message on :required association
Fixes #18696.
2015-01-28 11:32:10 +02: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
Rafael Mendonça França
14599a5758 Merge pull request #18322 from morgoth/add-error-codes
Add ActiveModel::Errors#codes
2015-01-21 14:28:54 -02:00
Wojciech Wnętrzak
2ee6ed69fc Add missing AS core extension dependency 2015-01-21 08:04:40 +01: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
ea721d7027 Don't calculate in-place changes on attribute assignment
When an attribute is assigned, we determine if it was already marked as
changed so we can determine if we need to clear the changes, or mark it
as changed. Since this only affects the `attributes_changed_by_setter`
hash, in-place changes are irrelevant to this process. Since calculating
in-place changes can be expensive, we can just skip it here.

I also added a test for the only edge case I could think of that would
be affected by this change.
2015-01-18 13:43:31 -07:00