diff options
Diffstat (limited to 'activerecord/test/conditions_scoping_test.rb')
-rw-r--r-- | activerecord/test/conditions_scoping_test.rb | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/activerecord/test/conditions_scoping_test.rb b/activerecord/test/conditions_scoping_test.rb index a997ee9e85..cf8b670c26 100644 --- a/activerecord/test/conditions_scoping_test.rb +++ b/activerecord/test/conditions_scoping_test.rb @@ -5,7 +5,7 @@ require 'fixtures/post' require 'fixtures/category' class ConditionsScopingTest < Test::Unit::TestCase - fixtures :developers + fixtures :developers, :comments, :posts def test_set_conditions Developer.constrain(:conditions => 'just a test...') do @@ -42,6 +42,17 @@ class ConditionsScopingTest < Test::Unit::TestCase end end + def test_scoped_create + new_comment = nil + + VerySpecialComment.constrain(:creation => { :post_id => 1 }) do + assert_equal({ :post_id => 1 }, Thread.current[:constraints][VerySpecialComment][:creation]) + new_comment = VerySpecialComment.create :body => "Wonderful world" + end + + assert Post.find(1).comments.include?(new_comment) + end + def test_immutable_constraint options = { :conditions => "name = 'David'" } Developer.constrain(options) do |