Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

* added extra step to the installation instructions

* fixed nasty bug regarding invoking validation on new records
  • Loading branch information...
commit e60aeb31a779753b42329ba61d369608fafb001d 1 parent 7325ce6
Christopher J. Bottaro authored
Showing with 10 additions and 1 deletion.
  1. +1 −0  README.rdoc
  2. +1 −0  lib/has_easy.rb
  3. +8 −1 test/has_easy_test.rb
1  README.rdoc
View
@@ -6,6 +6,7 @@ What's the difference between flags, preferences and options? Nothing really, t
git clone git://github.com/cjbottaro/has_easy.git vendor/plugins/has_easy
script/generate has_easy_migration create_has_easy_things
rake db:migrate
+ rake db:test:prepare
cd vendor/plugins/has_easy
rake test
1  lib/has_easy.rb
View
@@ -68,6 +68,7 @@ def set_has_easy_thing(context, name, value, do_preprocess = false)
thing = HasEasyThing.new :context => context,
:name => name,
:value => value
+ thing.set_model_target(self) # for the bug regarding thing's validation trying to invoke the 'model' assocation when self is a new record
send("#{context}").send("<<", thing)
else
thing.value = value
9 test/has_easy_test.rb
View
@@ -178,7 +178,14 @@ def test_validate_3
def test_validate_4
@user.preferences.validate_test_4 = "blah"
assert_raise(ActiveRecord::RecordInvalid){ @user.preferences.save! }
- @user.preferences.save
+ assert !@user.preferences.save
+ assert 2, @user.errors.on(:preferences).length
+ assert '1one', @user.errors.on(:preferences)[0]
+ assert '2two', @user.errors.on(:preferences)[1]
+
+ # nasty bug when the parent is a new record
+ user = @user.class.new :preferences_validate_test_4 => "blah"
+ assert !user.save
assert 2, @user.errors.on(:preferences).length
assert '1one', @user.errors.on(:preferences)[0]
assert '2two', @user.errors.on(:preferences)[1]
Please sign in to comment.
Something went wrong with that request. Please try again.