diff --git a/app/views/notify/push_to_merge_request_email.html.haml b/app/views/notify/push_to_merge_request_email.html.haml index 4c507c08ed765128673423743b0379db26a338ea..67744ec1cee00c8619ec459a877224e2332401e0 100644 --- a/app/views/notify/push_to_merge_request_email.html.haml +++ b/app/views/notify/push_to_merge_request_email.html.haml @@ -7,7 +7,7 @@ - count = @existing_commits.size %ul %li - - if count.one? + - if count == 1 - commit_id = @existing_commits.first[:short_id] = link_to(commit_id, project_commit_url(@merge_request.target_project, commit_id)) - else diff --git a/app/views/notify/push_to_merge_request_email.text.haml b/app/views/notify/push_to_merge_request_email.text.haml index 553f771f1a6b9ea7321bf36ed84741ff7e16ef9b..95759d127e2443c9806656df306ddd39ec71353b 100644 --- a/app/views/notify/push_to_merge_request_email.text.haml +++ b/app/views/notify/push_to_merge_request_email.text.haml @@ -4,7 +4,7 @@ \ - if @existing_commits.any? - count = @existing_commits.size - - commits_id = count.one? ? @existing_commits.first[:short_id] : "#{@existing_commits.first[:short_id]}...#{@existing_commits.last[:short_id]}" + - commits_id = count == 1 ? @existing_commits.first[:short_id] : "#{@existing_commits.first[:short_id]}...#{@existing_commits.last[:short_id]}" - commits_text = "#{count} commit".pluralize(count) * #{commits_id} - #{commits_text} from branch `#{@merge_request.target_branch}` diff --git a/spec/mailers/notify_spec.rb b/spec/mailers/notify_spec.rb index 971a88e9ee9741586c71c398530a9723d4d61314..43e419cd7de1be49b74976a2ea894967deaa354f 100644 --- a/spec/mailers/notify_spec.rb +++ b/spec/mailers/notify_spec.rb @@ -390,11 +390,11 @@ describe Notify do end end - describe 'that have new commits' do + shared_examples 'a push to an existing merge request' do let(:push_user) { create(:user) } subject do - described_class.push_to_merge_request_email(recipient.id, merge_request.id, push_user.id, new_commits: merge_request.commits) + described_class.push_to_merge_request_email(recipient.id, merge_request.id, push_user.id, new_commits: merge_request.commits, existing_commits: existing_commits) end it_behaves_like 'a multiple recipients email' @@ -419,6 +419,18 @@ describe Notify do end end end + + describe 'that have new commits' do + let(:existing_commits) { [] } + + it_behaves_like 'a push to an existing merge request' + end + + describe 'that have new commits on top of an existing one' do + let(:existing_commits) { [merge_request.commits.first] } + + it_behaves_like 'a push to an existing merge request' + end end context 'for issue notes' do