Created
October 5, 2011 19:01
-
-
Save nu7hatch/1265331 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
require 'spec_helper' | |
describe MessageObserver do | |
subject do | |
MessageObserver.instance | |
end | |
let :message do | |
Message.make! :content => "Hello World!" | |
end | |
describe "after update" do | |
context "when message notify flag is on" do | |
before do | |
Delayed::Job.delete_all | |
end | |
let :job do | |
stub(:perform => lambda {}) | |
end | |
it "schedules mail to user about new message" do | |
message.expects(:notify?).returns(true) | |
NewMessageNotifierJob.expects(:new).with(message).returns(job) | |
Delayed::Job.expects(:enqueue).with(job) | |
subject.after_create(message) | |
end | |
end | |
context "when message notify flag is off" do | |
it "does nothing" do | |
message.expects(:notify?).returns(false) | |
NewMessageNotifierJob.expects(:new).times(0) | |
subject.after_create(message) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment