diff options
author | Sean McGivern <sean@gitlab.com> | 2016-07-21 12:53:38 +0300 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2016-07-21 12:53:38 +0300 |
commit | 331571e0671baf606fd0c5cf694441b9a4036419 (patch) | |
tree | c6a91d2c62dc93cb9d5c178e0db89bfc00b529c4 /spec/workers | |
parent | cb9f418bf846b5bc32902ed70ddc7d7be3d5c071 (diff) |
Fix emails on push for new and deleted branches
Diffstat (limited to 'spec/workers')
-rw-r--r-- | spec/workers/emails_on_push_worker_spec.rb | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/spec/workers/emails_on_push_worker_spec.rb b/spec/workers/emails_on_push_worker_spec.rb index 439da765c2c..796751efe8d 100644 --- a/spec/workers/emails_on_push_worker_spec.rb +++ b/spec/workers/emails_on_push_worker_spec.rb @@ -12,6 +12,42 @@ describe EmailsOnPushWorker do subject { EmailsOnPushWorker.new } describe "#perform" do + context "when push is a new branch" do + let(:email) { ActionMailer::Base.deliveries.last } + + before do + data_new_branch = data.stringify_keys.merge("before" => Gitlab::Git::BLANK_SHA) + + subject.perform(project.id, recipients, data_new_branch) + end + + it "sends a mail with the correct subject" do + expect(email.subject).to include("Pushed new branch") + end + + it "sends the mail to the correct recipient" do + expect(email.to).to eq([user.email]) + end + end + + context "when push is a deleted branch" do + let(:email) { ActionMailer::Base.deliveries.last } + + before do + data_deleted_branch = data.stringify_keys.merge("after" => Gitlab::Git::BLANK_SHA) + + subject.perform(project.id, recipients, data_deleted_branch) + end + + it "sends a mail with the correct subject" do + expect(email.subject).to include("Deleted branch") + end + + it "sends the mail to the correct recipient" do + expect(email.to).to eq([user.email]) + end + end + context "when there are no errors in sending" do let(:email) { ActionMailer::Base.deliveries.last } |