2016-04-18 12:53:32 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-06-29 00:13:10 -04:00
|
|
|
feature 'Groups > Members > Manage access requests' 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) }
|
2016-04-18 12:53:32 -04:00
|
|
|
|
|
|
|
background do
|
|
|
|
group.request_access(user)
|
|
|
|
group.add_owner(owner)
|
2017-06-21 19:44:10 -04:00
|
|
|
sign_in(owner)
|
2016-04-18 12:53:32 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'owner can see access requests' do
|
|
|
|
visit group_group_members_path(group)
|
|
|
|
|
|
|
|
expect_visible_access_request(group, user)
|
|
|
|
end
|
|
|
|
|
2017-06-26 10:34:35 -04:00
|
|
|
scenario 'owner can grant access' do
|
2016-04-18 12:53:32 -04:00
|
|
|
visit group_group_members_path(group)
|
|
|
|
|
|
|
|
expect_visible_access_request(group, user)
|
|
|
|
|
2016-06-02 12:05:06 -04:00
|
|
|
perform_enqueued_jobs { click_on 'Grant access' }
|
2016-04-18 12:53:32 -04:00
|
|
|
|
|
|
|
expect(ActionMailer::Base.deliveries.last.to).to eq [user.notification_email]
|
2016-06-02 12:05:06 -04:00
|
|
|
expect(ActionMailer::Base.deliveries.last.subject).to match "Access to the #{group.name} group was granted"
|
2016-04-18 12:53:32 -04:00
|
|
|
end
|
|
|
|
|
2017-06-26 10:34:35 -04:00
|
|
|
scenario 'owner can deny access' do
|
2016-04-18 12:53:32 -04:00
|
|
|
visit group_group_members_path(group)
|
|
|
|
|
|
|
|
expect_visible_access_request(group, user)
|
|
|
|
|
2016-06-02 12:05:06 -04:00
|
|
|
perform_enqueued_jobs { click_on 'Deny access' }
|
2016-04-18 12:53:32 -04:00
|
|
|
|
|
|
|
expect(ActionMailer::Base.deliveries.last.to).to eq [user.notification_email]
|
2016-06-02 12:05:06 -04:00
|
|
|
expect(ActionMailer::Base.deliveries.last.subject).to match "Access to the #{group.name} group was denied"
|
2016-04-18 12:53:32 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def expect_visible_access_request(group, user)
|
2016-06-27 10:20:57 -04:00
|
|
|
expect(group.requesters.exists?(user_id: user)).to be_truthy
|
2016-09-02 08:35:43 -04:00
|
|
|
expect(page).to have_content "Users requesting access to #{group.name} 1"
|
2016-04-18 12:53:32 -04:00
|
|
|
expect(page).to have_content user.name
|
|
|
|
end
|
|
|
|
end
|