summaryrefslogtreecommitdiff
path: root/spec/models/project_authorization_spec.rb
blob: ee6bdc39c8cc4081a582a24bee5c3f88272083a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
require 'spec_helper'

describe ProjectAuthorization do
  let(:user) { create(:user) }
  let(:project1) { create(:empty_project) }
  let(:project2) { create(:empty_project) }

  describe '.insert_authorizations' do
    it 'inserts the authorizations' do
      described_class
        .insert_authorizations([[user.id, project1.id, Gitlab::Access::MASTER]])

      expect(user.project_authorizations.count).to eq(1)
    end

    it 'inserts rows in batches' do
      described_class.insert_authorizations([
        [user.id, project1.id, Gitlab::Access::MASTER],
        [user.id, project2.id, Gitlab::Access::MASTER]
      ], 1)

      expect(user.project_authorizations.count).to eq(2)
    end
  end
end