2019-07-07 11:18:12 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-06-16 23:09:34 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
RSpec.describe AccessRequestable do
|
2016-06-16 23:09:34 +05:30
|
|
|
describe 'Group' do
|
|
|
|
describe '#request_access' do
|
2019-12-21 20:55:43 +05:30
|
|
|
let(:group) { create(:group, :public) }
|
2016-06-16 23:09:34 +05:30
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
|
|
|
it { expect(group.request_access(user)).to be_a(GroupMember) }
|
|
|
|
it { expect(group.request_access(user).user).to eq(user) }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#access_requested?' do
|
2019-12-21 20:55:43 +05:30
|
|
|
let(:group) { create(:group, :public) }
|
2016-06-16 23:09:34 +05:30
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
before do
|
|
|
|
group.request_access(user)
|
|
|
|
end
|
2016-06-16 23:09:34 +05:30
|
|
|
|
2016-08-24 12:49:21 +05:30
|
|
|
it { expect(group.requesters.exists?(user_id: user)).to be_truthy }
|
2016-06-16 23:09:34 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'Project' do
|
|
|
|
describe '#request_access' do
|
2019-12-21 20:55:43 +05:30
|
|
|
let(:project) { create(:project, :public) }
|
2016-06-16 23:09:34 +05:30
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
|
|
|
it { expect(project.request_access(user)).to be_a(ProjectMember) }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#access_requested?' do
|
2019-12-21 20:55:43 +05:30
|
|
|
let(:project) { create(:project, :public) }
|
2016-06-16 23:09:34 +05:30
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
before do
|
|
|
|
project.request_access(user)
|
|
|
|
end
|
2016-06-16 23:09:34 +05:30
|
|
|
|
2016-08-24 12:49:21 +05:30
|
|
|
it { expect(project.requesters.exists?(user_id: user)).to be_truthy }
|
2016-06-16 23:09:34 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|