Skip to content
This repository has been archived by the owner on Apr 18, 2021. It is now read-only.

Commit

Permalink
added transaction tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakub Kuźma committed Jan 4, 2010
1 parent e920bff commit 3b78f5a
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions test/test_active_record.rb
Expand Up @@ -109,4 +109,41 @@ def test_user_dirty_attributes
assert_equal "alice", user.login
assert_equal "bob", user.login_was
end

def test_transaction_commit
User.transaction do
User.create!
end
assert_equal 1, User.count
end

def test_transaction_rollback
User.transaction do
User.create!
raise ActiveRecord::Rollback
end
assert_equal 0, User.count
end

def test_reload
User.create!(:login => "bob")
user = User.first
assert_equal "bob", user.login
user.login = "alice"
assert_equal "alice", user.login
user.reload
assert_equal "bob", user.login
end

def test_save
user = User.new(:login => "alice")
user.save
assert_equal 1, User.count
end

def test_save_with_bang
user = User.new(:login => "alice")
user.save!
assert_equal 1, User.count
end
end

0 comments on commit 3b78f5a

Please sign in to comment.