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
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 4e9f53f9736544f070e75e516c71137b7eb49a7a, reversing
changes made to 6b802cdb4f5b84e1bf49aaeb0e994b3be6028af9.
Revert "Don't use tap in this case."
This reverts commit 454d820bf0a18fe1db4c55b0145197d70fef1f82.
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