Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-05 00:07:54 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-05 00:07:54 +0300
commit2fd92f2dc784ade9cb4e1c33dd60cbfad7b86818 (patch)
tree7779f36689db97a46e0268a4aec1d49f283eb0c8 /spec/lib/gitlab/background_migration
parent42ca24aa5bbab7a2d43bc866d9bee9876941cea2 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/background_migration')
-rw-r--r--spec/lib/gitlab/background_migration/recalculate_project_authorizations_with_min_max_user_id_spec.rb38
1 files changed, 38 insertions, 0 deletions
diff --git a/spec/lib/gitlab/background_migration/recalculate_project_authorizations_with_min_max_user_id_spec.rb b/spec/lib/gitlab/background_migration/recalculate_project_authorizations_with_min_max_user_id_spec.rb
new file mode 100644
index 00000000000..14ba57eecbf
--- /dev/null
+++ b/spec/lib/gitlab/background_migration/recalculate_project_authorizations_with_min_max_user_id_spec.rb
@@ -0,0 +1,38 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe Gitlab::BackgroundMigration::RecalculateProjectAuthorizationsWithMinMaxUserId, :migration, schema: 20200204113224 do
+ let(:users_table) { table(:users) }
+ let(:min) { 1 }
+ let(:max) { 5 }
+
+ before do
+ min.upto(max) do |i|
+ users_table.create!(id: i, email: "user#{i}@example.com", projects_limit: 10)
+ end
+ end
+
+ describe '#perform' do
+ it 'initializes Users::RefreshAuthorizedProjectsService with correct users' do
+ min.upto(max) do |i|
+ user = User.find(i)
+ expect(Users::RefreshAuthorizedProjectsService).to(
+ receive(:new).with(user, any_args).and_call_original)
+ end
+
+ described_class.new.perform(min, max)
+ end
+
+ it 'executes Users::RefreshAuthorizedProjectsService' do
+ expected_call_counts = max - min + 1
+
+ service = instance_double(Users::RefreshAuthorizedProjectsService)
+ expect(Users::RefreshAuthorizedProjectsService).to(
+ receive(:new).exactly(expected_call_counts).times.and_return(service))
+ expect(service).to receive(:execute).exactly(expected_call_counts).times
+
+ described_class.new.perform(min, max)
+ end
+ end
+end