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
|
|
|
end
|
|
|
|
|
2018-11-18 11:00:15 +05:30
|
|
|
it 'maintainer can see access requests' do
|
2018-10-15 14:42:47 +05:30
|
|
|
visit members_page_path
|
|
|
|
|
|
|
|
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
|
|
|
visit members_page_path
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
page.within('.members-list') do
|
|
|
|
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
|
|
|
visit members_page_path
|
|
|
|
|
|
|
|
expect_visible_access_request(entity, user)
|
|
|
|
|
|
|
|
accept_confirm { click_on 'Deny access' }
|
|
|
|
|
|
|
|
expect_no_visible_access_request(entity, user)
|
|
|
|
expect(page).not_to have_content user.name
|
|
|
|
end
|
|
|
|
|
|
|
|
def expect_visible_access_request(entity, user)
|
|
|
|
expect(page).to have_content "Users requesting access to #{entity.name} 1"
|
|
|
|
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
|