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

Rename variable

merge_request_for_resolving_discussions ->
merge_request_to_resolve_discussions_of
parent a07e89b2
...@@ -65,13 +65,13 @@ class Projects::IssuesController < Projects::ApplicationController ...@@ -65,13 +65,13 @@ class Projects::IssuesController < Projects::ApplicationController
assignee_id: "" assignee_id: ""
) )
build_params = issue_params.merge( build_params = issue_params.merge(
merge_request_for_resolving_discussions: params[:merge_request_for_resolving_discussions], merge_request_to_resolve_discussions_of: params[:merge_request_to_resolve_discussions_of],
discussion_to_resolve: params[:discussion_to_resolve] discussion_to_resolve: params[:discussion_to_resolve]
) )
service = Issues::BuildService.new(project, current_user, build_params) service = Issues::BuildService.new(project, current_user, build_params)
@issue = @noteable = service.execute @issue = @noteable = service.execute
@merge_request_for_resolving_discussions = service.merge_request_for_resolving_discussions @merge_request_to_resolve_discussions_of = service.merge_request_to_resolve_discussions_of
@discussion_to_resolve = service.discussions_to_resolve.first if params[:discussion_to_resolve] @discussion_to_resolve = service.discussions_to_resolve.first if params[:discussion_to_resolve]
respond_with(@issue) respond_with(@issue)
...@@ -102,7 +102,7 @@ class Projects::IssuesController < Projects::ApplicationController ...@@ -102,7 +102,7 @@ class Projects::IssuesController < Projects::ApplicationController
def create def create
create_params = issue_params.merge(spammable_params).merge( create_params = issue_params.merge(spammable_params).merge(
merge_request_for_resolving_discussions: params[:merge_request_for_resolving_discussions], merge_request_to_resolve_discussions_of: params[:merge_request_to_resolve_discussions_of],
discussion_to_resolve: params[:discussion_to_resolve] discussion_to_resolve: params[:discussion_to_resolve]
) )
...@@ -248,7 +248,6 @@ class Projects::IssuesController < Projects::ApplicationController ...@@ -248,7 +248,6 @@ class Projects::IssuesController < Projects::ApplicationController
def issue_params def issue_params
params.require(:issue).permit( params.require(:issue).permit(
:title, :assignee_id, :position, :description, :confidential, :title, :assignee_id, :position, :description, :confidential,
:discussion_to_resolve, :merge_request_for_resolving_discussions,
:milestone_id, :due_date, :state_event, :task_num, :lock_version, label_ids: [] :milestone_id, :due_date, :state_event, :task_num, :lock_version, label_ids: []
) )
end end
......
...@@ -8,23 +8,23 @@ module Issues ...@@ -8,23 +8,23 @@ module Issues
end end
def issue_params_with_info_from_discussions def issue_params_with_info_from_discussions
return {} unless merge_request_for_resolving_discussions return {} unless merge_request_to_resolve_discussions_of
{ title: title_from_merge_request, description: description_for_discussions } { title: title_from_merge_request, description: description_for_discussions }
end end
def title_from_merge_request def title_from_merge_request
"Follow-up from \"#{merge_request_for_resolving_discussions.title}\"" "Follow-up from \"#{merge_request_to_resolve_discussions_of.title}\""
end end
def description_for_discussions def description_for_discussions
if discussions_to_resolve.empty? if discussions_to_resolve.empty?
return "There are no unresolved discussions. "\ return "There are no unresolved discussions. "\
"Review the conversation in #{merge_request_for_resolving_discussions.to_reference}" "Review the conversation in #{merge_request_to_resolve_discussions_of.to_reference}"
end end
description = "The following #{'discussion'.pluralize(discussions_to_resolve.size)} "\ description = "The following #{'discussion'.pluralize(discussions_to_resolve.size)} "\
"from #{merge_request_for_resolving_discussions.to_reference} "\ "from #{merge_request_to_resolve_discussions_of.to_reference} "\
"should be addressed:" "should be addressed:"
[description, *items_for_discussions].join("\n\n") [description, *items_for_discussions].join("\n\n")
......
...@@ -29,7 +29,7 @@ module Issues ...@@ -29,7 +29,7 @@ module Issues
return if discussions_to_resolve.empty? return if discussions_to_resolve.empty?
Discussions::ResolveService.new(project, current_user, Discussions::ResolveService.new(project, current_user,
merge_request: merge_request_for_resolving_discussions, merge_request: merge_request_to_resolve_discussions_of,
follow_up_issue: issue). follow_up_issue: issue).
execute(discussions_to_resolve) execute(discussions_to_resolve)
end end
......
module Issues module Issues
module ResolveDiscussions module ResolveDiscussions
attr_reader :merge_request_for_resolving_discussions_iid, :discussion_to_resolve_id attr_reader :merge_request_to_resolve_discussions_of_iid, :discussion_to_resolve_id
def filter_resolve_discussion_params def filter_resolve_discussion_params
@merge_request_for_resolving_discussions_iid ||= params.delete(:merge_request_for_resolving_discussions) @merge_request_to_resolve_discussions_of_iid ||= params.delete(:merge_request_to_resolve_discussions_of)
@discussion_to_resolve_id ||= params.delete(:discussion_to_resolve) @discussion_to_resolve_id ||= params.delete(:discussion_to_resolve)
end end
def merge_request_for_resolving_discussions def merge_request_to_resolve_discussions_of
return @merge_request_for_resolving_discussions if defined?(@merge_request_for_resolving_discussions) return @merge_request_to_resolve_discussions_of if defined?(@merge_request_to_resolve_discussions_of)
@merge_request_for_resolving_discussions = MergeRequestsFinder.new(current_user, project_id: project.id). @merge_request_to_resolve_discussions_of = MergeRequestsFinder.new(current_user, project_id: project.id).
execute. execute.
find_by(iid: merge_request_for_resolving_discussions_iid) find_by(iid: merge_request_to_resolve_discussions_of_iid)
end end
def discussions_to_resolve def discussions_to_resolve
return [] unless merge_request_for_resolving_discussions return [] unless merge_request_to_resolve_discussions_of
@discussions_to_resolve ||= @discussions_to_resolve ||=
if discussion_to_resolve_id if discussion_to_resolve_id
discussion_or_nil = merge_request_for_resolving_discussions discussion_or_nil = merge_request_to_resolve_discussions_of
.find_diff_discussion(discussion_to_resolve_id) .find_diff_discussion(discussion_to_resolve_id)
Array(discussion_or_nil) Array(discussion_or_nil)
else else
merge_request_for_resolving_discussions merge_request_to_resolve_discussions_of
.resolvable_discussions .resolvable_discussions
end end
end end
......
...@@ -3,4 +3,4 @@ ...@@ -3,4 +3,4 @@
.btn.btn-default.discussion-create-issue-btn.has-tooltip{ title: "Resolve all discussions in new issue", .btn.btn-default.discussion-create-issue-btn.has-tooltip{ title: "Resolve all discussions in new issue",
"aria-label" => "Resolve all discussions in a new issue", "aria-label" => "Resolve all discussions in a new issue",
"data-container" => "body" } "data-container" => "body" }
= link_to custom_icon('icon_mr_issue'), new_namespace_project_issue_path(@project.namespace, @project, merge_request_for_resolving_discussions: merge_request.iid), title: "Resolve all discussions in new issue", class: 'new-issue-for-discussion' = link_to custom_icon('icon_mr_issue'), new_namespace_project_issue_path(@project.namespace, @project, merge_request_to_resolve_discussions_of: merge_request.iid), title: "Resolve all discussions in new issue", class: 'new-issue-for-discussion'
...@@ -5,4 +5,4 @@ ...@@ -5,4 +5,4 @@
.btn.btn-default.discussion-create-issue-btn.has-tooltip{ title: "Resolve this discussion in a new issue", .btn.btn-default.discussion-create-issue-btn.has-tooltip{ title: "Resolve this discussion in a new issue",
"aria-label" => "Resolve this discussion in a new issue", "aria-label" => "Resolve this discussion in a new issue",
"data-container" => "body" } "data-container" => "body" }
= link_to custom_icon('icon_mr_issue'), new_namespace_project_issue_path(@project.namespace, @project, merge_request_for_resolving_discussions: merge_request.iid, discussion_to_resolve: discussion.id), title: "Resolve this discussion in a new issue", class: 'new-issue-for-discussion' = link_to custom_icon('icon_mr_issue'), new_namespace_project_issue_path(@project.namespace, @project, merge_request_to_resolve_discussions_of: merge_request.iid, discussion_to_resolve: discussion.id), title: "Resolve this discussion in a new issue", class: 'new-issue-for-discussion'
- form = [@project.namespace.becomes(Namespace), @project, @issue] - form = [@project.namespace.becomes(Namespace), @project, @issue]
= render layout: 'layouts/recaptcha_verification', locals: { spammable: @issue, form: form } do = render layout: 'layouts/recaptcha_verification', locals: { spammable: @issue, form: form } do
= hidden_field_tag(:merge_request_for_resolving_discussions, params[:merge_request_for_resolving_discussions]) = hidden_field_tag(:merge_request_to_resolve_discussions_of, params[:merge_request_to_resolve_discussions_of])
= hidden_field_tag(:discussion_to_resolve, params[:discussion_to_resolve]) = hidden_field_tag(:discussion_to_resolve, params[:discussion_to_resolve])
...@@ -6,5 +6,5 @@ ...@@ -6,5 +6,5 @@
Please resolve these discussions Please resolve these discussions
- if @project.issues_enabled? && can?(current_user, :create_issue, @project) - if @project.issues_enabled? && can?(current_user, :create_issue, @project)
or or
= link_to "open an issue to resolve them later", new_namespace_project_issue_path(@project.namespace, @project, merge_request_for_resolving_discussions: @merge_request.iid) = link_to "open an issue to resolve them later", new_namespace_project_issue_path(@project.namespace, @project, merge_request_to_resolve_discussions_of: @merge_request.iid)
to allow this merge request to be merged. to allow this merge request to be merged.
...@@ -45,23 +45,23 @@ ...@@ -45,23 +45,23 @@
= render 'shared/issuable/form/merge_params', issuable: issuable = render 'shared/issuable/form/merge_params', issuable: issuable
- if @merge_request_for_resolving_discussions - if @merge_request_to_resolve_discussions_of
.form-group .form-group
.col-sm-10.col-sm-offset-2 .col-sm-10.col-sm-offset-2
= icon('info-circle') = icon('info-circle')
- if @merge_request_for_resolving_discussions.discussions_can_be_resolved_by?(current_user) - if @merge_request_to_resolve_discussions_of.discussions_can_be_resolved_by?(current_user)
= hidden_field_tag 'merge_request_for_resolving_discussions', @merge_request_for_resolving_discussions.iid = hidden_field_tag 'merge_request_to_resolve_discussions_of', @merge_request_to_resolve_discussions_of.iid
- if @discussion_to_resolve - if @discussion_to_resolve
= hidden_field_tag 'discussion_to_resolve', @discussion_to_resolve.id = hidden_field_tag 'discussion_to_resolve', @discussion_to_resolve.id
Creating this issue will resolve the discussion in Creating this issue will resolve the discussion in
- else - else
Creating this issue will resolve all discussions in Creating this issue will resolve all discussions in
= link_to_discussions_to_resolve(@merge_request_for_resolving_discussions, @discussion_to_resolve) = link_to_discussions_to_resolve(@merge_request_to_resolve_discussions_of, @discussion_to_resolve)
- else - else
The The
= @discussion_to_resolve ? 'discussion' : 'discussions' = @discussion_to_resolve ? 'discussion' : 'discussions'
at at
= link_to_discussions_to_resolve(@merge_request_for_resolving_discussions, @discussion_to_resolve) = link_to_discussions_to_resolve(@merge_request_to_resolve_discussions_of, @discussion_to_resolve)
will stay unresolved. Ask someone with permission to resolve will stay unresolved. Ask someone with permission to resolve
= @discussion_to_resolve ? 'it.' : 'them.' = @discussion_to_resolve ? 'it.' : 'them.'
......
...@@ -340,8 +340,8 @@ POST /projects/:id/issues ...@@ -340,8 +340,8 @@ POST /projects/:id/issues
| `labels` | string | no | Comma-separated label names for an issue | | `labels` | string | no | Comma-separated label names for an issue |
| `created_at` | string | no | Date time string, ISO 8601 formatted, e.g. `2016-03-11T03:45:40Z` (requires admin or project owner rights) | | `created_at` | string | no | Date time string, ISO 8601 formatted, e.g. `2016-03-11T03:45:40Z` (requires admin or project owner rights) |
| `due_date` | string | no | Date time string in the format YEAR-MONTH-DAY, e.g. `2016-03-11` | | `due_date` | string | no | Date time string in the format YEAR-MONTH-DAY, e.g. `2016-03-11` |
| `merge_request_for_resolving_discussions` | integer | no | The IID of a merge request in which to resolve all issues. This will fill the issue with a default description and mark all discussions as resolved. When passing a description or title, these values will take precedence over the default values. | | `merge_request_to_resolve_discussions_of` | integer | no | The IID of a merge request in which to resolve all issues. This will fill the issue with a default description and mark all discussions as resolved. When passing a description or title, these values will take precedence over the default values. |
| `discussion_to_resolve` | string | no | The ID of a discussion to resolve. This will fill in the issue with a default description and mark the discussion as resolved. Use in combination with `merge_request_for_resolving_discussions`. | | `discussion_to_resolve` | string | no | The ID of a discussion to resolve. This will fill in the issue with a default description and mark the discussion as resolved. Use in combination with `merge_request_to_resolve_discussions_of`. |
```bash ```bash
curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/projects/4/issues?title=Issues%20with%20auth&labels=bug curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/projects/4/issues?title=Issues%20with%20auth&labels=bug
......
...@@ -116,10 +116,10 @@ module API ...@@ -116,10 +116,10 @@ module API
requires :title, type: String, desc: 'The title of an issue' requires :title, type: String, desc: 'The title of an issue'
optional :created_at, type: DateTime, optional :created_at, type: DateTime,
desc: 'Date time when the issue was created. Available only for admins and project owners.' desc: 'Date time when the issue was created. Available only for admins and project owners.'
optional :merge_request_for_resolving_discussions, type: Integer, optional :merge_request_to_resolve_discussions_of, type: Integer,
desc: 'The IID of a merge request for which to resolve discussions' desc: 'The IID of a merge request for which to resolve discussions'
optional :discussion_to_resolve, type: String, optional :discussion_to_resolve, type: String,
desc: 'The ID of a discussion to resolve, also pass `merge_request_for_resolving_discussions`' desc: 'The ID of a discussion to resolve, also pass `merge_request_to_resolve_discussions_of`'
use :issue_params use :issue_params
end end
post ':id/issues' do post ':id/issues' do
......
...@@ -104,7 +104,7 @@ describe Projects::IssuesController do ...@@ -104,7 +104,7 @@ describe Projects::IssuesController do
project_with_repository.team << [user, :developer] project_with_repository.team << [user, :developer]
mr = create(:merge_request_with_diff_notes, source_project: project_with_repository) mr = create(:merge_request_with_diff_notes, source_project: project_with_repository)
get :new, namespace_id: project_with_repository.namespace, project_id: project_with_repository, merge_request_for_resolving_discussions: mr.iid get :new, namespace_id: project_with_repository.namespace, project_id: project_with_repository, merge_request_to_resolve_discussions_of: mr.iid
expect(assigns(:issue).title).not_to be_empty expect(assigns(:issue).title).not_to be_empty
expect(assigns(:issue).description).not_to be_empty expect(assigns(:issue).description).not_to be_empty
...@@ -113,7 +113,7 @@ describe Projects::IssuesController do ...@@ -113,7 +113,7 @@ describe Projects::IssuesController do
it 'fills in an issue for a discussion' do it 'fills in an issue for a discussion' do
note = create(:note_on_merge_request, project: project) note = create(:note_on_merge_request, project: project)
get :new, namespace_id: project.namespace.path, project_id: project, merge_request_for_resolving_discussions: note.noteable.iid, discussion_to_resolve: note.discussion_id get :new, namespace_id: project.namespace.path, project_id: project, merge_request_to_resolve_discussions_of: note.noteable.iid, discussion_to_resolve: note.discussion_id
expect(assigns(:issue).title).not_to be_empty expect(assigns(:issue).title).not_to be_empty
expect(assigns(:issue).description).not_to be_empty expect(assigns(:issue).description).not_to be_empty
...@@ -471,11 +471,11 @@ describe Projects::IssuesController do ...@@ -471,11 +471,11 @@ describe Projects::IssuesController do
end end
let(:merge_request_params) do let(:merge_request_params) do
{ merge_request_for_resolving_discussions: merge_request.iid } { merge_request_to_resolve_discussions_of: merge_request.iid }
end end
def post_issue(issue_params, other_params: {}) def post_issue(issue_params, other_params: {})
post :create, { namespace_id: project.namespace.to_param, project_id: project, issue: issue_params, merge_request_for_resolving_discussions: merge_request.iid }.merge(other_params) post :create, { namespace_id: project.namespace.to_param, project_id: project, issue: issue_params, merge_request_to_resolve_discussions_of: merge_request.iid }.merge(other_params)
end end
it 'creates an issue for the project' do it 'creates an issue for the project' do
......
...@@ -15,7 +15,7 @@ feature 'Resolving all open discussions in a merge request from an issue', featu ...@@ -15,7 +15,7 @@ feature 'Resolving all open discussions in a merge request from an issue', featu
it 'shows a button to resolve all discussions by creating a new issue' do it 'shows a button to resolve all discussions by creating a new issue' do
within('li#resolve-count-app') do within('li#resolve-count-app') do
expect(page).to have_link "Resolve all discussions in new issue", href: new_namespace_project_issue_path(project.namespace, project, merge_request_for_resolving_discussions: merge_request.iid) expect(page).to have_link "Resolve all discussions in new issue", href: new_namespace_project_issue_path(project.namespace, project, merge_request_to_resolve_discussions_of: merge_request.iid)
end end
end end
...@@ -25,13 +25,13 @@ feature 'Resolving all open discussions in a merge request from an issue', featu ...@@ -25,13 +25,13 @@ feature 'Resolving all open discussions in a merge request from an issue', featu
end end
it 'hides the link for creating a new issue' do it 'hides the link for creating a new issue' do
expect(page).not_to have_link "Resolve all discussions in new issue", href: new_namespace_project_issue_path(project.namespace, project, merge_request_for_resolving_discussions: merge_request.iid) expect(page).not_to have_link "Resolve all discussions in new issue", href: new_namespace_project_issue_path(project.namespace, project, merge_request_to_resolve_discussions_of: merge_request.iid)
end end
end end
context 'creating an issue for discussions' do context 'creating an issue for discussions' do
before do before do
click_link "Resolve all discussions in new issue", href: new_namespace_project_issue_path(project.namespace, project, merge_request_for_resolving_discussions: merge_request.iid) click_link "Resolve all discussions in new issue", href: new_namespace_project_issue_path(project.namespace, project, merge_request_to_resolve_discussions_of: merge_request.iid)
end end
it_behaves_like 'creating an issue for a discussion' it_behaves_like 'creating an issue for a discussion'
...@@ -64,13 +64,13 @@ feature 'Resolving all open discussions in a merge request from an issue', featu ...@@ -64,13 +64,13 @@ feature 'Resolving all open discussions in a merge request from an issue', featu
it 'has a link to resolve all discussions by creating an issue' do it 'has a link to resolve all discussions by creating an issue' do
page.within '.mr-widget-body' do page.within '.mr-widget-body' do
expect(page).to have_link 'open an issue to resolve them later', href: new_namespace_project_issue_path(project.namespace, project, merge_request_for_resolving_discussions: merge_request.iid) expect(page).to have_link 'open an issue to resolve them later', href: new_namespace_project_issue_path(project.namespace, project, merge_request_to_resolve_discussions_of: merge_request.iid)
end end
end end
context 'creating an issue for discussions' do context 'creating an issue for discussions' do
before do before do
page.click_link 'open an issue to resolve them later', href: new_namespace_project_issue_path(project.namespace, project, merge_request_for_resolving_discussions: merge_request.iid) page.click_link 'open an issue to resolve them later', href: new_namespace_project_issue_path(project.namespace, project, merge_request_to_resolve_discussions_of: merge_request.iid)
end end
it_behaves_like 'creating an issue for a discussion' it_behaves_like 'creating an issue for a discussion'
...@@ -83,7 +83,7 @@ feature 'Resolving all open discussions in a merge request from an issue', featu ...@@ -83,7 +83,7 @@ feature 'Resolving all open discussions in a merge request from an issue', featu
before do before do
project.team << [user, :reporter] project.team << [user, :reporter]
login_as user login_as user
visit new_namespace_project_issue_path(project.namespace, project, merge_request_for_resolving_discussions: merge_request.iid) visit new_namespace_project_issue_path(project.namespace, project, merge_request_to_resolve_discussions_of: merge_request.iid)
end end
it 'Shows a notice to ask someone else to resolve the discussions' do it 'Shows a notice to ask someone else to resolve the discussions' do
......
...@@ -43,14 +43,14 @@ feature 'Resolve an open discussion in a merge request by creating an issue', fe ...@@ -43,14 +43,14 @@ feature 'Resolve an open discussion in a merge request by creating an issue', fe
end end
it 'has a link to create a new issue for a discussion' do it 'has a link to create a new issue for a discussion' do
new_issue_link = new_namespace_project_issue_path(project.namespace, project, discussion_to_resolve: discussion.id, merge_request_for_resolving_discussions: merge_request.iid) new_issue_link = new_namespace_project_issue_path(project.namespace, project, discussion_to_resolve: discussion.id, merge_request_to_resolve_discussions_of: merge_request.iid)
expect(page).to have_link 'Resolve this discussion in a new issue', href: new_issue_link expect(page).to have_link 'Resolve this discussion in a new issue', href: new_issue_link
end end
context 'creating the issue' do context 'creating the issue' do
before do before do
click_link 'Resolve this discussion in a new issue', href: new_namespace_project_issue_path(project.namespace, project, discussion_to_resolve: discussion.id, merge_request_for_resolving_discussions: merge_request.iid) click_link 'Resolve this discussion in a new issue', href: new_namespace_project_issue_path(project.namespace, project, discussion_to_resolve: discussion.id, merge_request_to_resolve_discussions_of: merge_request.iid)
end end
it 'has a hidden field for the discussion' do it 'has a hidden field for the discussion' do
...@@ -68,7 +68,7 @@ feature 'Resolve an open discussion in a merge request by creating an issue', fe ...@@ -68,7 +68,7 @@ feature 'Resolve an open discussion in a merge request by creating an issue', fe
project.team << [user, :reporter] project.team << [user, :reporter]
login_as user login_as user
visit new_namespace_project_issue_path(project.namespace, project, visit new_namespace_project_issue_path(project.namespace, project,
merge_request_for_resolving_discussions: merge_request.iid, merge_request_to_resolve_discussions_of: merge_request.iid,
discussion_to_resolve: discussion.id) discussion_to_resolve: discussion.id)
end end
......
...@@ -941,7 +941,7 @@ describe API::Issues, api: true do ...@@ -941,7 +941,7 @@ describe API::Issues, api: true do
before do before do
post api("/projects/#{project.id}/issues", user), post api("/projects/#{project.id}/issues", user),
title: 'New Issue', title: 'New Issue',
merge_request_for_resolving_discussions: merge_request.iid merge_request_to_resolve_discussions_of: merge_request.iid
end end
it_behaves_like 'creating an issue resolving discussions through the API' it_behaves_like 'creating an issue resolving discussions through the API'
...@@ -951,7 +951,7 @@ describe API::Issues, api: true do ...@@ -951,7 +951,7 @@ describe API::Issues, api: true do
before do before do
post api("/projects/#{project.id}/issues", user), post api("/projects/#{project.id}/issues", user),
title: 'New Issue', title: 'New Issue',
merge_request_for_resolving_discussions: merge_request.iid, merge_request_to_resolve_discussions_of: merge_request.iid,
discussion_to_resolve: discussion.id discussion_to_resolve: discussion.id
end end
......
...@@ -12,7 +12,7 @@ describe Issues::BuildService, services: true do ...@@ -12,7 +12,7 @@ describe Issues::BuildService, services: true do
describe '#execute' do describe '#execute' do
let(:merge_request) { create(:merge_request, title: "Hello world", source_project: project) } let(:merge_request) { create(:merge_request, title: "Hello world", source_project: project) }
let(:discussion) { Discussion.new([create(:diff_note_on_merge_request, project: project, noteable: merge_request, note: "Almost done")]) } let(:discussion) { Discussion.new([create(:diff_note_on_merge_request, project: project, noteable: merge_request, note: "Almost done")]) }
let(:service) { described_class.new(project, user, merge_request_for_resolving_discussions: merge_request.iid, discussion_to_resolve: discussion.id) } let(:service) { described_class.new(project, user, merge_request_to_resolve_discussions_of: merge_request.iid, discussion_to_resolve: discussion.id) }
it 'references the noteable title in the issue title' do it 'references the noteable title in the issue title' do
issue = service.execute issue = service.execute
...@@ -30,12 +30,12 @@ describe Issues::BuildService, services: true do ...@@ -30,12 +30,12 @@ describe Issues::BuildService, services: true do
context 'for discussions in a merge request' do context 'for discussions in a merge request' do
let(:merge_request) { create(:merge_request_with_diff_notes, source_project: project) } let(:merge_request) { create(:merge_request_with_diff_notes, source_project: project) }
let(:issue) { described_class.new(project, user, merge_request_for_resolving_discussions: merge_request.iid).execute } let(:issue) { described_class.new(project, user, merge_request_to_resolve_discussions_of: merge_request.iid).execute }
describe '#items_for_discussions' do describe '#items_for_discussions' do
it 'has an item for each discussion' do it 'has an item for each discussion' do
create(:diff_note_on_merge_request, noteable: merge_request, project: merge_request.source_project, line_number: 13) create(:diff_note_on_merge_request, noteable: merge_request, project: merge_request.source_project, line_number: 13)
service = described_class.new(project, user, merge_request_for_resolving_discussions: merge_request.iid) service = described_class.new(project, user, merge_request_to_resolve_discussions_of: merge_request.iid)
service.execute service.execute
...@@ -44,7 +44,7 @@ describe Issues::BuildService, services: true do ...@@ -44,7 +44,7 @@ describe Issues::BuildService, services: true do
end end
describe '#item_for_discussion' do describe '#item_for_discussion' do
let(:service) { described_class.new(project, user, merge_request_for_resolving_discussions: merge_request.iid) } let(:service) { described_class.new(project, user, merge_request_to_resolve_discussions_of: merge_request.iid) }
it 'mentions the author of the note' do it 'mentions the author of the note' do
discussion = Discussion.new([create(:diff_note_on_merge_request, author: create(:user, username: 'author'))]) discussion = Discussion.new([create(:diff_note_on_merge_request, author: create(:user, username: 'author'))])
...@@ -76,7 +76,7 @@ describe Issues::BuildService, services: true do ...@@ -76,7 +76,7 @@ describe Issues::BuildService, services: true do
it 'does not assign title when a title was given' do it 'does not assign title when a title was given' do
issue = described_class.new(project, user, issue = described_class.new(project, user,
merge_request_for_resolving_discussions: merge_request, merge_request_to_resolve_discussions_of: merge_request,
title: 'What an issue').execute title: 'What an issue').execute
expect(issue.title).to eq('What an issue') expect(issue.title).to eq('What an issue')
...@@ -84,7 +84,7 @@ describe Issues::BuildService, services: true do ...@@ -84,7 +84,7 @@ describe Issues::BuildService, services: true do
it 'does not assign description when a description was given' do it 'does not assign description when a description was given' do
issue = described_class.new(project, user, issue = described_class.new(project, user,
merge_request_for_resolving_discussions: merge_request, merge_request_to_resolve_discussions_of: merge_request,
description: 'Fix at your earliest conveignance').execute description: 'Fix at your earliest conveignance').execute
expect(issue.description).to eq('Fix at your earliest conveignance') expect(issue.description).to eq('Fix at your earliest conveignance')
...@@ -122,7 +122,7 @@ describe Issues::BuildService, services: true do ...@@ -122,7 +122,7 @@ describe Issues::BuildService, services: true do
describe '#execute' do describe '#execute' do
it 'mentions the merge request in the description' do it 'mentions the merge request in the description' do
issue = described_class.new(project, user, merge_request_for_resolving_discussions: merge_request.iid).execute issue = described_class.new(project, user, merge_request_to_resolve_discussions_of: merge_request.iid).execute
expect(issue.description).to include("Review the conversation in #{merge_request.to_reference}") expect(issue.description).to include("Review the conversation in #{merge_request.to_reference}")
end end
......
...@@ -150,7 +150,7 @@ describe Issues::CreateService, services: true do ...@@ -150,7 +150,7 @@ describe Issues::CreateService, services: true do
end end
describe 'for a single discussion' do describe 'for a single discussion' do
let(:opts) { { discussion_to_resolve: discussion.id, merge_request_for_resolving_discussions: merge_request.iid } } let(:opts) { { discussion_to_resolve: discussion.id, merge_request_to_resolve_discussions_of: merge_request.iid } }
it 'resolves the discussion' do it 'resolves the discussion' do
described_class.new(project, user, opts).execute described_class.new(project, user, opts).execute
...@@ -176,7 +176,7 @@ describe Issues::CreateService, services: true do ...@@ -176,7 +176,7 @@ describe Issues::CreateService, services: true do
it 'can set nil explicitly to the title and description' do it 'can set nil explicitly to the title and description' do
issue = described_class.new(project, user, issue = described_class.new(project, user,
merge_request_for_resolving_discussions: merge_request, merge_request_to_resolve_discussions_of: merge_request,
description: nil, description: nil,
title: nil).execute title: nil).execute
...@@ -186,7 +186,7 @@ describe Issues::CreateService, services: true do ...@@ -186,7 +186,7 @@ describe Issues::CreateService, services: true do
end end
describe 'for a merge request' do describe 'for a merge request' do
let(:opts) { { merge_request_for_resolving_discussions: merge_request.iid } } let(:opts) { { merge_request_to_resolve_discussions_of: merge_request.iid } }
it 'resolves the discussion' do it 'resolves the discussion' do
described_class.new(project, user, opts).execute described_class.new(project, user, opts).execute
...@@ -212,7 +212,7 @@ describe Issues::CreateService, services: true do ...@@ -212,7 +212,7 @@ describe Issues::CreateService, services: true do
it 'can set nil explicitly to the title and description' do it 'can set nil explicitly to the title and description' do
issue = described_class.new(project, user, issue = described_class.new(project, user,
merge_request_for_resolving_discussions: merge_request, merge_request_to_resolve_discussions_of: merge_request,
description: nil, description: nil,
title: nil).execute title: nil).execute
......
...@@ -23,10 +23,10 @@ describe DummyService, services: true do ...@@ -23,10 +23,10 @@ describe DummyService, services: true do
let(:other_merge_request) { create(:merge_request, source_project: project, source_branch: "other") } let(:other_merge_request) { create(:merge_request, source_project: project, source_branch: "other") }
describe "#merge_request_for_resolving_discussion" do describe "#merge_request_for_resolving_discussion" do
let(:service) { described_class.new(project, user, merge_request_for_resolving_discussions: merge_request.iid) } let(:service) { described_class.new(project, user, merge_request_to_resolve_discussions_of: merge_request.iid) }
it "finds the merge request" do it "finds the merge request" do
expect(service.merge_request_for_resolving_discussions).to eq(merge_request) expect(service.merge_request_to_resolve_discussions_of).to eq(merge_request)
end end
it "only queries for the merge request once" do it "only queries for the merge request once" do
...@@ -37,7 +37,7 @@ describe DummyService, services: true do ...@@ -37,7 +37,7 @@ describe DummyService, services: true do
expect(fake_results).to receive(:find_by).exactly(1) expect(fake_results).to receive(:find_by).exactly(1)
expect(MergeRequestsFinder).to receive(:new).and_return(fake_finder).exactly(1) expect(MergeRequestsFinder).to receive(:new).and_return(fake_finder).exactly(1)
2.times { service.merge_request_for_resolving_discussions } 2.times { service.merge_request_to_resolve_discussions_of }
end end
end end
...@@ -47,7 +47,7 @@ describe DummyService, services: true do ...@@ -47,7 +47,7 @@ describe DummyService, services: true do
project, project,
user, user,
discussion_to_resolve: discussion.id, discussion_to_resolve: discussion.id,
merge_request_for_resolving_discussions: merge_request.iid merge_request_to_resolve_discussions_of: merge_request.iid
) )
# We need to compare discussion id's because the Discussion-objects are rebuilt # We need to compare discussion id's because the Discussion-objects are rebuilt
# which causes the object-id's not to be different. # which causes the object-id's not to be different.
...@@ -64,7 +64,7 @@ describe DummyService, services: true do ...@@ -64,7 +64,7 @@ describe DummyService, services: true do
service = described_class.new( service = described_class.new(
project, project,
user, user,
merge_request_for_resolving_discussions: merge_request.iid merge_request_to_resolve_discussions_of: merge_request.iid
) )
# We need to compare discussion id's because the Discussion-objects are rebuilt # We need to compare discussion id's because the Discussion-objects are rebuilt
# which causes the object-id's not to be different. # which causes the object-id's not to be different.
...@@ -82,7 +82,7 @@ describe DummyService, services: true do ...@@ -82,7 +82,7 @@ describe DummyService, services: true do
service = described_class.new( service = described_class.new(
project, project,
user, user,
merge_request_for_resolving_discussions: merge_request.iid merge_request_to_resolve_discussions_of: merge_request.iid
) )
# We need to compare discussion id's because the Discussion-objects are rebuilt # We need to compare discussion id's because the Discussion-objects are rebuilt
# which causes the object-id's not to be different. # which causes the object-id's not to be different.
...@@ -96,7 +96,7 @@ describe DummyService, services: true do ...@@ -96,7 +96,7 @@ describe DummyService, services: true do
project, project,
user, user,
discussion_to_resolve: discussion.id, discussion_to_resolve: discussion.id,
merge_request_for_resolving_discussions: other_merge_request.iid merge_request_to_resolve_discussions_of: other_merge_request.iid
) )
expect(service.discussions_to_resolve).to be_empty expect(service.discussions_to_resolve).to be_empty
......
...@@ -34,7 +34,7 @@ shared_examples 'creating an issue for a discussion' do ...@@ -34,7 +34,7 @@ shared_examples 'creating an issue for a discussion' do
end end
it 'has a hidden field for the merge request' do it 'has a hidden field for the merge request' do
merge_request_field = find('#merge_request_for_resolving_discussions', visible: false) merge_request_field = find('#merge_request_to_resolve_discussions_of', visible: false)
expect(merge_request_field.value).to eq(merge_request.iid.to_s) expect(merge_request_field.value).to eq(merge_request.iid.to_s)
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