2019-03-30 07:23:56 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-04-18 16:53:32 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe AccessRequestable do
|
|
|
|
describe 'Group' do
|
|
|
|
describe '#request_access' do
|
2016-11-11 12:51:50 +00:00
|
|
|
let(:group) { create(:group, :public, :access_requestable) }
|
2016-04-18 16:53:32 +00:00
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
|
|
|
it { expect(group.request_access(user)).to be_a(GroupMember) }
|
2016-06-02 16:05:06 +00:00
|
|
|
it { expect(group.request_access(user).user).to eq(user) }
|
2016-04-18 16:53:32 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
describe '#access_requested?' do
|
2016-11-11 12:51:50 +00:00
|
|
|
let(:group) { create(:group, :public, :access_requestable) }
|
2016-04-18 16:53:32 +00:00
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
2017-06-14 18:18:56 +00:00
|
|
|
before do
|
|
|
|
group.request_access(user)
|
|
|
|
end
|
2016-04-18 16:53:32 +00:00
|
|
|
|
2016-06-27 14:20:57 +00:00
|
|
|
it { expect(group.requesters.exists?(user_id: user)).to be_truthy }
|
2016-04-18 16:53:32 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'Project' do
|
|
|
|
describe '#request_access' do
|
2017-08-02 19:55:11 +00:00
|
|
|
let(:project) { create(:project, :public, :access_requestable) }
|
2016-04-18 16:53:32 +00:00
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
|
|
|
it { expect(project.request_access(user)).to be_a(ProjectMember) }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#access_requested?' do
|
2017-08-02 19:55:11 +00:00
|
|
|
let(:project) { create(:project, :public, :access_requestable) }
|
2016-04-18 16:53:32 +00:00
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
2017-06-14 18:18:56 +00:00
|
|
|
before do
|
|
|
|
project.request_access(user)
|
|
|
|
end
|
2016-04-18 16:53:32 +00:00
|
|
|
|
2016-06-27 14:20:57 +00:00
|
|
|
it { expect(project.requesters.exists?(user_id: user)).to be_truthy }
|
2016-04-18 16:53:32 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|