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 @@ def new
assignee_id: ""
)
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]
)
service = Issues::BuildService.new(project, current_user, build_params)
@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]
respond_with(@issue)
......@@ -102,7 +102,7 @@ def show
def create
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]
)
......@@ -248,7 +248,6 @@ def redirect_old
def issue_params
params.require(:issue).permit(
: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: []
)
end
......
......@@ -8,23 +8,23 @@ def execute
end
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 }
end
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
def description_for_discussions
if discussions_to_resolve.empty?
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
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:"
[description, *items_for_discussions].join("\n\n")
......
......@@ -29,7 +29,7 @@ def resolve_discussions_with_issue(issue)
return if discussions_to_resolve.empty?
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).
execute(discussions_to_resolve)
end
......
module Issues
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
@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)
end
def merge_request_for_resolving_discussions
return @merge_request_for_resolving_discussions if defined?(@merge_request_for_resolving_discussions)
def merge_request_to_resolve_discussions_of
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.
find_by(iid: merge_request_for_resolving_discussions_iid)
find_by(iid: merge_request_to_resolve_discussions_of_iid)
end
def discussions_to_resolve
return [] unless merge_request_for_resolving_discussions
return [] unless merge_request_to_resolve_discussions_of
@discussions_to_resolve ||=
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)
Array(discussion_or_nil)
else
merge_request_for_resolving_discussions
merge_request_to_resolve_discussions_of
.resolvable_discussions
end
end
......
......@@ -3,4 +3,4 @@
.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",
"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 @@
.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",
"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]
= 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])
......@@ -6,5 +6,5 @@
Please resolve these discussions
- if @project.issues_enabled? && can?(current_user, :create_issue, @project)
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.
......@@ -45,23 +45,23 @@
= render 'shared/issuable/form/merge_params', issuable: issuable
- if @merge_request_for_resolving_discussions
- if @merge_request_to_resolve_discussions_of
.form-group
.col-sm-10.col-sm-offset-2
= icon('info-circle')
- if @merge_request_for_resolving_discussions.discussions_can_be_resolved_by?(current_user)
= hidden_field_tag 'merge_request_for_resolving_discussions', @merge_request_for_resolving_discussions.iid
- if @merge_request_to_resolve_discussions_of.discussions_can_be_resolved_by?(current_user)
= hidden_field_tag 'merge_request_to_resolve_discussions_of', @merge_request_to_resolve_discussions_of.iid
- if @discussion_to_resolve
= hidden_field_tag 'discussion_to_resolve', @discussion_to_resolve.id
Creating this issue will resolve the discussion in
- else
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
The
= @discussion_to_resolve ? 'discussion' : 'discussions'
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
= @discussion_to_resolve ? 'it.' : 'them.'
......
......@@ -340,8 +340,8 @@ POST /projects/:id/issues
| `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) |
| `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. |
| `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`. |
| `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_to_resolve_discussions_of`. |
```bash
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 @@ def find_issues(args = {})
requires :title, type: String, desc: 'The title of an issue'
optional :created_at, type: DateTime,
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'
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
end
post ':id/issues' do
......
......@@ -104,7 +104,7 @@
project_with_repository.team << [user, :developer]
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).description).not_to be_empty
......@@ -113,7 +113,7 @@
it 'fills in an issue for a discussion' do
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).description).not_to be_empty
......@@ -471,11 +471,11 @@ def post_new_issue(issue_attrs = {}, additional_params = {})
end
let(:merge_request_params) do
{ merge_request_for_resolving_discussions: merge_request.iid }
{ merge_request_to_resolve_discussions_of: merge_request.iid }
end
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
it 'creates an issue for the project' do
......
......@@ -15,7 +15,7 @@
it 'shows a button to resolve all discussions by creating a new issue' 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
......@@ -25,13 +25,13 @@
end
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
context 'creating an issue for discussions' 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
it_behaves_like 'creating an issue for a discussion'
......@@ -64,13 +64,13 @@
it 'has a link to resolve all discussions by creating an issue' 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
context 'creating an issue for discussions' 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
it_behaves_like 'creating an issue for a discussion'
......@@ -83,7 +83,7 @@
before do
project.team << [user, :reporter]
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
it 'Shows a notice to ask someone else to resolve the discussions' do
......
......@@ -43,14 +43,14 @@
end
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
end
context 'creating the issue' 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
it 'has a hidden field for the discussion' do
......@@ -68,7 +68,7 @@
project.team << [user, :reporter]
login_as user
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)
end
......
......@@ -941,7 +941,7 @@
before do
post api("/projects/#{project.id}/issues", user),
title: 'New Issue',
merge_request_for_resolving_discussions: merge_request.iid
merge_request_to_resolve_discussions_of: merge_request.iid
end
it_behaves_like 'creating an issue resolving discussions through the API'
......@@ -951,7 +951,7 @@
before do
post api("/projects/#{project.id}/issues", user),
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
end
......
......@@ -12,7 +12,7 @@
describe '#execute' do
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(: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
issue = service.execute
......@@ -30,12 +30,12 @@
context 'for discussions in a merge request' do
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
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)
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
......@@ -44,7 +44,7 @@
end
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
discussion = Discussion.new([create(:diff_note_on_merge_request, author: create(:user, username: 'author'))])
......@@ -76,7 +76,7 @@
it 'does not assign title when a title was given' do
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
expect(issue.title).to eq('What an issue')
......@@ -84,7 +84,7 @@
it 'does not assign description when a description was given' do
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
expect(issue.description).to eq('Fix at your earliest conveignance')
......@@ -122,7 +122,7 @@
describe '#execute' 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}")
end
......
......@@ -150,7 +150,7 @@
end
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
described_class.new(project, user, opts).execute
......@@ -176,7 +176,7 @@
it 'can set nil explicitly to the title and description' do
issue = described_class.new(project, user,
merge_request_for_resolving_discussions: merge_request,
merge_request_to_resolve_discussions_of: merge_request,
description: nil,
title: nil).execute
......@@ -186,7 +186,7 @@
end
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
described_class.new(project, user, opts).execute
......@@ -212,7 +212,7 @@
it 'can set nil explicitly to the title and description' do
issue = described_class.new(project, user,
merge_request_for_resolving_discussions: merge_request,
merge_request_to_resolve_discussions_of: merge_request,
description: nil,
title: nil).execute
......
......@@ -23,10 +23,10 @@ def initialize(*args)
let(:other_merge_request) { create(:merge_request, source_project: project, source_branch: "other") }
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
expect(service.merge_request_for_resolving_discussions).to eq(merge_request)
expect(service.merge_request_to_resolve_discussions_of).to eq(merge_request)
end
it "only queries for the merge request once" do
......@@ -37,7 +37,7 @@ def initialize(*args)
expect(fake_results).to receive(:find_by).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
......@@ -47,7 +47,7 @@ def initialize(*args)
project,
user,
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
# which causes the object-id's not to be different.
......@@ -64,7 +64,7 @@ def initialize(*args)
service = described_class.new(
project,
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
# which causes the object-id's not to be different.
......@@ -82,7 +82,7 @@ def initialize(*args)
service = described_class.new(
project,
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
# which causes the object-id's not to be different.
......@@ -96,7 +96,7 @@ def initialize(*args)
project,
user,
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
......
......@@ -34,7 +34,7 @@
end
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)
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