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