2016-04-18 12:53:32 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
feature 'Groups > Members > User requests access', feature: true do
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:owner) { create(:user) }
|
|
|
|
let(:group) { create(:group, :public) }
|
|
|
|
|
|
|
|
background do
|
|
|
|
group.add_owner(owner)
|
|
|
|
login_as(user)
|
2016-06-02 12:05:06 -04:00
|
|
|
visit group_path(group)
|
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-02 12:05:06 -04:00
|
|
|
expect(group.members.request.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-04-18 12:53:32 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'user is not listed in the group members page' do
|
|
|
|
click_link 'Request Access'
|
|
|
|
|
2016-06-02 12:05:06 -04:00
|
|
|
expect(group.members.request.exists?(user_id: user)).to be_truthy
|
2016-04-18 12:53:32 -04:00
|
|
|
|
|
|
|
click_link 'Members'
|
|
|
|
|
|
|
|
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-02 12:05:06 -04:00
|
|
|
expect(group.members.request.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-02 12:05:06 -04:00
|
|
|
expect(group.members.request.exists?(user_id: user)).to be_falsey
|
|
|
|
expect(page).to have_content 'Your access request to the group has been withdrawn.'
|
2016-04-18 12:53:32 -04:00
|
|
|
end
|
|
|
|
end
|