2016-04-18 12:53:32 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-06-29 00:13:10 -04:00
|
|
|
feature 'Groups > Members > Request access' do
|
2016-04-18 12:53:32 -04:00
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:owner) { create(:user) }
|
2016-11-11 07:51:50 -05:00
|
|
|
let(:group) { create(:group, :public, :access_requestable) }
|
2017-08-02 15:55:11 -04:00
|
|
|
let!(:project) { create(:project, :private, namespace: group) }
|
2016-04-18 12:53:32 -04:00
|
|
|
|
|
|
|
background do
|
|
|
|
group.add_owner(owner)
|
2017-06-21 19:44:10 -04:00
|
|
|
sign_in(user)
|
2016-07-20 06:34:29 -04:00
|
|
|
visit group_path(group)
|
2016-07-15 17:46:29 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'request access feature is disabled' do
|
|
|
|
group.update_attributes(request_access_enabled: false)
|
|
|
|
visit group_path(group)
|
|
|
|
|
|
|
|
expect(page).not_to have_content 'Request Access'
|
2016-04-18 12:53:32 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'user can request access to a group' 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 [owner.notification_email]
|
2016-06-02 12:05:06 -04:00
|
|
|
expect(ActionMailer::Base.deliveries.last.subject).to match "Request to join the #{group.name} group"
|
2016-04-18 12:53:32 -04:00
|
|
|
|
2016-06-27 10:20:57 -04:00
|
|
|
expect(group.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-11-19 10:40:41 -05:00
|
|
|
expect(page).not_to have_content 'Leave group'
|
2016-04-18 12:53:32 -04:00
|
|
|
end
|
|
|
|
|
2016-06-24 06:01:48 -04:00
|
|
|
scenario 'user does not see private projects' do
|
|
|
|
perform_enqueued_jobs { click_link 'Request Access' }
|
|
|
|
|
|
|
|
expect(page).not_to have_content project.name
|
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'user does not see group in the Dashboard > Groups page' do
|
|
|
|
perform_enqueued_jobs { click_link 'Request Access' }
|
|
|
|
|
|
|
|
visit dashboard_groups_path
|
|
|
|
|
|
|
|
expect(page).not_to have_content group.name
|
|
|
|
end
|
|
|
|
|
2016-04-18 12:53:32 -04:00
|
|
|
scenario 'user is not listed in the group members page' do
|
|
|
|
click_link 'Request Access'
|
|
|
|
|
2016-06-27 10:20:57 -04:00
|
|
|
expect(group.requesters.exists?(user_id: user)).to be_truthy
|
2016-04-18 12:53:32 -04:00
|
|
|
|
2017-09-01 03:41:31 -04:00
|
|
|
first(:link, 'Members').click
|
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(group.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-04-18 12:53:32 -04:00
|
|
|
|
2016-06-27 10:20:57 -04:00
|
|
|
expect(group.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 group has been withdrawn.'
|
2016-04-18 12:53:32 -04:00
|
|
|
end
|
2017-06-26 10:33:49 -04:00
|
|
|
|
|
|
|
scenario 'member does not see the request access button' do
|
|
|
|
group.add_owner(user)
|
|
|
|
visit group_path(group)
|
|
|
|
|
|
|
|
expect(page).not_to have_content 'Request Access'
|
|
|
|
end
|
2016-04-18 12:53:32 -04:00
|
|
|
end
|