Commit f26308d3 authored by Michel Engelen's avatar Michel Engelen Committed by Michel Engelen

updated tests for !29553

parent 69067552
require 'rails_helper' require 'rails_helper'
describe 'Resolving all open discussions in a merge request from an issue', :js do describe 'Resolving all open threads in a merge request from an issue', :js do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:project, :repository) } let(:project) { create(:project, :repository) }
let(:merge_request) { create(:merge_request, source_project: project) } let(:merge_request) { create(:merge_request, source_project: project) }
let!(:discussion) { create(:diff_note_on_merge_request, noteable: merge_request, project: project).to_discussion } let!(:discussion) { create(:diff_note_on_merge_request, noteable: merge_request, project: project).to_discussion }
def resolve_all_discussions_link_selector def resolve_all_discussions_link_selector
text = "Resolve all discussions in new issue" text = "Resolve all threads in new issue"
url = new_project_issue_path(project, merge_request_to_resolve_discussions_of: merge_request.iid) url = new_project_issue_path(project, merge_request_to_resolve_discussions_of: merge_request.iid)
%Q{a[data-original-title="#{text}"][href="#{url}"]} %Q{a[data-original-title="#{text}"][href="#{url}"]}
end end
...@@ -19,15 +19,15 @@ describe 'Resolving all open discussions in a merge request from an issue', :js ...@@ -19,15 +19,15 @@ describe 'Resolving all open discussions in a merge request from an issue', :js
visit project_merge_request_path(project, merge_request) visit project_merge_request_path(project, merge_request)
end end
it 'shows a button to resolve all discussions by creating a new issue' do it 'shows a button to resolve all threads by creating a new issue' do
within('.line-resolve-all-container') do within('.line-resolve-all-container') do
expect(page).to have_selector resolve_all_discussions_link_selector expect(page).to have_selector resolve_all_discussions_link_selector
end end
end end
context 'resolving the discussion' do context 'resolving the thread' do
before do before do
click_button 'Resolve discussion' click_button 'Resolve thread'
end end
it 'hides the link for creating a new issue' do it 'hides the link for creating a new issue' do
...@@ -35,15 +35,15 @@ describe 'Resolving all open discussions in a merge request from an issue', :js ...@@ -35,15 +35,15 @@ describe 'Resolving all open discussions in a merge request from an issue', :js
end end
end end
context 'creating an issue for discussions' do context 'creating an issue for threads' do
before do before do
find(resolve_all_discussions_link_selector).click find(resolve_all_discussions_link_selector).click
end end
it_behaves_like 'creating an issue for a discussion' it_behaves_like 'creating an issue for a thread'
end end
context 'for a project where all discussions need to be resolved before merging' do context 'for a project where all threads need to be resolved before merging' do
before do before do
project.update_attribute(:only_allow_merge_if_all_discussions_are_resolved, true) project.update_attribute(:only_allow_merge_if_all_discussions_are_resolved, true)
end end
...@@ -59,27 +59,27 @@ describe 'Resolving all open discussions in a merge request from an issue', :js ...@@ -59,27 +59,27 @@ describe 'Resolving all open discussions in a merge request from an issue', :js
end end
end end
context 'merge request has discussions that need to be resolved' do context 'merge request has threads that need to be resolved' do
before do before do
visit project_merge_request_path(project, merge_request) visit project_merge_request_path(project, merge_request)
end end
it 'shows a warning that the merge request contains unresolved discussions' do it 'shows a warning that the merge request contains unresolved threads' do
expect(page).to have_content 'There are unresolved discussions.' expect(page).to have_content 'There are unresolved threads.'
end end
it 'has a link to resolve all discussions by creating an issue' do it 'has a link to resolve all threads by creating an issue' do
page.within '.mr-widget-body' do page.within '.mr-widget-body' do
expect(page).to have_link 'Create an issue to resolve them later', href: new_project_issue_path(project, merge_request_to_resolve_discussions_of: merge_request.iid) expect(page).to have_link 'Create an issue to resolve them later', href: new_project_issue_path(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 threads' do
before do before do
page.click_link 'Create an issue to resolve them later', href: new_project_issue_path(project, merge_request_to_resolve_discussions_of: merge_request.iid) page.click_link 'Create an issue to resolve them later', href: new_project_issue_path(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 thread'
end end
end end
end end
...@@ -92,8 +92,8 @@ describe 'Resolving all open discussions in a merge request from an issue', :js ...@@ -92,8 +92,8 @@ describe 'Resolving all open discussions in a merge request from an issue', :js
visit new_project_issue_path(project, merge_request_to_resolve_discussions_of: merge_request.iid) visit new_project_issue_path(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 threads' do
expect(page).to have_content("The discussions at #{merge_request.to_reference} will stay unresolved. Ask someone with permission to resolve them.") expect(page).to have_content("The threads at #{merge_request.to_reference} will stay unresolved. Ask someone with permission to resolve them.")
end 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