From bf9a0ae12b701cba7a8aac2955ce243866ac7bf6 Mon Sep 17 00:00:00 2001 From: Henry Hsu Date: Fri, 26 Feb 2010 11:06:55 +0100 Subject: Fix a bug where default_scope was overriding attributes given on model initialization [#3218 status:resolved] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- activerecord/test/cases/method_scoping_test.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'activerecord/test/cases/method_scoping_test.rb') diff --git a/activerecord/test/cases/method_scoping_test.rb b/activerecord/test/cases/method_scoping_test.rb index 1081aa40a9..3151457440 100644 --- a/activerecord/test/cases/method_scoping_test.rb +++ b/activerecord/test/cases/method_scoping_test.rb @@ -663,6 +663,16 @@ class DefaultScopingTest < ActiveRecord::TestCase assert_equal 2, posts.count assert_equal posts(:thinking), posts.first end + + def test_create_attribute_overwrites_default_scoping + assert_equal 'David', PoorDeveloperCalledJamis.create!(:name => 'David').name + assert_equal 200000, PoorDeveloperCalledJamis.create!(:name => 'David', :salary => 200000).salary + end + + def test_create_attribute_overwrites_default_values + assert_equal nil, PoorDeveloperCalledJamis.create!(:salary => nil).salary + assert_equal 50000, PoorDeveloperCalledJamis.create!(:name => 'David').salary + end end =begin -- cgit v1.2.3