diff options
author | Jonathan A. Sternberg <jonathansternberg@gmail.com> | 2014-04-10 20:41:20 +0400 |
---|---|---|
committer | Marin Jankovski <marin@gitlab.com> | 2014-04-14 11:19:57 +0400 |
commit | c67e3067d2ff57341fbc620342d18520c1c73629 (patch) | |
tree | 23ca53063e3273cddb9cef43ecf159d69ce7a10c | |
parent | 2f5b6e137eb5ba027f8bef5f720323e8d9fea5ce (diff) |
Fix emails on push service when a single commit is pushed
Conflicts:
CHANGELOG
-rw-r--r-- | CHANGELOG | 3 | ||||
-rw-r--r-- | app/mailers/emails/projects.rb | 2 | ||||
-rw-r--r-- | spec/mailers/notify_spec.rb | 38 |
3 files changed, 41 insertions, 2 deletions
diff --git a/CHANGELOG b/CHANGELOG index dde81a7bfd1..d5d01c3840f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ +v 6.7.5 + - Fix emails on push service when only one commit is pushed (Jonathan Sternberg) + v 6.7.4 - Don't send an email for "mentioned in" notes (Pierre de La Morinerie) diff --git a/app/mailers/emails/projects.rb b/app/mailers/emails/projects.rb index 46aa34d13da..9f99c11ea30 100644 --- a/app/mailers/emails/projects.rb +++ b/app/mailers/emails/projects.rb @@ -26,7 +26,7 @@ module Emails 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), diff --git a/spec/mailers/notify_spec.rb b/spec/mailers/notify_spec.rb index 22d60429ccd..e86a60a42b5 100644 --- a/spec/mailers/notify_spec.rb +++ b/spec/mailers/notify_spec.rb @@ -502,7 +502,7 @@ describe Notify do 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 @@ describe Notify do 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 |