Skip to content

Commit

Permalink
Update tests so that update/update! are the main ones tested against
Browse files Browse the repository at this point in the history
Since the `update_attributes` versions are being deprecated in Rails 6,
decrease the surface area touched by those and lean more on `update`
instead.
  • Loading branch information
carlosantoniodasilva committed Sep 23, 2019
1 parent b15f9e3 commit a984037
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions test/i18n_alchemy/proxy/attributes_parsing_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,20 @@ def test_attributes_assignment_does_not_change_given_attributes_hash
end
end

def test_update_attributes
@localized.update_attributes(:price => '2,88')
def test_update
@localized.update(:price => '2,88')
assert_equal '2,88', @localized.price
assert_equal 2.88, @product.reload.price
end

def test_update_attributes_does_not_change_given_attributes_hash
def test_update_does_not_change_given_attributes_hash
assert_attributes_hash_is_unchanged do |attributes|
@localized.update_attributes(attributes)
@localized.update(attributes)
end
end

def test_update_attributes!
@localized.update_attributes!(:price => '2,88')
def test_update_attributes
@localized.update_attributes(:price => '2,88')
assert_equal '2,88', @localized.price
assert_equal 2.88, @product.reload.price
end
Expand All @@ -65,18 +65,18 @@ def test_update!
assert_equal 2.88, @product.reload.price
end

def test_update
@localized.update(:price => '2,88')
assert_equal '2,88', @localized.price
assert_equal 2.88, @product.reload.price
end

def test_update_attributes_bang_does_not_change_given_attributes_hash
def test_update_bang_does_not_change_given_attributes_hash
assert_attributes_hash_is_unchanged do |attributes|
@localized.update_attributes!(attributes)
@localized.update!(attributes)
end
end

def test_update_attributes!
@localized.update_attributes!(:price => '2,88')
assert_equal '2,88', @localized.price
assert_equal 2.88, @product.reload.price
end

def test_update_attribute
@localized.update_attribute(:price, '2,88')
assert_equal '2,88', @localized.price
Expand Down Expand Up @@ -104,8 +104,8 @@ def test_should_assign_for_nested_attributes_for_one_to_one_association
assert_equal '100,87', account.localized.total_money
end

def test_update_attributes_for_nested_attributes
@supplier_localized.update_attributes(:account_attributes => {:total_money => '99,87'})
def test_update_for_nested_attributes
@supplier_localized.update(:account_attributes => {:total_money => '99,87'})
assert_equal '99,87', @supplier_localized.account.localized.total_money
end

Expand Down

0 comments on commit a984037

Please sign in to comment.