BigW Consortium Gitlab

access_requestable_spec.rb 1.17 KB
Newer Older
1 2 3 4 5
require 'spec_helper'

describe AccessRequestable do
  describe 'Group' do
    describe '#request_access' do
6
      let(:group) { create(:group, :public, :access_requestable) }
7 8 9
      let(:user) { create(:user) }

      it { expect(group.request_access(user)).to be_a(GroupMember) }
10
      it { expect(group.request_access(user).user).to eq(user) }
11 12 13
    end

    describe '#access_requested?' do
14
      let(:group) { create(:group, :public, :access_requestable) }
15 16
      let(:user) { create(:user) }

17 18 19
      before do
        group.request_access(user)
      end
20

21
      it { expect(group.requesters.exists?(user_id: user)).to be_truthy }
22 23 24 25 26
    end
  end

  describe 'Project' do
    describe '#request_access' do
27
      let(:project) { create(:project, :public, :access_requestable) }
28 29 30 31 32 33
      let(:user) { create(:user) }

      it { expect(project.request_access(user)).to be_a(ProjectMember) }
    end

    describe '#access_requested?' do
34
      let(:project) { create(:project, :public, :access_requestable) }
35 36
      let(:user) { create(:user) }

37 38 39
      before do
        project.request_access(user)
      end
40

41
      it { expect(project.requesters.exists?(user_id: user)).to be_truthy }
42 43 44
    end
  end
end