2019-07-25 01:24:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-04-18 12:53:32 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-16 14:09:01 -04:00
|
|
|
RSpec.describe 'Projects > Members > User requests access', :js do
|
2022-06-15 11:09:20 -04:00
|
|
|
include Spec::Support::Helpers::ModalHelpers
|
|
|
|
|
2021-05-26 08:10:41 -04:00
|
|
|
let_it_be(:user) { create(:user) }
|
2022-03-16 20:07:59 -04:00
|
|
|
let_it_be(:maintainer) { create(:user) }
|
2021-05-26 08:10:41 -04:00
|
|
|
let_it_be(:project) { create(:project, :public, :repository) }
|
|
|
|
|
2022-03-16 20:07:59 -04:00
|
|
|
let(:owner) { project.first_owner }
|
2016-04-18 12:53:32 -04:00
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
before do
|
2017-06-21 19:44:10 -04:00
|
|
|
sign_in(user)
|
2022-03-16 20:07:59 -04:00
|
|
|
project.add_maintainer(maintainer)
|
2017-07-06 12:20:50 -04:00
|
|
|
visit project_path(project)
|
2016-07-15 17:46:29 -04:00
|
|
|
end
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'request access feature is disabled' do
|
2021-04-03 23:08:52 -04:00
|
|
|
project.update!(request_access_enabled: false)
|
2017-07-06 12:20:50 -04:00
|
|
|
visit project_path(project)
|
2016-07-20 06:34:29 -04:00
|
|
|
|
2016-07-15 17:46:29 -04:00
|
|
|
expect(page).not_to have_content 'Request Access'
|
2016-04-18 12:53:32 -04:00
|
|
|
end
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'user can request access to a project' do
|
2016-06-02 12:05:06 -04:00
|
|
|
perform_enqueued_jobs { click_link 'Request Access' }
|
2016-04-18 12:53:32 -04:00
|
|
|
|
2022-03-16 20:07:59 -04:00
|
|
|
expect(ActionMailer::Base.deliveries.map(&:to)).to match_array([[owner.notification_email_or_default], [maintainer.notification_email_or_default]])
|
2018-03-05 09:15:26 -05:00
|
|
|
expect(ActionMailer::Base.deliveries.last.subject).to eq "Request to join the #{project.full_name} project"
|
2016-04-18 12:53:32 -04:00
|
|
|
|
2016-06-27 10:20:57 -04:00
|
|
|
expect(project.requesters.exists?(user_id: user)).to be_truthy
|
2016-06-02 12:05:06 -04:00
|
|
|
|
|
|
|
expect(page).to have_content 'Withdraw Access Request'
|
2016-06-17 23:44:15 -04:00
|
|
|
expect(page).not_to have_content 'Leave Project'
|
2016-04-18 12:53:32 -04:00
|
|
|
end
|
|
|
|
|
2017-04-21 19:18:09 -04:00
|
|
|
context 'code access is restricted' do
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'user can request access' do
|
2017-04-21 19:18:09 -04:00
|
|
|
project.project_feature.update!(repository_access_level: ProjectFeature::PRIVATE,
|
|
|
|
builds_access_level: ProjectFeature::PRIVATE,
|
|
|
|
merge_requests_access_level: ProjectFeature::PRIVATE)
|
2017-07-06 12:20:50 -04:00
|
|
|
visit project_path(project)
|
2017-04-21 19:18:09 -04:00
|
|
|
|
|
|
|
expect(page).to have_content 'Request Access'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'user is not listed in the project members page' do
|
2016-04-18 12:53:32 -04:00
|
|
|
click_link 'Request Access'
|
|
|
|
|
2016-06-27 10:20:57 -04:00
|
|
|
expect(project.requesters.exists?(user_id: user)).to be_truthy
|
2016-04-18 12:53:32 -04:00
|
|
|
|
2021-05-26 08:10:41 -04:00
|
|
|
click_link 'Project information'
|
|
|
|
|
2017-08-18 07:07:10 -04:00
|
|
|
page.within('.nav-sidebar') do
|
2017-07-07 10:40:41 -04:00
|
|
|
click_link('Members')
|
|
|
|
end
|
2016-04-18 12:53:32 -04:00
|
|
|
|
|
|
|
page.within('.content') do
|
|
|
|
expect(page).not_to have_content(user.name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'user can withdraw its request for access' do
|
2016-04-18 12:53:32 -04:00
|
|
|
click_link 'Request Access'
|
|
|
|
|
2016-06-27 10:20:57 -04:00
|
|
|
expect(project.requesters.exists?(user_id: user)).to be_truthy
|
2016-04-18 12:53:32 -04:00
|
|
|
|
2022-06-15 11:09:20 -04:00
|
|
|
accept_gl_confirm { click_link 'Withdraw Access Request' }
|
2016-06-02 12:05:06 -04:00
|
|
|
|
2019-04-12 04:50:24 -04:00
|
|
|
expect(page).not_to have_content 'Withdraw Access Request'
|
|
|
|
expect(page).to have_content 'Request Access'
|
2016-06-02 12:05:06 -04:00
|
|
|
end
|
2016-04-18 12:53:32 -04:00
|
|
|
|
2016-06-02 12:05:06 -04:00
|
|
|
def open_project_settings_menu
|
2017-03-07 21:43:08 -05:00
|
|
|
page.within('.layout-nav .nav-links') do
|
|
|
|
click_link('Settings')
|
|
|
|
end
|
|
|
|
|
2017-03-23 12:52:23 -04:00
|
|
|
page.within('.sub-nav') do
|
2017-03-07 21:43:08 -05:00
|
|
|
click_link('Members')
|
|
|
|
end
|
2016-04-18 12:53:32 -04:00
|
|
|
end
|
|
|
|
end
|