diff --git a/app/controllers/projects/issues_controller.rb b/app/controllers/projects/issues_controller.rb index ed31774bc70..35d1a52b251 100644 --- a/app/controllers/projects/issues_controller.rb +++ b/app/controllers/projects/issues_controller.rb @@ -109,9 +109,12 @@ class Projects::IssuesController < Projects::ApplicationController service = Issues::CreateService.new(project, current_user, create_params) @issue = service.execute - if service.discussions_to_resolve.any? && service.discussions_to_resolve.all?(&:resolved?) - resolve_count = service.discussions_to_resolve.size - flash[:notice] = "Resolved #{resolve_count} #{'discussion'.pluralize(resolve_count)}." + if service.discussions_to_resolve.count(&:resolved?) > 0 + flash[:notice] = if params[:discussion_to_resolve].present? + "Resolved 1 discussion." + else + "Resolved all discussions." + end end respond_to do |format| diff --git a/spec/controllers/projects/issues_controller_spec.rb b/spec/controllers/projects/issues_controller_spec.rb index 70b1ae237ce..5e70966aa2d 100644 --- a/spec/controllers/projects/issues_controller_spec.rb +++ b/spec/controllers/projects/issues_controller_spec.rb @@ -498,22 +498,22 @@ describe Projects::IssuesController do it 'sets a flash message' do post_issue(title: 'Hello') - expect(flash[:notice]).to eq('Resolved 1 discussion.') + expect(flash[:notice]).to eq('Resolved all discussions.') end - it 'pluralizes the flash message when resolving multiple discussions' do - create(:diff_note_on_merge_request, noteable: merge_request, project: project, line_number: 15) + describe "resolving a single discussion" do + before do + post_issue({ title: 'Hello' }, other_params: { discussion_to_resolve: discussion.id }) + end + it 'resolves a single discussion' do + discussion.first_note.reload - post_issue(title: 'Hello') + expect(discussion.resolved?).to eq(true) + end - expect(flash[:notice]).to eq('Resolved 2 discussions.') - end - - it "resolves a single discussion" do - post_issue(other_params: { discussion_to_resolve: discussion.id }) - discussion.first_note.reload - - expect(discussion.resolved?).to eq(true) + it 'sets a flash message that one discussion was resolved' do + expect(flash[:notice]).to eq('Resolved 1 discussion.') + end end end