Extract remove due date spec to shared example
This commit is contained in:
parent
1ddd9eff6d
commit
08e2bc390f
2 changed files with 27 additions and 34 deletions
|
@ -43,7 +43,7 @@ describe 'Issues > User uses quick actions', :js do
|
||||||
describe 'issue-only commands' do
|
describe 'issue-only commands' do
|
||||||
let(:user) { create(:user) }
|
let(:user) { create(:user) }
|
||||||
let(:project) { create(:project, :public) }
|
let(:project) { create(:project, :public) }
|
||||||
let(:issue) { create(:issue, project: project) }
|
let(:issue) { create(:issue, project: project, due_date: Date.new(2016, 8, 28)) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
project.add_maintainer(user)
|
project.add_maintainer(user)
|
||||||
|
@ -57,6 +57,7 @@ describe 'Issues > User uses quick actions', :js do
|
||||||
end
|
end
|
||||||
|
|
||||||
it_behaves_like 'confidential quick action'
|
it_behaves_like 'confidential quick action'
|
||||||
|
it_behaves_like 'remove_due_date quick action'
|
||||||
|
|
||||||
describe 'adding a due date from note' do
|
describe 'adding a due date from note' do
|
||||||
let(:issue) { create(:issue, project: project) }
|
let(:issue) { create(:issue, project: project) }
|
||||||
|
@ -76,24 +77,6 @@ describe 'Issues > User uses quick actions', :js do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'removing a due date from note' do
|
|
||||||
let(:issue) { create(:issue, project: project, due_date: Date.new(2016, 8, 28)) }
|
|
||||||
|
|
||||||
it_behaves_like 'remove_due_date action available and due date can be removed'
|
|
||||||
|
|
||||||
context 'when the current user cannot update the due date' do
|
|
||||||
let(:guest) { create(:user) }
|
|
||||||
before do
|
|
||||||
project.add_guest(guest)
|
|
||||||
gitlab_sign_out
|
|
||||||
sign_in(guest)
|
|
||||||
visit project_issue_path(project, issue)
|
|
||||||
end
|
|
||||||
|
|
||||||
it_behaves_like 'remove_due_date action not available'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'toggling the WIP prefix from the title from note' do
|
describe 'toggling the WIP prefix from the title from note' do
|
||||||
let(:issue) { create(:issue, project: project) }
|
let(:issue) { create(:issue, project: project) }
|
||||||
|
|
||||||
|
|
|
@ -1,25 +1,35 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
shared_examples 'remove_due_date action not available' do
|
shared_examples 'remove_due_date quick action' do
|
||||||
it 'does not remove the due date' do
|
context 'remove_due_date action available and due date can be removed' do
|
||||||
add_note("/remove_due_date")
|
it 'removes the due date accordingly' do
|
||||||
|
add_note('/remove_due_date')
|
||||||
|
|
||||||
expect(page).not_to have_content 'Commands applied'
|
expect(page).not_to have_content '/remove_due_date'
|
||||||
expect(page).not_to have_content '/remove_due_date'
|
expect(page).to have_content 'Commands applied'
|
||||||
|
|
||||||
|
visit project_issue_path(project, issue)
|
||||||
|
|
||||||
|
page.within '.due_date' do
|
||||||
|
expect(page).to have_content 'No due date'
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
shared_examples 'remove_due_date action available and due date can be removed' do
|
context 'remove_due_date action not available' do
|
||||||
it 'removes the due date accordingly' do
|
let(:guest) { create(:user) }
|
||||||
add_note('/remove_due_date')
|
before do
|
||||||
|
project.add_guest(guest)
|
||||||
|
gitlab_sign_out
|
||||||
|
sign_in(guest)
|
||||||
|
visit project_issue_path(project, issue)
|
||||||
|
end
|
||||||
|
|
||||||
expect(page).not_to have_content '/remove_due_date'
|
it 'does not remove the due date' do
|
||||||
expect(page).to have_content 'Commands applied'
|
add_note("/remove_due_date")
|
||||||
|
|
||||||
visit project_issue_path(project, issue)
|
expect(page).not_to have_content 'Commands applied'
|
||||||
|
expect(page).not_to have_content '/remove_due_date'
|
||||||
page.within '.due_date' do
|
|
||||||
expect(page).to have_content 'No due date'
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue