2016-04-18 12:53:32 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
feature 'Projects > Members > User requests access', feature: true do
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:master) { create(:user) }
|
2016-11-11 07:51:50 -05:00
|
|
|
let(:project) { create(:project, :public, :access_requestable) }
|
2016-04-18 12:53:32 -04:00
|
|
|
|
|
|
|
background do
|
|
|
|
project.team << [master, :master]
|
|
|
|
login_as(user)
|
2016-07-20 06:34:29 -04:00
|
|
|
visit namespace_project_path(project.namespace, project)
|
2016-07-15 17:46:29 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'request access feature is disabled' do
|
|
|
|
project.update_attributes(request_access_enabled: false)
|
2016-06-02 12:05:06 -04:00
|
|
|
visit namespace_project_path(project.namespace, 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
|
|
|
|
|
|
|
|
scenario '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
|
|
|
|
|
|
|
expect(ActionMailer::Base.deliveries.last.to).to eq [master.notification_email]
|
2016-06-02 12:05:06 -04:00
|
|
|
expect(ActionMailer::Base.deliveries.last.subject).to eq "Request to join the #{project.name_with_namespace} 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-04-18 12:53:32 -04:00
|
|
|
expect(page).to have_content 'Your request for access has been queued for review.'
|
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
|
|
|
|
scenario 'user can request access' do
|
|
|
|
project.project_feature.update!(repository_access_level: ProjectFeature::PRIVATE,
|
|
|
|
builds_access_level: ProjectFeature::PRIVATE,
|
|
|
|
merge_requests_access_level: ProjectFeature::PRIVATE)
|
|
|
|
visit namespace_project_path(project.namespace, project)
|
|
|
|
|
|
|
|
expect(page).to have_content 'Request Access'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-04-18 12:53:32 -04:00
|
|
|
scenario 'user is not listed in the project members page' do
|
|
|
|
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
|
|
|
|
2016-06-02 12:05:06 -04:00
|
|
|
open_project_settings_menu
|
2016-04-18 12:53:32 -04:00
|
|
|
click_link 'Members'
|
|
|
|
|
2016-12-22 17:38:27 -05:00
|
|
|
visit namespace_project_settings_members_path(project.namespace, project)
|
2016-04-18 12:53:32 -04:00
|
|
|
page.within('.content') do
|
|
|
|
expect(page).not_to have_content(user.name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'user can withdraw its request for access' do
|
|
|
|
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
|
|
|
|
2016-06-02 12:05:06 -04:00
|
|
|
click_link 'Withdraw Access Request'
|
|
|
|
|
2016-06-27 10:20:57 -04:00
|
|
|
expect(project.requesters.exists?(user_id: user)).to be_falsey
|
2016-06-02 12:05:06 -04:00
|
|
|
expect(page).to have_content 'Your access request to the project has been withdrawn.'
|
|
|
|
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
|