Created
December 2, 2015 20:48
-
-
Save ClayShentrup/026550c3feb247829fb3 to your computer and use it in GitHub Desktop.
Testing that code executes within a block, e.g. transaction or time zone
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
it('uses the client time zone') do | |
allow(described_class).to receive(:delete_cache) do | |
fail unless Time.zone == client_time_zone | |
end | |
allow(described_class).to receive(:create_cache) do | |
fail unless Time.zone == client_time_zone | |
end | |
update_for_year | |
end | |
it('uses a transaction') do | |
test_transaction = ActiveRecord::Base.connection.current_transaction | |
allow(described_class).to receive(:delete_cache) do | |
fail if ActiveRecord::Base.connection.current_transaction == | |
test_transaction | |
end | |
allow(described_class).to receive(:create_cache) do | |
fail if ActiveRecord::Base.connection.current_transaction == | |
test_transaction | |
end | |
update_for_year | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment