2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-11-18 11:00:15 +05:30
|
|
|
RSpec.shared_examples 'Maintainer manages access requests' do
|
2018-10-15 14:42:47 +05:30
|
|
|
let(:user) { create(:user) }
|
2018-11-18 11:00:15 +05:30
|
|
|
let(:maintainer) { create(:user) }
|
2018-10-15 14:42:47 +05:30
|
|
|
|
|
|
|
before do
|
|
|
|
entity.request_access(user)
|
2018-11-18 11:00:15 +05:30
|
|
|
entity.respond_to?(:add_owner) ? entity.add_owner(maintainer) : entity.add_maintainer(maintainer)
|
|
|
|
sign_in(maintainer)
|
2018-10-15 14:42:47 +05:30
|
|
|
visit members_page_path
|
|
|
|
|
2020-10-24 23:57:45 +05:30
|
|
|
if has_tabs
|
|
|
|
click_on 'Access requests'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'maintainer can see access requests', :js do
|
2018-10-15 14:42:47 +05:30
|
|
|
expect_visible_access_request(entity, user)
|
|
|
|
end
|
|
|
|
|
2018-11-18 11:00:15 +05:30
|
|
|
it 'maintainer can grant access', :js do
|
2018-10-15 14:42:47 +05:30
|
|
|
expect_visible_access_request(entity, user)
|
|
|
|
|
2019-07-31 22:56:46 +05:30
|
|
|
click_on 'Grant access'
|
2018-10-15 14:42:47 +05:30
|
|
|
|
|
|
|
expect_no_visible_access_request(entity, user)
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
page.within('[data-qa-selector="members_list"]') do
|
2018-10-15 14:42:47 +05:30
|
|
|
expect(page).to have_content user.name
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-11-18 11:00:15 +05:30
|
|
|
it 'maintainer can deny access', :js do
|
2018-10-15 14:42:47 +05:30
|
|
|
expect_visible_access_request(entity, user)
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
# Open modal
|
|
|
|
click_on 'Deny access request'
|
|
|
|
|
|
|
|
expect(page).not_to have_field "Also unassign this user from related issues and merge requests"
|
|
|
|
|
|
|
|
click_on 'Deny access request'
|
2018-10-15 14:42:47 +05:30
|
|
|
|
|
|
|
expect_no_visible_access_request(entity, user)
|
|
|
|
expect(page).not_to have_content user.name
|
|
|
|
end
|
|
|
|
|
|
|
|
def expect_visible_access_request(entity, user)
|
2020-10-24 23:57:45 +05:30
|
|
|
if has_tabs
|
|
|
|
expect(page).to have_content "Access requests 1"
|
|
|
|
expect(page).to have_content "Users requesting access to #{entity.name}"
|
|
|
|
else
|
|
|
|
expect(page).to have_content "Users requesting access to #{entity.name} 1"
|
|
|
|
end
|
|
|
|
|
2018-10-15 14:42:47 +05:30
|
|
|
expect(page).to have_content user.name
|
|
|
|
end
|
|
|
|
|
|
|
|
def expect_no_visible_access_request(entity, user)
|
|
|
|
expect(page).not_to have_content "Users requesting access to #{entity.name}"
|
|
|
|
end
|
|
|
|
end
|