diff options
author | cmrd Senya <senya@riseup.net> | 2016-09-14 20:30:36 +0300 |
---|---|---|
committer | cmrd Senya <senya@riseup.net> | 2016-11-28 16:35:46 +0300 |
commit | ef5751b808f7aa47b1ad10790e1c30894ae67b43 (patch) | |
tree | efe5de91c0c8178aef41ea37e8cfea05914185c4 /spec/workers | |
parent | 0ee34f8590df6e2fce3fecf5b484af6eaa6f8524 (diff) |
Refactor mail workers to use common base
Introduce Workers::Mail::NotifierBase to be a base for all appropriate
mail workers to reduce code duplication
Diffstat (limited to 'spec/workers')
-rw-r--r-- | spec/workers/mail/csrf_token_fail_spec.rb | 4 | ||||
-rw-r--r-- | spec/workers/mail/liked_spec.rb | 9 | ||||
-rw-r--r-- | spec/workers/mail/mentioned_spec.rb | 6 | ||||
-rw-r--r-- | spec/workers/mail/private_message_spec.rb | 9 | ||||
-rw-r--r-- | spec/workers/mail/reshared_spec.rb | 7 |
5 files changed, 19 insertions, 16 deletions
diff --git a/spec/workers/mail/csrf_token_fail_spec.rb b/spec/workers/mail/csrf_token_fail_spec.rb index e57292048..8c94f8663 100644 --- a/spec/workers/mail/csrf_token_fail_spec.rb +++ b/spec/workers/mail/csrf_token_fail_spec.rb @@ -3,12 +3,12 @@ # the COPYRIGHT file. describe Workers::Mail::CsrfTokenFail do - describe "#perfom" do + describe "#perform" do it "should call .deliver on the notifier object" do user = alice mail_double = double expect(mail_double).to receive(:deliver_now) - expect(Notifier).to receive(:csrf_token_fail).with(user.id).and_return(mail_double) + expect(Notifier).to receive(:send_notification).with("csrf_token_fail", user.id).and_return(mail_double) Workers::Mail::CsrfTokenFail.new.perform(user.id) end diff --git a/spec/workers/mail/liked_spec.rb b/spec/workers/mail/liked_spec.rb index 8bb31ef0d..7ab94586a 100644 --- a/spec/workers/mail/liked_spec.rb +++ b/spec/workers/mail/liked_spec.rb @@ -1,12 +1,13 @@ describe Workers::Mail::Liked do - describe "#perfom" do + describe "#perform" 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) + expect(Notifier).to receive(:send_notification) + .with("liked", bob.id, like.author.id, like.id).and_return(mail_double) Workers::Mail::Liked.new.perform(bob.id, like.author.id, like.id) end @@ -15,7 +16,7 @@ describe Workers::Mail::Liked 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) + expect(Notifier).to receive(:send_notification).with("liked", 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) @@ -25,7 +26,7 @@ describe Workers::Mail::Liked 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) + expect(Notifier).to receive(:send_notification).with("liked", bob.id, like.author.id, like.id) .and_raise(ActiveRecord::RecordNotFound.new("Couldn't find Person with 'id'=42")) expect { diff --git a/spec/workers/mail/mentioned_spec.rb b/spec/workers/mail/mentioned_spec.rb index e63a9dfe5..5d8d76cd7 100644 --- a/spec/workers/mail/mentioned_spec.rb +++ b/spec/workers/mail/mentioned_spec.rb @@ -3,15 +3,15 @@ # the COPYRIGHT file. describe Workers::Mail::Mentioned do - describe '#perfom' do - it 'should call .deliver on the notifier object' do + describe "#perform" do + it "should call .deliver on the notifier object" do user = alice sm = FactoryGirl.build(:status_message) m = Mention.new(:person => user.person, :post=> sm) mail_double = double() expect(mail_double).to receive(:deliver_now) - expect(Notifier).to receive(:mentioned).with(user.id, sm.author.id, m.id).and_return(mail_double) + expect(Notifier).to receive(:send_notification).with("mentioned", user.id, sm.author.id, m.id).and_return(mail_double) Workers::Mail::Mentioned.new.perform(user.id, sm.author.id, m.id) end diff --git a/spec/workers/mail/private_message_spec.rb b/spec/workers/mail/private_message_spec.rb index 8722cd211..7b8401986 100644 --- a/spec/workers/mail/private_message_spec.rb +++ b/spec/workers/mail/private_message_spec.rb @@ -3,8 +3,8 @@ # the COPYRIGHT file. describe Workers::Mail::PrivateMessage do - describe '#perfom_delegate' do - it 'should call .deliver on the notifier object' do + describe "#perform" do + it "should call .deliver on the notifier object" do user1 = alice user2 = bob participant_ids = [user1.contacts.first.person.id, user1.person.id] @@ -17,9 +17,10 @@ describe Workers::Mail::PrivateMessage do mail_double = double() expect(mail_double).to receive(:deliver_now) - expect(Notifier).to receive(:mentioned).with(user2.id, user1.person.id, message.id).and_return(mail_double) + expect(Notifier).to receive(:send_notification) + .with("private_message", user2.id, user1.person.id, message.id).and_return(mail_double) - Workers::Mail::Mentioned.new.perform(user2.id, user1.person.id, message.id) + Workers::Mail::PrivateMessage.new.perform(user2.id, user1.person.id, message.id) end end end diff --git a/spec/workers/mail/reshared_spec.rb b/spec/workers/mail/reshared_spec.rb index fea1eb54d..d1ebd9908 100644 --- a/spec/workers/mail/reshared_spec.rb +++ b/spec/workers/mail/reshared_spec.rb @@ -3,14 +3,15 @@ # the COPYRIGHT file. describe Workers::Mail::Reshared do - describe '#perfom' do - it 'should call .deliver on the notifier object' do + describe "#perform" do + it "should call .deliver on the notifier object" do sm = FactoryGirl.build(:status_message, :author => bob.person, :public => true) reshare = FactoryGirl.build(:reshare, :author => alice.person, :root=> sm) mail_double = double() expect(mail_double).to receive(:deliver_now) - expect(Notifier).to receive(:reshared).with(bob.id, reshare.author.id, reshare.id).and_return(mail_double) + expect(Notifier).to receive(:send_notification) + .with("reshared", bob.id, reshare.author.id, reshare.id).and_return(mail_double) Workers::Mail::Reshared.new.perform(bob.id, reshare.author.id, reshare.id) end |