diff options
author | Bob Van Landuyt <bob@vanlanduyt.co> | 2017-02-27 16:01:56 +0100 |
---|---|---|
committer | Bob Van Landuyt <bob@gitlab.com> | 2017-03-13 08:27:51 +0100 |
commit | d6453e75b7100ee94c3d125d21627961adcaa8cc (patch) | |
tree | 08e0f7f1604d156b5fdfcf059f16317137784c74 /spec/features/issues | |
parent | f86928953d2d79f40f10813a6e244c1da0779d16 (diff) | |
download | gitlab-ce-d6453e75b7100ee94c3d125d21627961adcaa8cc.tar.gz |
Add a button to delegate all discussions in a merge request
Diffstat (limited to 'spec/features/issues')
-rw-r--r-- | spec/features/issues/create_issue_for_discussions_in_merge_request_spec.rb | 65 |
1 files changed, 45 insertions, 20 deletions
diff --git a/spec/features/issues/create_issue_for_discussions_in_merge_request_spec.rb b/spec/features/issues/create_issue_for_discussions_in_merge_request_spec.rb index 62ecd0100ae..4751b16013d 100644 --- a/spec/features/issues/create_issue_for_discussions_in_merge_request_spec.rb +++ b/spec/features/issues/create_issue_for_discussions_in_merge_request_spec.rb @@ -1,54 +1,79 @@ require 'rails_helper' -feature 'Resolving all open discussions in a merge request from an issue', feature: true do +feature 'Resolving all open discussions in a merge request from an issue', feature: true, js: true do let(:user) { create(:user) } - let(:project) { create(:project, only_allow_merge_if_all_discussions_are_resolved: true) } + let(:project) { create(: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 } before 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 + 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 - project.project_feature.update_attribute(:issues_access_level, ProjectFeature::DISABLED) - visit namespace_project_merge_request_path(project.namespace, project, merge_request) + click_button 'Resolve discussion' end - it 'does not show a link to create a new issue' do - expect(page).not_to have_link 'open an issue to resolve them later' + 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 - context 'merge request has discussions that need to be resolved' do + context 'creating an issue for discussions' do before do - visit namespace_project_merge_request_path(project.namespace, project, merge_request) + 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) end - it 'shows a warning that the merge request contains unresolved discussions' do - expect(page).to have_content 'This merge request has unresolved discussions' + it_behaves_like 'creating an issue for a discussion' + end + + context 'for a project where all discussions need to be resolved before merging' do + before do + project.update_attribute(:only_allow_merge_if_all_discussions_are_resolved, true) 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) + context 'with the internal tracker disabled' do + 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 'open an issue to resolve them later' end end - context 'creating an issue for discussions' do + context 'merge request has discussions that need to be resolved' 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 'has a hidden field for the discussion' do - merge_request_field = find('#merge_request_for_resolving_discussions', visible: false) + it 'shows a warning that the merge request contains unresolved discussions' do + expect(page).to have_content 'This merge request has unresolved discussions' + end - expect(merge_request_field.value).to eq(merge_request.iid.to_s) + 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 - 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 |