debian-mirror-gitlab/spec/features/projects/members/user_requests_access_spec.rb

83 lines
2.3 KiB
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
require 'spec_helper'
2020-06-23 00:09:42 +05:30
RSpec.describe 'Projects > Members > User requests access', :js do
2021-09-04 01:27:46 +05:30
let_it_be(:user) { create(:user) }
let_it_be(:project) { create(:project, :public, :repository) }
2018-11-18 11:00:15 +05:30
let(:maintainer) { project.owner }
2018-11-08 19:23:39 +05:30
before do
2017-09-10 17:25:29 +05:30
sign_in(user)
visit project_path(project)
end
2018-11-08 19:23:39 +05:30
it 'request access feature is disabled' do
2021-04-29 21:17:54 +05:30
project.update!(request_access_enabled: false)
2017-09-10 17:25:29 +05:30
visit project_path(project)
2016-08-24 12:49:21 +05:30
expect(page).not_to have_content 'Request Access'
end
2018-11-08 19:23:39 +05:30
it 'user can request access to a project' do
perform_enqueued_jobs { click_link 'Request Access' }
2021-11-11 11:23:49 +05:30
expect(ActionMailer::Base.deliveries.last.to).to eq [maintainer.notification_email_or_default]
2018-03-27 19:54:05 +05:30
expect(ActionMailer::Base.deliveries.last.subject).to eq "Request to join the #{project.full_name} project"
2016-08-24 12:49:21 +05:30
expect(project.requesters.exists?(user_id: user)).to be_truthy
expect(page).to have_content 'Withdraw Access Request'
2016-08-24 12:49:21 +05:30
expect(page).not_to have_content 'Leave Project'
end
2017-08-17 22:00:37 +05:30
context 'code access is restricted' do
2018-11-08 19:23:39 +05:30
it 'user can request access' do
2017-08-17 22:00:37 +05:30
project.project_feature.update!(repository_access_level: ProjectFeature::PRIVATE,
builds_access_level: ProjectFeature::PRIVATE,
merge_requests_access_level: ProjectFeature::PRIVATE)
2017-09-10 17:25:29 +05:30
visit project_path(project)
2017-08-17 22:00:37 +05:30
expect(page).to have_content 'Request Access'
end
end
2018-11-08 19:23:39 +05:30
it 'user is not listed in the project members page' do
click_link 'Request Access'
2016-08-24 12:49:21 +05:30
expect(project.requesters.exists?(user_id: user)).to be_truthy
2021-09-04 01:27:46 +05:30
click_link 'Project information'
2018-03-17 18:26:18 +05:30
page.within('.nav-sidebar') do
2017-09-10 17:25:29 +05:30
click_link('Members')
end
page.within('.content') do
expect(page).not_to have_content(user.name)
end
end
2018-11-08 19:23:39 +05:30
it 'user can withdraw its request for access' do
click_link 'Request Access'
2016-08-24 12:49:21 +05:30
expect(project.requesters.exists?(user_id: user)).to be_truthy
2018-03-17 18:26:18 +05:30
accept_confirm { click_link 'Withdraw Access Request' }
2019-07-31 22:56:46 +05:30
expect(page).not_to have_content 'Withdraw Access Request'
expect(page).to have_content 'Request Access'
end
def open_project_settings_menu
2017-08-17 22:00:37 +05:30
page.within('.layout-nav .nav-links') do
click_link('Settings')
end
page.within('.sub-nav') do
click_link('Members')
end
end
end