project_authorization_spec.rb 705 Bytes
Newer Older
1 2 3 4
require 'spec_helper'

describe ProjectAuthorization do
  let(:user) { create(:user) }
5 6
  let(:project1) { create(:project) }
  let(:project2) { create(:project) }
7 8 9

  describe '.insert_authorizations' do
    it 'inserts the authorizations' do
10
      described_class
11
        .insert_authorizations([[user.id, project1.id, Gitlab::Access::MAINTAINER]])
12 13 14 15 16 17

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

    it 'inserts rows in batches' do
      described_class.insert_authorizations([
18 19
        [user.id, project1.id, Gitlab::Access::MAINTAINER],
        [user.id, project2.id, Gitlab::Access::MAINTAINER]
20 21 22 23 24 25
      ], 1)

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