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) }
|
|
|
|
let(:project) { create(:project, :public) }
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
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'
|
|
|
|
|
|
|
|
visit namespace_project_project_members_path(project.namespace, project)
|
|
|
|
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
|
|
|
|
find('#project-settings-button').click
|
2016-04-18 12:53:32 -04:00
|
|
|
end
|
|
|
|
end
|