GitLab steht wegen Wartungsarbeiten am Montag, den 10. Mai, zwischen 17:00 und 19:00 Uhr nicht zur Verfügung.

Commit 9cb2a4ac authored by Jonathan A. Sternberg's avatar Jonathan A. Sternberg

Fix emails on push service when a single commit is pushed

This fixes issue #161.
parent 415c0f4b
......@@ -15,6 +15,7 @@ v 6.8.0
- Option to disable standard login
- Clean old created archives from repository downloads directory
- Fix download link for huge MR diffs
- Fix emails on push service when only one commit is pushed
v 6.7.3
- Fix the merge notification email not being sent (Pierre de La Morinerie)
......
......@@ -26,7 +26,7 @@ def repository_push_email(project_id, recipient, author_id, branch, compare)
if @commits.length > 1
@target_url = project_compare_url(@project, from: @commits.first, to: @commits.last)
else
@target_url = project_commit_url(@project, @compare.commit)
@target_url = project_commit_url(@project, @commits.first)
end
mail(from: sender(author_id),
......
......@@ -502,7 +502,7 @@
end
end
describe 'email on push' do
describe 'email on push with multiple commits' do
let(:example_site_path) { root_path }
let(:user) { create(:user) }
let(:compare) { Gitlab::Git::Compare.new(project.repository.raw_repository, 'cd5c4bac', 'b1e6a9db') }
......@@ -537,4 +537,40 @@
should have_body_text /#{diff_path}/
end
end
describe 'email on push with a single commit' do
let(:example_site_path) { root_path }
let(:user) { create(:user) }
let(:compare) { Gitlab::Git::Compare.new(project.repository.raw_repository, '8716fc78', 'b1e6a9db') }
let(:commits) { Commit.decorate(compare.commits) }
let(:diff_path) { project_commit_path(project, commits.first) }
subject { Notify.repository_push_email(project.id, 'devs@company.name', user.id, 'master', compare) }
it 'is sent as the author' do
sender = subject.header[:from].addrs[0]
sender.display_name.should eq(user.name)
sender.address.should eq(gitlab_sender)
end
it 'is sent to recipient' do
should deliver_to 'devs@company.name'
end
it 'has the correct subject' do
should have_subject /New push to repository/
end
it 'includes commits list' do
should have_body_text /tree css fixes/
end
it 'includes diffs' do
should have_body_text /Checkout wiki pages for installation information/
end
it 'contains a link to the diff' do
should have_body_text /#{diff_path}/
end
end
end
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