Commit a9e87bb4 authored by Jackie Fraser's avatar Jackie Fraser

Use ProjectMember access_level_roles for invite members modal

parent 36cf7b9a
......@@ -2,6 +2,6 @@
.js-invite-members-modal{ data: { id: project.id,
name: project.name,
is_project: 'true',
access_levels: GroupMember.access_level_roles.to_json,
access_levels: ProjectMember.access_level_roles.to_json,
default_access_level: Gitlab::Access::GUEST,
help_link: help_page_url('user/permissions') } }
......@@ -11,7 +11,7 @@ RSpec.describe 'Project members list' do
let(:project) { create(:project, namespace: group) }
before do
stub_feature_flags(invite_members_group_modal: false)
stub_feature_flags(invite_members_group_modal: true)
sign_in(user1)
group.add_owner(user1)
......@@ -60,13 +60,30 @@ RSpec.describe 'Project members list' do
it 'add user to project', :js do
visit_members_page
add_user(user2.id, 'Reporter')
add_user(user2.name, 'Reporter')
page.within find_member_row(user2) do
expect(page).to have_button('Reporter')
end
end
it 'uses ProjectMember access_level_roles for the invite members modal access option', :js do
visit_members_page
click_on 'Invite members'
click_on 'Guest'
wait_for_requests
page.within '.dropdown-menu' do
expect(page).to have_button('Guest')
expect(page).to have_button('Reporter')
expect(page).to have_button('Developer')
expect(page).to have_button('Maintainer')
expect(page).not_to have_button('Owner')
end
end
it 'remove user from project', :js do
other_user = create(:user)
project.add_developer(other_user)
......@@ -160,7 +177,7 @@ RSpec.describe 'Project members list' do
it 'add user to project', :js do
visit_members_page
add_user(user2.id, 'Reporter')
add_user(user2.name, 'Reporter')
page.within(second_row) do
expect(page).to have_content(user2.name)
......@@ -222,12 +239,22 @@ RSpec.describe 'Project members list' do
private
def add_user(id, role)
page.within ".invite-users-form" do
select2(id, from: "#user_ids", multiple: true)
select(role, from: "access_level")
click_on 'Invite members'
page.within '#invite-members-modal' do
fill_in 'Search for members to invite', with: id
wait_for_requests
click_button id
click_button 'Guest'
wait_for_requests
click_button role
click_button 'Invite'
end
click_button "Invite"
page.refresh
end
def visit_members_page
......
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