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

Show correct message when user cannot resolve discussions

parent 40dd9937
...@@ -58,9 +58,12 @@ ...@@ -58,9 +58,12 @@
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_for_resolving_discussions, @discussion_to_resolve)
- else - else
The discussion at 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_for_resolving_discussions, @discussion_to_resolve)
will stay unresolved. Ask someone with permission to resolve it. will stay unresolved. Ask someone with permission to resolve
= @discussion_to_resolve ? 'it.' : 'them.'
- is_footer = !(issuable.is_a?(MergeRequest) && issuable.new_record?) - is_footer = !(issuable.is_a?(MergeRequest) && issuable.new_record?)
.row-content-block{ class: (is_footer ? "footer-block" : "middle-block") } .row-content-block{ class: (is_footer ? "footer-block" : "middle-block") }
......
...@@ -6,74 +6,88 @@ feature 'Resolving all open discussions in a merge request from an issue', featu ...@@ -6,74 +6,88 @@ feature 'Resolving all open discussions in a merge request from an issue', featu
let(:merge_request) { create(:merge_request, source_project: project) } let(:merge_request) { create(:merge_request, source_project: project) }
let!(:discussion) { Discussion.for_diff_notes([create(:diff_note_on_merge_request, noteable: merge_request, project: project)]).first } let!(:discussion) { Discussion.for_diff_notes([create(:diff_note_on_merge_request, noteable: merge_request, project: project)]).first }
before do describe 'as a user with access to the project' do
project.team << [user, :master]
login_as user
visit namespace_project_merge_request_path(project.namespace, project, merge_request)
end
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)
end
end
context 'resolving the discussion' do
before do before do
click_button 'Resolve discussion' project.team << [user, :master]
end login_as user
visit namespace_project_merge_request_path(project.namespace, project, merge_request)
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)
end end
end
context 'creating an issue for discussions' do it 'shows a button to resolve all discussions by creating a new issue' do
before do within('li#resolve-count-app') 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) 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)
end
end end
it_behaves_like 'creating an issue for a discussion' context 'resolving the discussion' do
end before do
click_button 'Resolve discussion'
end
context 'for a project where all discussions need to be resolved before merging' do it 'hides the link for creating a new issue' do
before 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)
project.update_attribute(:only_allow_merge_if_all_discussions_are_resolved, true) end
end end
context 'with the internal tracker disabled' do context 'creating an issue for discussions' do
before do before do
project.project_feature.update_attribute(:issues_access_level, ProjectFeature::DISABLED) 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)
visit namespace_project_merge_request_path(project.namespace, project, merge_request)
end end
it 'does not show a link to create a new issue' do it_behaves_like 'creating an issue for a discussion'
expect(page).not_to have_link 'open an issue to resolve them later'
end
end end
context 'merge request has discussions that need to be resolved' do context 'for a project where all discussions need to be resolved before merging' do
before do before do
visit namespace_project_merge_request_path(project.namespace, project, merge_request) project.update_attribute(:only_allow_merge_if_all_discussions_are_resolved, true)
end end
it 'shows a warning that the merge request contains unresolved discussions' do context 'with the internal tracker disabled' do
expect(page).to have_content 'This merge request has unresolved discussions' before do
end project.project_feature.update_attribute(:issues_access_level, ProjectFeature::DISABLED)
visit namespace_project_merge_request_path(project.namespace, project, merge_request)
end
it 'has a link to resolve all discussions by creating an issue' do it 'does not show a link to create a new issue' do
page.within '.mr-widget-body' do expect(page).not_to have_link 'open an issue to resolve them later'
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)
end end
end end
context 'creating an issue for discussions' do context 'merge request has discussions that need to be resolved' 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) visit namespace_project_merge_request_path(project.namespace, project, merge_request)
end
it 'shows a warning that the merge request contains unresolved discussions' do
expect(page).to have_content 'This merge request has unresolved discussions'
end
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)
end
end end
it_behaves_like 'creating an issue for a discussion' 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)
end
it_behaves_like 'creating an issue for a discussion'
end
end end
end end
end end
describe 'as a reporter' do
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)
end
it 'Shows a notice to ask someone else to resolve the discussions' do
expect(page).to have_content("The discussions at #{merge_request.to_reference} will stay unresolved. Ask someone with permission to resolve them.")
end
end
end end
...@@ -6,58 +6,76 @@ feature 'Resolve an open discussion in a merge request by creating an issue', fe ...@@ -6,58 +6,76 @@ feature 'Resolve an open discussion in a merge request by creating an issue', fe
let(:merge_request) { create(:merge_request, source_project: project) } let(:merge_request) { create(:merge_request, source_project: project) }
let!(:discussion) { Discussion.for_diff_notes([create(:diff_note_on_merge_request, noteable: merge_request, project: project)]).first } let!(:discussion) { Discussion.for_diff_notes([create(:diff_note_on_merge_request, noteable: merge_request, project: project)]).first }
before do describe 'As a user with access to the project' do
project.team << [user, :master]
login_as user
visit namespace_project_merge_request_path(project.namespace, project, merge_request)
end
context 'with the internal tracker disabled' do
before do before do
project.project_feature.update_attribute(:issues_access_level, ProjectFeature::DISABLED) project.team << [user, :master]
login_as user
visit namespace_project_merge_request_path(project.namespace, project, merge_request) visit namespace_project_merge_request_path(project.namespace, project, merge_request)
end end
it 'does not show a link to create a new issue' do context 'with the internal tracker disabled' do
expect(page).not_to have_link 'Resolve this discussion in a new issue' before do
project.project_feature.update_attribute(:issues_access_level, ProjectFeature::DISABLED)
visit namespace_project_merge_request_path(project.namespace, project, merge_request)
end
it 'does not show a link to create a new issue' do
expect(page).not_to have_link 'Resolve this discussion in a new issue'
end
end end
end
context 'resolving the discussion', js: true do context 'resolving the discussion', js: true do
before do before do
click_button 'Resolve discussion' click_button 'Resolve discussion'
end
it 'hides the link for creating a new issue' do
expect(page).not_to have_link 'Resolve this discussion in a new issue'
end
it 'shows the link for creating a new issue when unresolving a discussion' do
page.within '.diff-content' do
click_button 'Unresolve discussion'
end
expect(page).to have_link 'Resolve this discussion in a new issue'
end
end end
it 'hides the link for creating a new issue' do it 'has a link to create a new issue for a discussion' do
expect(page).not_to have_link 'Resolve this discussion in a new issue' new_issue_link = new_namespace_project_issue_path(project.namespace, project, discussion_to_resolve: discussion.id, merge_request_for_resolving_discussions: merge_request.iid)
expect(page).to have_link 'Resolve this discussion in a new issue', href: new_issue_link
end end
it 'shows the link for creating a new issue when unresolving a discussion' do context 'creating the issue' do
page.within '.diff-content' do before do
click_button 'Unresolve discussion' 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)
end end
expect(page).to have_link 'Resolve this discussion in a new issue' it 'has a hidden field for the discussion' do
end discussion_field = find('#discussion_to_resolve', visible: false)
end
it 'has a link to create a new issue for a discussion' do expect(discussion_field.value).to eq(discussion.id.to_s)
new_issue_link = new_namespace_project_issue_path(project.namespace, project, discussion_to_resolve: discussion.id, merge_request_for_resolving_discussions: merge_request.iid) end
expect(page).to have_link 'Resolve this discussion in a new issue', href: new_issue_link it_behaves_like 'creating an issue for a discussion'
end
end end
context 'creating the issue' do describe 'as a reporter' 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) project.team << [user, :reporter]
login_as user
visit new_namespace_project_issue_path(project.namespace, project,
merge_request_for_resolving_discussions: merge_request.iid,
discussion_to_resolve: discussion.id)
end end
it 'has a hidden field for the discussion' do it 'Shows a notice to ask someone else to resolve the discussions' do
discussion_field = find('#discussion_to_resolve', visible: false) expect(page).to have_content("The discussion at #{merge_request.to_reference}"\
"(discussion #{discussion.first_note.id}) will stay unresolved."\
expect(discussion_field.value).to eq(discussion.id.to_s) "Ask someone with permission to resolve it.")
end end
it_behaves_like 'creating an issue for a discussion'
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