BigW Consortium Gitlab

access_requestable_spec.rb 1.06 KB
Newer Older
1 2 3 4 5 6 7 8 9
require 'spec_helper'

describe AccessRequestable do
  describe 'Group' do
    describe '#request_access' do
      let(:group) { create(:group, :public) }
      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 14 15 16 17 18
    end

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

      before { group.request_access(user) }

19
      it { expect(group.requesters.exists?(user_id: user)).to be_truthy }
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
    end
  end

  describe 'Project' do
    describe '#request_access' do
      let(:project) { create(:empty_project, :public) }
      let(:user) { create(:user) }

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

    describe '#access_requested?' do
      let(:project) { create(:empty_project, :public) }
      let(:user) { create(:user) }

      before { project.request_access(user) }

37
      it { expect(project.requesters.exists?(user_id: user)).to be_truthy }
38 39 40
    end
  end
end