Fix undefined method one?
when pushing to an existing merge request
An untested code path was triggering an Exception because Fixnum doesn't have `one?` implemented in Rails, while arrays and collections do. Closes #45152
This commit is contained in:
parent
dd552d06f6
commit
47b1528abe
3 changed files with 16 additions and 4 deletions
|
@ -7,7 +7,7 @@
|
||||||
- count = @existing_commits.size
|
- count = @existing_commits.size
|
||||||
%ul
|
%ul
|
||||||
%li
|
%li
|
||||||
- if count.one?
|
- if count == 1
|
||||||
- commit_id = @existing_commits.first[:short_id]
|
- commit_id = @existing_commits.first[:short_id]
|
||||||
= link_to(commit_id, project_commit_url(@merge_request.target_project, commit_id))
|
= link_to(commit_id, project_commit_url(@merge_request.target_project, commit_id))
|
||||||
- else
|
- else
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
\
|
\
|
||||||
- if @existing_commits.any?
|
- if @existing_commits.any?
|
||||||
- count = @existing_commits.size
|
- 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_text = "#{count} commit".pluralize(count)
|
||||||
|
|
||||||
* #{commits_id} - #{commits_text} from branch `#{@merge_request.target_branch}`
|
* #{commits_id} - #{commits_text} from branch `#{@merge_request.target_branch}`
|
||||||
|
|
|
@ -390,11 +390,11 @@ describe Notify do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'that have new commits' do
|
shared_examples 'a push to an existing merge request' do
|
||||||
let(:push_user) { create(:user) }
|
let(:push_user) { create(:user) }
|
||||||
|
|
||||||
subject do
|
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
|
end
|
||||||
|
|
||||||
it_behaves_like 'a multiple recipients email'
|
it_behaves_like 'a multiple recipients email'
|
||||||
|
@ -419,6 +419,18 @@ describe Notify do
|
||||||
end
|
end
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
context 'for issue notes' do
|
context 'for issue notes' do
|
||||||
|
|
Loading…
Reference in a new issue