Commit Graph

168 Commits

Author SHA1 Message Date
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