Commit 28e6e1b1ab22f50a700408fa0c43528cd13ad360
Exists in
spb-stable
and in
3 other branches
Merge branch '161-emails-on-push-service' of https://gitlab.com/jsternberg/gitla…
…b-ce into jsternberg/gitlab-ce-161-emails-on-push-service Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> Conflicts: CHANGELOG
Showing
3 changed files
with
39 additions
and
2 deletions
Show diff stats
CHANGELOG
| @@ -16,6 +16,7 @@ v 6.8.0 | @@ -16,6 +16,7 @@ v 6.8.0 | ||
| 16 | - Clean old created archives from repository downloads directory | 16 | - Clean old created archives from repository downloads directory |
| 17 | - Fix download link for huge MR diffs | 17 | - Fix download link for huge MR diffs |
| 18 | - Expose event and mergerequest timestamps in API | 18 | - Expose event and mergerequest timestamps in API |
| 19 | + - Fix emails on push service when only one commit is pushed | ||
| 19 | 20 | ||
| 20 | v 6.7.3 | 21 | v 6.7.3 |
| 21 | - Fix the merge notification email not being sent (Pierre de La Morinerie) | 22 | - Fix the merge notification email not being sent (Pierre de La Morinerie) |
app/mailers/emails/projects.rb
| @@ -26,7 +26,7 @@ module Emails | @@ -26,7 +26,7 @@ module Emails | ||
| 26 | if @commits.length > 1 | 26 | if @commits.length > 1 |
| 27 | @target_url = project_compare_url(@project, from: @commits.first, to: @commits.last) | 27 | @target_url = project_compare_url(@project, from: @commits.first, to: @commits.last) |
| 28 | else | 28 | else |
| 29 | - @target_url = project_commit_url(@project, @compare.commit) | 29 | + @target_url = project_commit_url(@project, @commits.first) |
| 30 | end | 30 | end |
| 31 | 31 | ||
| 32 | mail(from: sender(author_id), | 32 | mail(from: sender(author_id), |
spec/mailers/notify_spec.rb
| @@ -502,7 +502,7 @@ describe Notify do | @@ -502,7 +502,7 @@ describe Notify do | ||
| 502 | end | 502 | end |
| 503 | end | 503 | end |
| 504 | 504 | ||
| 505 | - describe 'email on push' do | 505 | + describe 'email on push with multiple commits' do |
| 506 | let(:example_site_path) { root_path } | 506 | let(:example_site_path) { root_path } |
| 507 | let(:user) { create(:user) } | 507 | let(:user) { create(:user) } |
| 508 | let(:compare) { Gitlab::Git::Compare.new(project.repository.raw_repository, 'cd5c4bac', 'b1e6a9db') } | 508 | let(:compare) { Gitlab::Git::Compare.new(project.repository.raw_repository, 'cd5c4bac', 'b1e6a9db') } |
| @@ -537,4 +537,40 @@ describe Notify do | @@ -537,4 +537,40 @@ describe Notify do | ||
| 537 | should have_body_text /#{diff_path}/ | 537 | should have_body_text /#{diff_path}/ |
| 538 | end | 538 | end |
| 539 | end | 539 | end |
| 540 | + | ||
| 541 | + describe 'email on push with a single commit' do | ||
| 542 | + let(:example_site_path) { root_path } | ||
| 543 | + let(:user) { create(:user) } | ||
| 544 | + let(:compare) { Gitlab::Git::Compare.new(project.repository.raw_repository, '8716fc78', 'b1e6a9db') } | ||
| 545 | + let(:commits) { Commit.decorate(compare.commits) } | ||
| 546 | + let(:diff_path) { project_commit_path(project, commits.first) } | ||
| 547 | + | ||
| 548 | + subject { Notify.repository_push_email(project.id, 'devs@company.name', user.id, 'master', compare) } | ||
| 549 | + | ||
| 550 | + it 'is sent as the author' do | ||
| 551 | + sender = subject.header[:from].addrs[0] | ||
| 552 | + sender.display_name.should eq(user.name) | ||
| 553 | + sender.address.should eq(gitlab_sender) | ||
| 554 | + end | ||
| 555 | + | ||
| 556 | + it 'is sent to recipient' do | ||
| 557 | + should deliver_to 'devs@company.name' | ||
| 558 | + end | ||
| 559 | + | ||
| 560 | + it 'has the correct subject' do | ||
| 561 | + should have_subject /New push to repository/ | ||
| 562 | + end | ||
| 563 | + | ||
| 564 | + it 'includes commits list' do | ||
| 565 | + should have_body_text /tree css fixes/ | ||
| 566 | + end | ||
| 567 | + | ||
| 568 | + it 'includes diffs' do | ||
| 569 | + should have_body_text /Checkout wiki pages for installation information/ | ||
| 570 | + end | ||
| 571 | + | ||
| 572 | + it 'contains a link to the diff' do | ||
| 573 | + should have_body_text /#{diff_path}/ | ||
| 574 | + end | ||
| 575 | + end | ||
| 540 | end | 576 | end |