diff options
author | Benjamin Neff <benjamin@coding4coffee.ch> | 2015-05-23 20:12:37 +0300 |
---|---|---|
committer | Dennis Schubert <mail@dennis-schubert.de> | 2015-05-24 03:30:02 +0300 |
commit | 8531b160a6c8407749411d44ac6bf72ca40408c1 (patch) | |
tree | 0e6297d7cd487c77c8ea50d23a7f8bf39b8b05c0 /spec/workers | |
parent | 68f7208ff5e30e1870d7234efe0316af9db6793d (diff) |
gracefully handle when a like is already deleted again
closes #5983
Diffstat (limited to 'spec/workers')
-rw-r--r-- | spec/workers/mail/liked_spec.rb | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/spec/workers/mail/liked_spec.rb b/spec/workers/mail/liked_spec.rb new file mode 100644 index 000000000..4d91d16e7 --- /dev/null +++ b/spec/workers/mail/liked_spec.rb @@ -0,0 +1,38 @@ +require "spec_helper" + +describe Workers::Mail::Liked do + describe "#perfom" do + it "should call .deliver_now on the notifier object" do + sm = FactoryGirl.build(:status_message, author: bob.person, public: true) + like = FactoryGirl.build(:like, author: alice.person, target: sm) + + mail_double = double + expect(mail_double).to receive(:deliver_now) + expect(Notifier).to receive(:liked).with(bob.id, like.author.id, like.id).and_return(mail_double) + + Workers::Mail::Liked.new.perform(bob.id, like.author.id, like.id) + end + + it "should not fail if the like is not found" do + sm = FactoryGirl.build(:status_message, author: bob.person, public: true) + like = FactoryGirl.build(:like, author: alice.person, target: sm) + + expect(Notifier).to receive(:liked).with(bob.id, like.author.id, like.id) + .and_raise(ActiveRecord::RecordNotFound.new("Couldn't find Like with 'id'=42")) + + Workers::Mail::Liked.new.perform(bob.id, like.author.id, like.id) + end + + it "should fail if the sender is not found" do + sm = FactoryGirl.build(:status_message, author: bob.person, public: true) + like = FactoryGirl.build(:like, author: alice.person, target: sm) + + expect(Notifier).to receive(:liked).with(bob.id, like.author.id, like.id) + .and_raise(ActiveRecord::RecordNotFound.new("Couldn't find Person with 'id'=42")) + + expect { + Workers::Mail::Liked.new.perform(bob.id, like.author.id, like.id) + }.to raise_error(ActiveRecord::RecordNotFound) + end + end +end |