Skip to content

Instantly share code, notes, and snippets.

@nu7hatch
Created October 5, 2011 19:01
Show Gist options
  • Save nu7hatch/1265331 to your computer and use it in GitHub Desktop.
Save nu7hatch/1265331 to your computer and use it in GitHub Desktop.
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