Skip to content

Commit

Permalink
Fix AR#update_columns tests on Ruby 1.8.7
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosantoniodasilva committed Jul 26, 2012
1 parent def9c85 commit 17a64de
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions activerecord/test/cases/persistence_test.rb
Expand Up @@ -526,7 +526,7 @@ def test_update_column_with_one_changed_and_one_updated

def test_update_columns
topic = Topic.find(1)
topic.update_columns({ "approved" => true, title: "Sebastian Topic" })
topic.update_columns("approved" => true, :title => "Sebastian Topic")
assert topic.approved?
assert_equal "Sebastian Topic", topic.title
topic.reload
Expand All @@ -536,27 +536,27 @@ def test_update_columns

def test_update_columns_should_raise_exception_if_new_record
topic = Topic.new
assert_raises(ActiveRecord::ActiveRecordError) { topic.update_columns({ approved: false }) }
assert_raises(ActiveRecord::ActiveRecordError) { topic.update_columns(:approved => false) }
end

def test_update_columns_should_not_leave_the_object_dirty
topic = Topic.find(1)
topic.update_attributes({ "content" => "Have a nice day", :author_name => "Jose" })
topic.update_attributes("content" => "Have a nice day", :author_name => "Jose")

topic.reload
topic.update_columns({ content: "You too", "author_name" => "Sebastian" })
topic.update_columns(:content => "You too", "author_name" => "Sebastian")
assert_equal [], topic.changed

topic.reload
topic.update_columns({ content: "Have a nice day", author_name: "Jose" })
topic.update_columns(:content => "Have a nice day", :author_name => "Jose")
assert_equal [], topic.changed
end

def test_update_columns_with_one_readonly_attribute
minivan = Minivan.find('m1')
prev_color = minivan.color
prev_name = minivan.name
assert_raises(ActiveRecord::ActiveRecordError) { minivan.update_columns({ name: "My old minivan", color: 'black' }) }
assert_raises(ActiveRecord::ActiveRecordError) { minivan.update_columns(:name => "My old minivan", :color => 'black') }
assert_equal prev_color, minivan.color
assert_equal prev_name, minivan.name

Expand All @@ -572,7 +572,7 @@ def test_update_columns_should_not_modify_updated_at
developer.update_column(:updated_at, prev_month)
assert_equal prev_month, developer.updated_at

developer.update_columns({ salary: 80000 })
developer.update_columns(:salary => 80000)
assert_equal prev_month, developer.updated_at
assert_equal 80000, developer.salary

Expand Down

0 comments on commit 17a64de

Please sign in to comment.