Last active
January 23, 2018 11:28
-
-
Save barelyknown/153e94c0d847e15251a8 to your computer and use it in GitHub Desktop.
Testing after_commit :do_something, on: :create
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 "#after_commit" do | |
context "on: :create" do | |
before do | |
expect(subject).to receive(:transaction_record_state).with(:new_record).and_return(true) | |
end | |
it "calls initiate_async" do | |
expect(subject).to receive(:initiate_async) | |
subject.run_callbacks(:commit) | |
end | |
end | |
context "not on: create" do | |
before do | |
expect(subject).to receive(:transaction_record_state).with(:new_record).and_return(false) | |
end | |
it "does not call initiate_async" do | |
expect(subject).to_not receive(:initiate_async) | |
subject.run_callbacks(:commit) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment