Commit 331571e0 authored by Sean McGivern's avatar Sean McGivern

Fix emails on push for new and deleted branches

parent cb9f418b
......@@ -28,12 +28,12 @@ class EmailsOnPushWorker
:push
end
merge_base_sha = project.merge_base_commit(before_sha, after_sha).try(:sha)
diff_refs = nil
compare = nil
reverse_compare = false
if action == :push
merge_base_sha = project.merge_base_commit(before_sha, after_sha).try(:sha)
compare = Gitlab::Git::Compare.new(project.repository.raw_repository, before_sha, after_sha)
diff_refs = Gitlab::Diff::DiffRefs.new(
......
......@@ -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 }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment