diff options
Diffstat (limited to 'spec/features/issues/issue_detail_spec.rb')
-rw-r--r-- | spec/features/issues/issue_detail_spec.rb | 64 |
1 files changed, 51 insertions, 13 deletions
diff --git a/spec/features/issues/issue_detail_spec.rb b/spec/features/issues/issue_detail_spec.rb index 531c3634b5e..b37c8e9d1cf 100644 --- a/spec/features/issues/issue_detail_spec.rb +++ b/spec/features/issues/issue_detail_spec.rb @@ -3,8 +3,9 @@ require 'spec_helper' RSpec.describe 'Issue Detail', :js do + let_it_be_with_refind(:project) { create(:project, :public) } + let(:user) { create(:user) } - let(:project) { create(:project, :public) } let(:issue) { create(:issue, project: project, author: user) } let(:incident) { create(:incident, project: project, author: user) } @@ -90,7 +91,13 @@ RSpec.describe 'Issue Detail', :js do end describe 'user updates `issue_type` via the issue type dropdown' do - context 'when an issue `issue_type` is edited by a signed in user' do + let_it_be(:reporter) { create(:user) } + + before_all do + project.add_reporter(reporter) + end + + describe 'when an issue `issue_type` is edited' do before do sign_in(user) @@ -98,18 +105,33 @@ RSpec.describe 'Issue Detail', :js do wait_for_requests end - it 'routes the user to the incident details page when the `issue_type` is set to incident' do - open_issue_edit_form + context 'by non-member author' do + it 'cannot see Incident option' do + open_issue_edit_form + + page.within('[data-testid="issuable-form"]') do + expect(page).to have_content('Issue') + expect(page).not_to have_content('Incident') + end + end + end + + context 'by reporter' do + let(:user) { reporter } - page.within('[data-testid="issuable-form"]') do - update_type_select('Issue', 'Incident') + it 'routes the user to the incident details page when the `issue_type` is set to incident' do + open_issue_edit_form - expect(page).to have_current_path(project_issues_incident_path(project, issue)) + page.within('[data-testid="issuable-form"]') do + update_type_select('Issue', 'Incident') + + expect(page).to have_current_path(project_issues_incident_path(project, issue)) + end end end end - context 'when an incident `issue_type` is edited by a signed in user' do + describe 'when an incident `issue_type` is edited' do before do sign_in(user) @@ -117,13 +139,29 @@ RSpec.describe 'Issue Detail', :js do wait_for_requests end - it 'routes the user to the issue details page when the `issue_type` is set to issue' do - open_issue_edit_form + context 'by non-member author' do + it 'routes the user to the issue details page when the `issue_type` is set to issue' do + open_issue_edit_form + + page.within('[data-testid="issuable-form"]') do + update_type_select('Incident', 'Issue') + + expect(page).to have_current_path(project_issue_path(project, incident)) + end + end + end + + context 'by reporter' do + let(:user) { reporter } + + it 'routes the user to the issue details page when the `issue_type` is set to issue' do + open_issue_edit_form - page.within('[data-testid="issuable-form"]') do - update_type_select('Incident', 'Issue') + page.within('[data-testid="issuable-form"]') do + update_type_select('Incident', 'Issue') - expect(page).to have_current_path(project_issue_path(project, incident)) + expect(page).to have_current_path(project_issue_path(project, incident)) + end end end end |