José Valim
51bef9d8fb
to_xml should also rely on serializable hash.
2011-09-18 09:09:01 -07:00
Jon Leighton
778c82bea6
Generate attribute method unless it's already in the module.
...
There's no harm in generating a method name that's already defined on
the host class, since we're generating the attribute methods in a module
that gets included. In fact, this is desirable as it allows the host
class to call super.
2011-09-14 00:00:37 +01:00
Jon Leighton
c89e1c7bde
Add an attribute_missing method to ActiveModel::AttributeMethods.
...
This can be overloaded by implementors if necessary.
2011-09-13 00:02:33 +01:00
Jon Leighton
ac687ed651
Let Ruby deal with method visibility.
...
Check respond_to_without_attributes? in method_missing. If there is any
method that responds (even private), let super handle it and raise
NoMethodError if necessary.
2011-09-13 00:01:58 +01:00
Jon Leighton
99bd6b53da
Add deprecation for doing attribute_method_suffix ''
2011-09-13 00:01:57 +01:00
Jon Leighton
8b8b7143ef
Use an empty AttributeMethodMatcher by default.
...
This means that attribute methods which don't exist will get generated
when define_attribute_methods is called, so we don't have to use hacks
like `attribute_method_suffix ''`.
2011-09-13 00:01:57 +01:00
Lawrence Pit
8817796167
Added test for obj.errors.as_json
2011-09-09 18:34:13 +10:00
Lawrence Pit
f5a944f662
Add ability to get an individual full error message + test for full_messages.
2011-09-09 18:28:25 +10:00
Damien Mathieu
e0335e2ccb
add has_key? to ActiveModel::Errors
2011-09-06 18:36:18 +02:00
José Valim
d15069316f
Merge pull request #2563 from bogdan/internal_validation
...
Implemented strict validation concept
2011-08-25 07:10:16 -07:00
Anand
56e32ad40f
added more tests for only-include and except-include options in serialization
2011-08-23 16:03:58 +05:30
Bogdan Gusiev
8620bf90c5
Implemented strict validation concept
...
In order to deliver debug information to dev team
instead of display error message to end user
Implemented strict validation concept
that suppose to define validation that always raise exception when fails
2011-08-17 17:26:00 +03:00
Myron Marston
d3c15a1d31
Allow ActiveRecord observers to be disabled.
...
We have to use Observer#update rather than Observer#send since the enabled state is checked in #update before forwarding the method call on.
2011-08-12 20:48:44 -07:00
José Valim
6b3af028ac
Merge pull request #2385 from bogdan/test_default_sanitizer2
...
MassAssignmentProtection: consider 'id' insensetive in StrictSanitizer
2011-08-01 04:50:06 -07:00
José Valim
dc8773b19f
Rename new method to_path to to_partial_path to avoid conflicts with File#to_path and similar.
2011-08-01 11:42:00 +02:00
Franck Verrot
325fdfc928
Remove warnings by calling remove_method
2011-07-31 20:05:58 +02:00
Bogdan Gusiev
b93a918337
MassAssignmentProtection: consider 'id' insensetive in StrictSanitizer
...
In order to use StrictSanitizer in test mode
Consider :id as not sensetive attribute that can be filtered from
mass assignement without exception.
2011-07-28 11:56:08 +03:00
José Valim
1b7db58a06
Merge pull request #2034 from Casecommons/to_path
...
Allow ActiveModel-compatible instances to define their own partial paths
2011-07-28 00:50:07 -07:00
thedarkone
efe4cbe5f2
Handle the empty array correctly.
2011-07-27 18:07:47 +02:00
Grant Hutchins & Peter Jaros
bf812074fd
Let ActiveModel instances define partial paths.
...
Deprecate ActiveModel::Name#partial_path. Now you
should call #to_path directly on ActiveModel
instances.
2011-07-25 16:05:24 -04:00
John Firebaugh
4860143ee4
ActiveModel support for the :include serialization option
...
This commit moves support for the :include serialization option for
serializing associated objects out of ActiveRecord in into ActiveModel.
The following methods support the :include option:
* serializable_hash
* to_json
* to_xml
Instances must respond to methods named by the values of the :includes
array (or keys of the :includes hash). If an association method returns
an object that is_a?(Enumerable) (which AR has_many associations do), it
is assumed to be a collection association, and its elements must respond
to :serializable_hash. Otherwise it must respond to :serializable_hash
itself.
While here, fix #858 , XmlSerializer should not singularize already
singular association names.
2011-07-17 11:34:07 -07:00
John Firebaugh
2a9a10f5e3
Add a test
2011-07-17 11:34:06 -07:00
John Firebaugh
da4e1faf6f
serializable_hash(:only => [], :methods => [:foo]) should work
2011-07-17 11:34:06 -07:00
Joe Fiorini
ac5e691153
Enable passing root: false to #to_json
2011-07-01 23:00:13 -04:00
Ian Stewart
eafa174bfd
changing an attribute multiple times retains the correct original value
2011-06-28 22:18:24 -07:00
Alexander Uvarov
528f405cdc
Allow to specify mass-assignment roles as array
2011-06-23 12:56:39 +06:00
Santiago Pastorino
5599e3fa0c
Merge pull request #1654 from ganeshkumar/test_cases
...
removed duplicate code in tests
2011-06-13 05:45:47 -07:00
ganesh
7c3094626d
removed duplicate code
2011-06-11 21:49:12 +05:30
José Valim
410a42860b
Get rid of the alternate namespace lookup.
2011-06-11 18:01:26 +02:00
thoefer
0831b7e076
Brought back alternative convention for namespaced models in i18n.
2011-06-08 13:40:17 +02:00
José Valim
139a9f7011
Transform the symbol into a constant lookup.
2011-05-31 12:24:30 +02:00
Bogdan Gusiev
aa2639e746
ActiveModel::MassAssignmentSecurity.mass_assignment_sanitizer method
...
In order to specify your own sanitize method
Implemented .mass_assignment_sanitizer configuration option
2011-05-30 11:34:00 +03:00
Bogdan Gusiev
c7567c9a6d
MassAssignmentSecurity: add ability to specify your own sanitizer
...
Added an ability to specify your own behavior on mass assingment
protection, controlled by option:
ActiveModel::MassAssignmentSecurity.mass_assignment_sanitizer
2011-05-26 15:58:43 +03:00
Arun Agrawal
1ffc3063b7
No more need rubygems here.
2011-05-22 02:02:56 +05:30
Yves Senn
e5429b789d
Specify the name to be used for ActiveModel::Name fixes #1168
...
This patch allows to specify the name of your models independent of the class name.
2011-05-20 16:59:09 +02:00
Jim Herzberg
fbf99653f1
Attributes with :string type should not be given the type passed in model serialization options. Closes #1058
2011-05-18 15:52:55 -04:00
Sebastian Martinez
21b61a8ac4
Follow code conventions on some tests
2011-05-10 20:58:36 -03:00
Joshua Wehner
2cef2d411a
Methods that return nil should not be considered YAML
2011-05-10 12:06:09 -04:00
Josh Kalderimis
b2451f4a7f
renamed mass-assignment scopes to roles, updated code, tests, docs and security guide
2011-05-08 16:43:29 +02:00
Aditya Sanghi
bf5cf5db86
:if should not fire on validations when not in context with :on
2011-04-29 02:54:37 +05:30
Myron Marston
7db7aa5053
Add additional tests for AM::ObserverArray that I had missed yesterday.
2011-04-28 08:32:22 -07:00
Myron Marston
fef22157b0
Fix bug with AM::Observer disablement.
...
Now that we propagate the enabling/disabling to descendants, we no longer have to check the disabled_observer Set on each superclass of the model class. This was causing a bug when disabling all observers at a superclass level and then enabling an individual observer at a subclass level.
Plus the logic is simpler now :).
2011-04-28 08:27:15 -07:00
Myron Marston
05d4653cef
Revert "Revert "Handle enabling/disabling observers at different levels of the class hierarchy.""
...
This reverts commit 2a25c5818b03d7d6cd63aad180bff23479dbd861.
I'm going to add another commit that keeps the same behavior of fixes
the problems of leaking memory in development.
2011-04-28 07:58:58 -07:00
José Valim
2a25c5818b
Revert "Handle enabling/disabling observers at different levels of the class hierarchy."
...
This reverts commit ad62f1928768bd2676958a4a08512bad342fe469 because the current
subclasses implementation leaks memory in development.
Instead of keeping an array of subclasses, the better solution is to
ask the parent if an observer is being disabled or not.
2011-04-28 09:32:57 +02:00
Myron Marston
ad62f19287
Handle enabling/disabling observers at different levels of the class hierarchy.
...
Last call wins.
2011-04-28 10:25:07 +08:00
Myron Marston
1f8cc446d9
Allow observers to be enabled and disabled.
...
This is useful in situations like model unit tests and the occasional rake task to backfill old data.
2011-04-28 10:23:49 +08:00
Josh Kalderimis
1054ebd613
AM mass assignment security attr_accessible and attr_protected now allow for scopes using :as => scope eg.
...
attr_accessible :name
attr_accessible :name, :admin, :as => :admin
2011-04-24 09:53:18 +02:00
Aaron Patterson
3e23752236
bcrypt will encrypt anything, so validate_presence_of would not catch nil / blank passwords. Thank you to Aleksander Kamil Modzelewski for reporting this
2011-04-14 14:54:25 -07:00
José Valim
df5691aa94
No need to rescue here. Invoking the wrong method in an object can happen anywhere if you are not careful. In other words, test your shit.
2011-04-11 17:47:59 +02:00
José Valim
5bf3d46bec
Revert "Add :use_include option to allow user to explicitly use Range#include?
method in Ruby 1.9"
...
Use :with => range.to_a instead.
This reverts commit f6540211b5b9133c9f93c11655a04d613c237e67.
2011-04-11 17:41:33 +02:00
Prem Sichanugrist
a9f3c9da01
Using Object#in? and Object#either? in various places
...
There're a lot of places in Rails source code which make a lot of sense to switching to Object#in? or Object#either? instead of using [].include?.
2011-04-11 03:17:09 +08:00
Prem Sichanugrist
f6540211b5
Add :use_include option to allow user to explicitly use Range#include?
method in Ruby 1.9
...
In Ruby 1.9 we're currently use `Range#cover?` to fix the performance problem. However, there might be the case that you want to use `Range#include?` instead. This patch will give you that option.
2011-04-10 18:49:28 +08:00
Prem Sichanugrist
58594be680
Add support for proc or lambda as an option for InclusionValidator, ExclusionValidator, and FormatValidator
...
You can now use a proc or lambda in :in option for InclusionValidator and ExclusionValidator, and :with, :without option for FormatValidator
2011-04-10 18:49:28 +08:00
John Firebaugh
d907f3cb5c
Rename test directory to match code directory
...
Hopefully "serializeration" is not an in joke that I missed.
2011-04-06 01:50:35 +08:00
Santiago Pastorino
da6c7bd4b4
Do not in place modify what table_name returns
2011-03-22 19:36:16 -03:00
Santiago Pastorino
445241d713
define_attr_method should be able to define methods that returns nil
2011-03-17 23:17:20 -03:00
Aaron Patterson
00f0879367
dup strings on return so that in place modifications do not break anything. I am looking at you "compute_table_name"
2011-03-17 10:26:11 -07:00
Santiago Pastorino
c834a751d2
define_attr_method correctly defines methods with invalid identifiers
2011-03-16 21:20:44 -03:00
Santiago Pastorino
fda45f4fc4
Add a define_attr_method test
2011-03-16 21:08:02 -03:00
Santiago Pastorino
5232077517
Add test for define_attr_method using as name an invalid identifier
2011-03-16 21:01:49 -03:00
Santiago Pastorino
cb44e99de4
Add test for define_attribute_method using as name an invalid identifier
2011-03-16 21:01:04 -03:00
Santiago Pastorino
157c37f558
Refactor length validation
2011-03-12 21:12:44 -02:00
Andriy Tyurnikov
f48d3d4df6
length validation for fixnums
...
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2011-03-12 21:12:44 -02:00
R.T. Lechow
86c15d8b89
Active Model typos.
2011-03-05 11:56:34 +01:00
Alexander Uvarov
24faddd60c
Move ActiveModel::AttributeMethods#attribute_methods_generated? to ActiveRecord, so it's flexible now
...
[#6428 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2011-03-01 20:22:45 +01:00
Santiago Pastorino
a00bed0c48
Revert "Properly interpolate i18n keys in modules [ #5572 state:resolved]"
...
This breaks #6448 , you should use :"module/class" as key for namespacing
[#6448 state:committed]
This reverts commit 8d30193b08bd2321a7a78a1f481bd5e4d4d45557.
2011-02-27 21:30:03 -02:00
Santiago Pastorino
acf0688fdd
failing test for i18n key collision with namespaced models
2011-02-27 21:23:52 -02:00
Frederick Cheung
fbfa30a1ee
Change validates inclusion to use cover? for Ranges in ruby 1.9 [ #6453 state:committed]
...
Signed-off-by: Xavier Noria <fxn@hashref.com>
2011-02-18 21:32:28 +01:00
Tsutomu Kuroda
ad31549ab3
Override attributes_protected_by_default when has_secure_password is called.
...
attr_protected should not be called, because it nullifies the
mass assignment protection that has been set by attr_accessible.
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2011-02-09 18:35:15 -02:00
Aaron Patterson
f48d32c0cf
implementing include? on AM::Errors
2011-02-09 09:19:56 -08:00
Carl Lerche
cf9324e590
Find all validators for multiple attributes
2011-02-05 20:27:02 -08:00
Carl Lerche
cd13fbd8d8
Optionally pass in the attribute being validated to an instance method validator
2011-02-05 16:44:35 -08:00
Carl Lerche
e9e9ed6b60
Be able to pass a validator method to #validates
2011-02-05 16:33:00 -08:00
Carl Lerche
ed7614aa7d
Provide a way to specify alternate option keys for validates
2011-02-05 16:00:57 -08:00
Carl Lerche
7176ade35b
Do not require that validation attributes be specified as symbols
2011-02-05 15:37:38 -08:00
Caleb Land
bca070ef2d
allow spaces and other characters in attribute names [ #4725 state:resolved]
...
* define the dynamically defined methods with
'define_method' instead of def
* wrap some string injected method names in quotes
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2011-02-03 19:05:17 -02:00
John Firebaugh
57bc25c5f8
Use run_callbacks; the generated _run_<name>_callbacks method is not a public interface.
...
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2011-01-31 19:45:53 -02:00
Aaron Patterson
b5cc277763
psych does not emit a space after the tag
2011-01-21 15:13:30 -08:00
Hemant Kumar
8de5595e4d
fix difference between behaviour of blank and empty
...
Signed-off-by: José Valim <jose.valim@gmail.com>
2011-01-05 13:18:10 +01:00
Santiago Pastorino
5fb42ac478
Tests and docs which explain the use of validate with a block and without arguments
2010-12-19 18:50:18 -02:00
Santiago Pastorino
08ccd29b5b
Remove weak_passwords list and the length/strong password validator, leave that up to the programmer
2010-12-19 15:01:29 -02:00
Mikel Lindsaar
6c217f98db
Add set_weak_passwords call in alignment with set_table_name.
2010-12-19 21:36:47 +11:00
Mikel Lindsaar
a39a333769
Added ability to specify which passwords you want as weak passwords
2010-12-19 20:39:54 +11:00
José Valim
432556b923
Make password messages translatable.
2010-12-19 09:34:31 +01:00
José Valim
d592fa946d
Avoid warnings and fix small typo on SecurePassword.
2010-12-19 09:28:15 +01:00
David Heinemeier Hansson
bd9dc4ff23
BCrypt does its own salting, lovely!
2010-12-18 19:09:07 -08:00
David Heinemeier Hansson
bcf4e4f2b0
Added ActiveRecord::Base#has_secure_password (via ActiveModel::SecurePassword) to encapsulate dead-simple password usage with SHA2 encryption and salting
2010-12-18 13:38:05 -08:00
Samuel Kadolph
972011a2e5
Add support for namespaced validators
...
Includes test and documentation for new feature
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-12-16 01:49:28 +05:30
Santiago Pastorino
7c920631ec
Test using default option as symbol added for human_attribute_name
2010-12-05 13:26:14 -02:00
Santiago Pastorino
33b0a30fcc
default could be a symbol here so attribute.to_s.humanize should be the final option
2010-12-05 12:57:45 -02:00
Santiago Pastorino
0dbf4ac709
Test falling back to default added for human_attribute_name
2010-12-05 12:36:53 -02:00
Santiago Pastorino
b870d67290
Test using default option added for human_attribute_name
2010-12-05 12:36:51 -02:00
Thilo Utke
7148b933c4
ActiveModel::Errors.to_hash returns plain OrderedHash and used in to_json serialization to properly handle multiple errors per attribute [ #5615 state:resolved]
...
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-12-01 11:43:37 +01:00
José Valim
1ec126dd37
Revert "Fix generation of wrong json string when field has multiple errors"
...
This reverts commit a9b666b51d28b2e74da630c31327dee7cbe96d37.
2010-12-01 11:42:30 +01:00
Krekoten' Marjan
a9b666b51d
Fix generation of wrong json string when field has multiple errors
2010-12-01 00:03:42 +08:00
Aaron Patterson
938243feb9
do not require ruby-debug automatically. please require it if you have declared it as a dependency
2010-11-19 16:26:09 -08:00
Jeremy Holland
ea0faa2055
Allowing to_xml :camelize option to be set to :lower to enable lower-camelcase tags [ #5903 state:resolved]
2010-11-03 10:43:45 -07:00
Ernie Miller
21cb1d40b9
Test to_model being called in ActiveModel::Naming helpers
...
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-10-04 21:26:42 +02:00
Neeraj Singh
72c1e19c33
after_create in ActiveModel should in the order specified
...
[#5650 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-09-27 23:11:31 +02:00
John Firebaugh
75a960ca6e
Don't act destructively on ActiveModel::Name#human options hash. [ #5366 state:resolved]
...
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-09-25 10:59:54 +02:00
Rodrigo Rosenfeld Rosas
8d30193b08
Properly interpolate i18n keys in modules [ #5572 state:resolved]
2010-09-24 20:41:12 +02:00
Obie Fernandez
275f922a23
Better shortcut options for custom validators [ #5672 state:resolved]
...
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-09-24 12:49:16 +02:00
Jakub Suder
2524cf404c
fixed some issues with JSON encoding
...
- as_json in ActiveModel should return a hash
and handle :only/:except/:methods options
- Array and Hash should call as_json on their elements
- json methods should not modify options argument
[#5374 state:committed]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2010-09-07 11:33:10 -07:00
Piotr Sarnacki
6e5aed057f
Prepared ActiveModel::Naming to handle cases for namespaced isolated engines
2010-09-03 22:59:15 +02:00
Neeraj Singh
8402488568
adding new test for ActiveModel::Serialization
...
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-08-31 17:45:03 +02:00
José Valim
f0ee4a6002
Remove deprecations in ActiveModel.
2010-08-29 20:45:34 -03:00
Neeraj Singh
2ffa50f5a9
after_validation should be called irrespective of the result of validation.
...
I confirmed that this is the behavior on 2.3.x .
[5419 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-08-20 11:24:43 -03:00
Xavier Noria
fb6b805620
code gardening: we have assert_(nil|blank|present), more concise, with better default failure messages - let's use them
2010-08-17 03:32:11 +02:00
Subba Rao Pasupuleti
b7fdc937fa
Adding missing required statement
...
[#5056 state:resolved]
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-08-14 06:27:15 -03:00
Santiago Pastorino
b451de0d6d
Deletes trailing whitespaces (over text files only find * -type f -exec sed 's/[ \t]*$//' -i {} \;)
2010-08-14 04:12:33 -03:00
Subba Rao Pasupuleti
ef0da581e9
no callbacks should be created for empty array [ #5289 state:resolved]
...
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-08-12 13:12:26 -03:00
Greg Campbell
90a7915ab2
Add missing ActiveModel::Validations require
...
[#5311 state: resolved]
ActiveModel::Validations uses Hash#except, but does not require it from
ActiveSupport. (This wasn't showing up in the tests, because it was
required in the helper, and was also required in
ActiveModel::Serialization).
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-08-12 13:11:48 -03:00
rohit
621246f997
Failing test for validates_length_of, when both too_short and too_long messages are set [ #5283 state:open]
...
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-08-03 15:11:51 +02:00
Tore Darell
2c8a4a53a8
Remove or fix non-working examples and add a few tests to Dirty [ #5185 state:resolved]
...
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-08-03 10:47:30 +02:00
Neeraj Singh
fb2b8fec24
adding test cases for ActiveModel::Errors
...
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-08-03 10:46:16 +02:00
Alex Le
aeaab06c79
ActiveModel::Errors json serialization to work as Rails 3b4 [ #5254 state:resolved]
...
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-08-02 16:26:32 +02:00
José Valim
53310614d7
Reuse already existing classes for ActiveModel tests.
2010-07-21 13:00:56 +02:00
Piotr Sarnacki
6807b08099
Moved a few methods from RecordIdentifier to ActiveModel::Naming
...
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-07-21 11:29:58 +02:00
Santiago Pastorino
16c14f7465
Avoid interpreted as grouped expression warnings
2010-07-11 02:55:38 -03:00
Josh Kalderimis
4b66aab00f
mass_assignment_security moved from AR to AMo, and minor test cleanup
...
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-07-08 18:28:45 +02:00
Jeremy Kemper
d15256af6c
Missing BigDecimal dependency
2010-06-27 16:28:04 -07:00
José Valim
7bd85a8fc2
Work around the fact the JSON gem was overwriting to_json implementation for all Ruby core classes.
...
This is required because the JSON gem is incompatible with Rails behavior and was not allowing ActiveModel::Errors to be serialized.
So we need to ensure Rails implementation is the one triggered. [#4890 state:resolved]
2010-06-26 12:01:13 +02:00
Josh Kalderimis
e8c064bbe0
Regression with how base errors messages are added to a model. Works correctly for both string error messages and symbol translated messages.
...
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-06-23 14:45:55 +02:00
Neeraj Singh
c0fc084e93
should be able to run ActiveModel validations_test [ #4933 state:resolved]
...
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-06-22 21:38:27 +02:00
Santiago Pastorino
6ea967729f
Avoid method redefined warning
...
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-06-22 15:09:01 +02:00
Jeroen van Dijk
26392c4ac5
Make ActiveModel::Errors#add_on_blank and #add_on_empty accept an options hash and make various Validators pass their (filtered) options.
...
This makes it possible to pass additional options through Validators to message generation. E.g. plugin authors want to add validates_presence_of :foo, :format => "some format".
Also, cleanup the :default vs :message options confusion in ActiveModel validation message generation.
Also, deprecate ActiveModel::Errors#add_on_blank(attributes, custom_message) in favor of ActiveModel::Errors#add_on_blank(attributes, options).
Also, refactoring of ActiveModel and ActiveRecord Validation tests. Test are a lot more DRY now. Better test coverage as well now.
The first four points were reapplied from an older patch of Sven Fuchs which didn't apply cleanly anymore and was not complete yet.
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-06-21 11:55:21 +02:00
José Valim
0247995d05
ActiveModel::Validations::Callbacks should not be required by default.
2010-06-19 18:20:02 +02:00
Neeraj Singh
51739d3228
moving before_validation and after_validation functionality from ActiveRecord to ActiveModel
...
[#4653 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-06-19 17:59:52 +02:00
José Valim
a04060fb6f
Really make include_root_in_json default to true [ #3770 state:resolved]
2010-06-08 01:02:45 +02:00
Anil Wadghule
bdb2871df7
Fix xml serialization test [ #4650 state:resolved]
...
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-05-19 13:02:13 +02:00
Neeraj Singh
b462952886
Use better assertion methods for testing
...
[#4645 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-05-19 10:18:36 +02:00
rohit
05e3fb45ee
Add a valid hex that shouldn't be valid to ActiveModel numericality tests [ #4622 state:commited]
...
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-05-18 03:10:55 +02:00
Jeremy Kemper
5371242384
Valid hex strings aren't valid float column values, to match the integer restriction. [ #4622 state:resolved]
2010-05-17 07:58:26 -07:00
Santiago Pastorino
fdfebb7782
Make use of assert_equal to test equallity between object assert expects and object and a message of error
...
[#4611 state:committed]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-05-16 16:06:28 +02:00
José Valim
d6cbb27e7b
Revert "Make ActiveModel::Errors#add_on_blank and #add_on_empty accept an options hash and make various Validators pass their (filtered) options."
...
Having a huge array to whitelist options is not the proper way to handle this case. This means that the ActiveModel::Errors object should know about the options given in *all* validators and break the extensibility added by the validators itself. If the intent is to whitelist options before sending them to I18n, each validator should clean its respective options instead of throwing the responsibility to the Errors object.
This reverts commit bc1c8d58ec45593acba614d1d0fecb49adef08ff.
2010-05-15 21:55:16 +02:00
Jeroen van Dijk
bc1c8d58ec
Make ActiveModel::Errors#add_on_blank and #add_on_empty accept an options hash and make various Validators pass their (filtered) options.
...
This makes it possible to pass additional options through Validators to message
generation. E.g. plugin authors want to add validates_presence_of :foo, :format
=> "some format".
Also, cleanup the :default vs :message options confusion in ActiveModel
validation message generation.
Also, deprecate ActiveModel::Errors#add_on_blank(attributes, custom_message) in
favor of ActiveModel::Errors#add_on_blank(attributes, options).
Original patch by Sven Fuchs, some minor changes and has been changed to be applicable to master again
[#4057 state:committed]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2010-05-15 11:17:58 -07:00
Josh Kalderimis
9131a88bb8
validation macros can now be used within an instance
2010-05-13 13:57:37 -07:00
Santiago Pastorino
6334006b81
Revert "Refactor of active_model/naming.rb and allow collection and element to be writable"
...
This reverts commit f7862b2c34b5b298bf7b937c55f0637ebfe43a25.
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-05-12 21:02:16 +02:00
Santiago Pastorino
bea3c26833
Make ActiveResource serialize XML correctly when element_name is set.
...
[#4529 ]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2010-05-12 09:31:36 -07:00
Santiago Pastorino
f7862b2c34
Refactor of active_model/naming.rb and allow collection and element to be writable
...
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2010-05-12 09:31:30 -07:00
Josh Kalderimis
605c6455ac
removed AR from all AMo tests, including any unneeded files (schema, fixtures and test helper)
2010-05-09 00:08:11 +03:00
Josh Kalderimis
88ad3ed8b5
removed an old unused model in the AMo tests which also removes another AR dependency
2010-05-09 00:08:11 +03:00
Josh Kalderimis
66913a76af
removed use of AR in AMo tests and removed testing of scopes (:on) in individual validation tests and moved them to their own test file
2010-05-08 23:51:36 +03:00
Jatinder Singh
bce2c0ce37
Active Model JSON serializer now supports custom root option
...
[#4515 state:committed]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2010-05-04 13:17:26 -07:00
Lawrence Pit
9bd91b00b8
Favor %{} in all code instead of (deprecated) {{}} as interpolation syntax for I18n
...
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-05-03 13:37:32 +02:00
Neeraj Singh
883f27aa9a
test cases for record.to_xml [ #458 state:resolved]
...
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-04-30 13:19:30 +02:00
Neeraj Singh
580dd3b052
array.to_xml should be able to handle all types of data elements [ #4490 state:resolved]
...
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-04-29 09:04:34 +02:00
reu
77c099c231
Fix validates_numericaly_of only integer error message [ #4406 state:resolved]
...
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-04-25 10:14:15 +02:00
Jeremy Kemper
1924cff934
Fix Active Model observer tests
2010-04-16 13:14:52 -07:00
Ryan Bigg
d748cc3cd0
Re-define empty? for errors to check if the values inside the OrderedHash are empty rather than the OrderedHash itself. [ #4356 state:resolved]
...
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-04-10 13:21:20 +02:00