Skip to content

Commit

Permalink
transaction spec
Browse files Browse the repository at this point in the history
  • Loading branch information
bleonard committed Sep 8, 2016
1 parent 4151e02 commit 8ad80b3
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,17 @@
connection.execute('SELECT * FROM users')
end

it 'should use transactions to signify master' do
con = connection.master_pool.connections.first
expect(con).to receive(:execute).with('BEGIN').once
expect(con).to receive(:execute).with('SELECT * FROM users').once
expect(con).to receive(:execute).with('COMMIT').once

ActiveRecord::Base.transaction do
connection.execute('SELECT * FROM users')
end
end

it 'should send writes to master' do
con = connection.master_pool.connections.first
expect(con).to receive(:execute).with('UPDATE users SET name = "bob" WHERE id = 1')
Expand Down

0 comments on commit 8ad80b3

Please sign in to comment.