Commit 27d10aef authored by Samantha Ming's avatar Samantha Ming

Add spec for feature spec when on/off

Only show reviewers dropdown when feature flag is on.
Otherwise, there is no reviewers dropdown.
parent f80b4767
...@@ -66,7 +66,8 @@ module FormHelper ...@@ -66,7 +66,8 @@ module FormHelper
first_user: current_user&.username, first_user: current_user&.username,
null_user: true, null_user: true,
current_user: true, current_user: true,
project_id: (@target_project || @project)&.id, field_name: "#{issuable_type}[reviewer_ids][]", project_id: (@target_project || @project)&.id,
field_name: "#{issuable_type}[reviewer_ids][]",
default_label: 'Unassigned', default_label: 'Unassigned',
'dropdown-header': 'Reviewer(s)', 'dropdown-header': 'Reviewer(s)',
multi_select: true, multi_select: true,
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
- issuable.reviewers.each do |reviewer| - issuable.reviewers.each do |reviewer|
= hidden_field_tag "#{issuable.to_ability_name}[reviewer_ids][]", reviewer.id, id: nil, data: { meta: reviewer.name, avatar_url: reviewer.avatar_url, name: reviewer.name, username: reviewer.username } = hidden_field_tag "#{issuable.to_ability_name}[reviewer_ids][]", reviewer.id, id: nil, data: { meta: reviewer.name, avatar_url: reviewer.avatar_url, name: reviewer.name, username: reviewer.username }
- if issuable.reviewers.length === 0 - if issuable.reviewers.empty?
= hidden_field_tag "#{issuable.to_ability_name}[reviewer_ids][]", 0, id: nil, data: { meta: '' } = hidden_field_tag "#{issuable.to_ability_name}[reviewer_ids][]", 0, id: nil, data: { meta: '' }
= dropdown_tag(users_dropdown_label(issuable.reviewers), options: reviewers_dropdown_options(issuable.to_ability_name)) = dropdown_tag(users_dropdown_label(issuable.reviewers), options: reviewers_dropdown_options(issuable.to_ability_name))
...@@ -7,7 +7,6 @@ RSpec.describe 'Merge request > User edits MR' do ...@@ -7,7 +7,6 @@ RSpec.describe 'Merge request > User edits MR' do
before do before do
stub_licensed_features(multiple_merge_request_assignees: false) stub_licensed_features(multiple_merge_request_assignees: false)
stub_feature_flags(merge_request_reviewers: true)
end end
context 'non-fork merge request' do context 'non-fork merge request' do
...@@ -21,4 +20,32 @@ RSpec.describe 'Merge request > User edits MR' do ...@@ -21,4 +20,32 @@ RSpec.describe 'Merge request > User edits MR' do
include_context 'merge request edit context' include_context 'merge request edit context'
it_behaves_like 'an editable merge request' it_behaves_like 'an editable merge request'
end end
context 'when merge_request_reviewers is turned on' do
before do
stub_feature_flags(merge_request_reviewers: true)
end
context 'non-fork merge request' do
include_context 'merge request edit context'
it_behaves_like 'an editable merge request with reviewers'
end
context 'for a forked project' do
let(:source_project) { fork_project(target_project, nil, repository: true) }
include_context 'merge request edit context'
it_behaves_like 'an editable merge request with reviewers'
end
end
context 'when merge_request_reviewers is turned off' do
before do
stub_feature_flags(merge_request_reviewers: false)
end
it 'does not render reviewers dropdown' do
expect(page).not_to have_selector('.js-reviewer-search')
end
end
end end
...@@ -11,15 +11,6 @@ RSpec.shared_examples 'an editable merge request' do ...@@ -11,15 +11,6 @@ RSpec.shared_examples 'an editable merge request' do
expect(page).to have_content user.name expect(page).to have_content user.name
end end
find('.js-reviewer-search').click
page.within '.dropdown-menu-user' do
click_link user.name
end
expect(find('input[name="merge_request[reviewer_ids][]"]', visible: false).value).to match(user.id.to_s)
page.within '.js-reviewer-search' do
expect(page).to have_content user.name
end
click_button 'Milestone' click_button 'Milestone'
page.within '.issue-milestone' do page.within '.issue-milestone' do
click_link milestone.title click_link milestone.title
...@@ -133,3 +124,16 @@ end ...@@ -133,3 +124,16 @@ end
def get_textarea_height def get_textarea_height
page.evaluate_script('document.getElementById("merge_request_description").offsetHeight') page.evaluate_script('document.getElementById("merge_request_description").offsetHeight')
end end
RSpec.shared_examples 'an editable merge request with reviewers' do
it 'updates merge request', :js do
find('.js-reviewer-search').click
page.within '.dropdown-menu-user' do
click_link user.name
end
expect(find('input[name="merge_request[reviewer_ids][]"]', visible: false).value).to match(user.id.to_s)
page.within '.js-reviewer-search' do
expect(page).to have_content user.name
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