Commit f8b5fef9 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Separate flash messages for resolving one or multiple discussions

parent ab520862
...@@ -109,9 +109,12 @@ class Projects::IssuesController < Projects::ApplicationController ...@@ -109,9 +109,12 @@ class Projects::IssuesController < Projects::ApplicationController
service = Issues::CreateService.new(project, current_user, create_params) service = Issues::CreateService.new(project, current_user, create_params)
@issue = service.execute @issue = service.execute
if service.discussions_to_resolve.any? && service.discussions_to_resolve.all?(&:resolved?) if service.discussions_to_resolve.count(&:resolved?) > 0
resolve_count = service.discussions_to_resolve.size flash[:notice] = if params[:discussion_to_resolve].present?
flash[:notice] = "Resolved #{resolve_count} #{'discussion'.pluralize(resolve_count)}." "Resolved 1 discussion."
else
"Resolved all discussions."
end
end end
respond_to do |format| respond_to do |format|
......
...@@ -498,22 +498,22 @@ describe Projects::IssuesController do ...@@ -498,22 +498,22 @@ describe Projects::IssuesController do
it 'sets a flash message' do it 'sets a flash message' do
post_issue(title: 'Hello') post_issue(title: 'Hello')
expect(flash[:notice]).to eq('Resolved 1 discussion.') expect(flash[:notice]).to eq('Resolved all discussions.')
end end
it 'pluralizes the flash message when resolving multiple discussions' do describe "resolving a single discussion" do
create(:diff_note_on_merge_request, noteable: merge_request, project: project, line_number: 15) before do
post_issue({ title: 'Hello' }, other_params: { discussion_to_resolve: discussion.id })
post_issue(title: 'Hello') end
it 'resolves a single discussion' do
expect(flash[:notice]).to eq('Resolved 2 discussions.') discussion.first_note.reload
end
it "resolves a single discussion" do expect(discussion.resolved?).to eq(true)
post_issue(other_params: { discussion_to_resolve: discussion.id }) end
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
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment