Welcome to mirror list, hosted at ThFree Co, Russian Federation.

liked_spec.rb « mail « workers « spec - github.com/diaspora/diaspora.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4d91d16e72f698d4ae92becb866189a5422faef0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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