Created
April 16, 2018 23:35
-
-
Save jenrzzz/67f24eef4dfdfe42e32469d27e8b58d8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe 'test' do | |
it 'locks stuff' do | |
ActiveRecord::Base.connection.execute <<-SQL | |
BEGIN; | |
SELECT pg_advisory_lock(420); | |
SQL | |
Thread.new do | |
res = ActiveRecord::Base.connection.execute <<-SQL | |
SELECT pg_try_advisory_lock(420); | |
SQL | |
expect(res.getvalue(0, 0)).to eq('f') | |
end.join | |
ActiveRecord::Base.connection.execute 'ROLLBACK;' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment