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
path: root/spec/lib
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-08-19 18:11:58 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-08-19 18:11:58 +0300
commit4c083c816333ef903fe7c32f412eaa53d7b959d3 (patch)
tree199c0a0034a2620374a92a47762bf4a4c07be7ca /spec/lib
parent35d5ae4e3de6444c02725b965ef59774d6256d8e (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib')
-rw-r--r--spec/lib/gitlab/background_migration/remove_self_managed_wiki_notes_spec.rb31
-rw-r--r--spec/lib/gitlab/container_repository/tags/cache_spec.rb12
-rw-r--r--spec/lib/gitlab/diff/highlight_cache_spec.rb8
-rw-r--r--spec/lib/gitlab/markdown_cache/redis/extension_spec.rb8
-rw-r--r--spec/lib/gitlab/redis/duplicate_jobs_spec.rb2
-rw-r--r--spec/lib/gitlab/redis/multi_store_spec.rb44
-rw-r--r--spec/lib/gitlab/redis/sidekiq_status_spec.rb2
-rw-r--r--spec/lib/sidebars/projects/menus/deployments_menu_spec.rb36
8 files changed, 115 insertions, 28 deletions
diff --git a/spec/lib/gitlab/background_migration/remove_self_managed_wiki_notes_spec.rb b/spec/lib/gitlab/background_migration/remove_self_managed_wiki_notes_spec.rb
new file mode 100644
index 00000000000..81927100562
--- /dev/null
+++ b/spec/lib/gitlab/background_migration/remove_self_managed_wiki_notes_spec.rb
@@ -0,0 +1,31 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Gitlab::BackgroundMigration::RemoveSelfManagedWikiNotes, :migration, schema: 20220601110011 do
+ let(:notes) { table(:notes) }
+
+ subject(:perform_migration) do
+ described_class.new(start_id: 1,
+ end_id: 30,
+ batch_table: :notes,
+ batch_column: :id,
+ sub_batch_size: 2,
+ pause_ms: 0,
+ connection: ActiveRecord::Base.connection)
+ .perform
+ end
+
+ it 'removes all wiki notes' do
+ notes.create!(id: 2, note: 'Commit note', noteable_type: 'Commit')
+ notes.create!(id: 10, note: 'Issue note', noteable_type: 'Issue')
+ notes.create!(id: 20, note: 'Wiki note', noteable_type: 'Wiki')
+ notes.create!(id: 30, note: 'MergeRequest note', noteable_type: 'MergeRequest')
+
+ expect(notes.where(noteable_type: 'Wiki').size).to eq(1)
+
+ expect { perform_migration }.to change(notes, :count).by(-1)
+
+ expect(notes.where(noteable_type: 'Wiki').size).to eq(0)
+ end
+end
diff --git a/spec/lib/gitlab/container_repository/tags/cache_spec.rb b/spec/lib/gitlab/container_repository/tags/cache_spec.rb
index f84c1ce173f..fcfc8e7a348 100644
--- a/spec/lib/gitlab/container_repository/tags/cache_spec.rb
+++ b/spec/lib/gitlab/container_repository/tags/cache_spec.rb
@@ -79,10 +79,14 @@ RSpec.describe ::Gitlab::ContainerRepository::Tags::Cache, :clean_gitlab_redis_c
it 'inserts values in redis' do
::Gitlab::Redis::Cache.with do |redis|
- expect(redis)
- .to receive(:set)
- .with(cache_key(tag), rfc3339(tag.created_at), ex: ttl.to_i)
- .and_call_original
+ expect(redis).to receive(:pipelined).and_call_original
+
+ expect_next_instance_of(Redis::PipelinedConnection) do |pipeline|
+ expect(pipeline)
+ .to receive(:set)
+ .with(cache_key(tag), rfc3339(tag.created_at), ex: ttl.to_i)
+ .and_call_original
+ end
end
subject
diff --git a/spec/lib/gitlab/diff/highlight_cache_spec.rb b/spec/lib/gitlab/diff/highlight_cache_spec.rb
index 67751144565..68a2b17840c 100644
--- a/spec/lib/gitlab/diff/highlight_cache_spec.rb
+++ b/spec/lib/gitlab/diff/highlight_cache_spec.rb
@@ -132,20 +132,12 @@ RSpec.describe Gitlab::Diff::HighlightCache, :clean_gitlab_redis_cache do
.once
.and_call_original
- Gitlab::Redis::Cache.with do |redis|
- expect(redis).to receive(:expire).with(cache.key, expiration_period).at_least(:once)
- end
-
2.times { cache.write_if_empty }
end
it 'reads from cache once' do
expect(cache).to receive(:read_cache).once.and_call_original
- Gitlab::Redis::Cache.with do |redis|
- expect(redis).to receive(:expire).with(cache.key, expiration_period).at_least(:once)
- end
-
cache.write_if_empty
end
diff --git a/spec/lib/gitlab/markdown_cache/redis/extension_spec.rb b/spec/lib/gitlab/markdown_cache/redis/extension_spec.rb
index b5d458f15fc..8e75009099d 100644
--- a/spec/lib/gitlab/markdown_cache/redis/extension_spec.rb
+++ b/spec/lib/gitlab/markdown_cache/redis/extension_spec.rb
@@ -62,7 +62,13 @@ RSpec.describe Gitlab::MarkdownCache::Redis::Extension, :clean_gitlab_redis_cach
it 'does not preload the markdown twice' do
expect(Gitlab::MarkdownCache::Redis::Store).to receive(:bulk_read).and_call_original
- expect(Gitlab::Redis::Cache).to receive(:with).twice.and_call_original
+ Gitlab::Redis::Cache.with do |redis|
+ expect(redis).to receive(:pipelined).and_call_original
+
+ expect_next_instance_of(Redis::PipelinedConnection) do |pipeline|
+ expect(pipeline).to receive(:mapped_hmget).once.and_call_original
+ end
+ end
klass.preload_markdown_cache!([thing])
diff --git a/spec/lib/gitlab/redis/duplicate_jobs_spec.rb b/spec/lib/gitlab/redis/duplicate_jobs_spec.rb
index 53e3d73d17e..be20e6dcdaf 100644
--- a/spec/lib/gitlab/redis/duplicate_jobs_spec.rb
+++ b/spec/lib/gitlab/redis/duplicate_jobs_spec.rb
@@ -46,7 +46,7 @@ RSpec.describe Gitlab::Redis::DuplicateJobs do
expect(redis_instance.primary_store.connection[:id]).to eq("redis://test-host:6379/99")
expect(redis_instance.primary_store.connection[:namespace]).to be_nil
- expect(redis_instance.secondary_store.connection[:id]).to eq("redis:///path/to/redis.sock/0")
+ expect(redis_instance.secondary_store.connection[:id]).to eq("unix:///path/to/redis.sock/0")
expect(redis_instance.secondary_store.connection[:namespace]).to eq("resque:gitlab")
expect(redis_instance.instance_name).to eq('DuplicateJobs')
diff --git a/spec/lib/gitlab/redis/multi_store_spec.rb b/spec/lib/gitlab/redis/multi_store_spec.rb
index ef8549548d7..8b73b5e03c0 100644
--- a/spec/lib/gitlab/redis/multi_store_spec.rb
+++ b/spec/lib/gitlab/redis/multi_store_spec.rb
@@ -264,13 +264,20 @@ RSpec.describe Gitlab::Redis::MultiStore do
context 'when the command is executed within pipelined block' do
subject do
- multi_store.pipelined do
- multi_store.send(name, *args)
+ multi_store.pipelined do |pipeline|
+ pipeline.send(name, *args)
end
end
- it 'is executed only 1 time on primary instance' do
- expect(primary_store).to receive(name).with(*args).once
+ it 'is executed only 1 time on primary and secondary instance' do
+ expect(primary_store).to receive(:pipelined).and_call_original
+ expect(secondary_store).to receive(:pipelined).and_call_original
+
+ 2.times do
+ expect_next_instance_of(Redis::PipelinedConnection) do |pipeline|
+ expect(pipeline).to receive(name).with(*args).once.and_call_original
+ end
+ end
subject
end
@@ -438,14 +445,21 @@ RSpec.describe Gitlab::Redis::MultiStore do
context 'when the command is executed within pipelined block' do
subject do
- multi_store.pipelined do
- multi_store.send(name, *args)
+ multi_store.pipelined do |pipeline|
+ pipeline.send(name, *args)
end
end
it 'is executed only 1 time on each instance', :aggregate_errors do
- expect(primary_store).to receive(name).with(*expected_args).once
- expect(secondary_store).to receive(name).with(*expected_args).once
+ expect(primary_store).to receive(:pipelined).and_call_original
+ expect_next_instance_of(Redis::PipelinedConnection) do |pipeline|
+ expect(pipeline).to receive(name).with(*expected_args).once.and_call_original
+ end
+
+ expect(secondary_store).to receive(:pipelined).and_call_original
+ expect_next_instance_of(Redis::PipelinedConnection) do |pipeline|
+ expect(pipeline).to receive(name).with(*expected_args).once.and_call_original
+ end
subject
end
@@ -781,14 +795,20 @@ RSpec.describe Gitlab::Redis::MultiStore do
context 'when the command is executed within pipelined block' do
subject do
- multi_store.pipelined do
- multi_store.incr(key)
+ multi_store.pipelined do |pipeline|
+ pipeline.incr(key)
end
end
it 'is executed only 1 time on each instance', :aggregate_errors do
- expect(primary_store).to receive(:incr).with(key).once
- expect(secondary_store).to receive(:incr).with(key).once
+ expect(primary_store).to receive(:pipelined).once.and_call_original
+ expect(secondary_store).to receive(:pipelined).once.and_call_original
+
+ 2.times do
+ expect_next_instance_of(Redis::PipelinedConnection) do |pipeline|
+ expect(pipeline).to receive(:incr).with(key).once
+ end
+ end
subject
end
diff --git a/spec/lib/gitlab/redis/sidekiq_status_spec.rb b/spec/lib/gitlab/redis/sidekiq_status_spec.rb
index f641ea40efd..76d130d67f7 100644
--- a/spec/lib/gitlab/redis/sidekiq_status_spec.rb
+++ b/spec/lib/gitlab/redis/sidekiq_status_spec.rb
@@ -42,7 +42,7 @@ RSpec.describe Gitlab::Redis::SidekiqStatus do
expect(redis_instance).to be_instance_of(::Gitlab::Redis::MultiStore)
expect(redis_instance.primary_store.connection[:id]).to eq("redis://test-host:6379/99")
- expect(redis_instance.secondary_store.connection[:id]).to eq("redis:///path/to/redis.sock/0")
+ expect(redis_instance.secondary_store.connection[:id]).to eq("unix:///path/to/redis.sock/0")
expect(redis_instance.instance_name).to eq('SidekiqStatus')
end
diff --git a/spec/lib/sidebars/projects/menus/deployments_menu_spec.rb b/spec/lib/sidebars/projects/menus/deployments_menu_spec.rb
index 56eb082e101..90ff04a2064 100644
--- a/spec/lib/sidebars/projects/menus/deployments_menu_spec.rb
+++ b/spec/lib/sidebars/projects/menus/deployments_menu_spec.rb
@@ -3,7 +3,7 @@
require 'spec_helper'
RSpec.describe Sidebars::Projects::Menus::DeploymentsMenu do
- let_it_be(:project) { create(:project, :repository) }
+ let_it_be(:project, reload: true) { create(:project, :repository) }
let(:user) { project.first_owner }
let(:context) { Sidebars::Projects::Context.new(current_user: user, container: project) }
@@ -37,6 +37,40 @@ RSpec.describe Sidebars::Projects::Menus::DeploymentsMenu do
specify { is_expected.to be_nil }
end
+
+ describe 'when the feature is disabled' do
+ before do
+ project.update_attribute("#{item_id}_access_level", 'disabled')
+ end
+
+ it { is_expected.to be_nil }
+ end
+
+ describe 'when split_operations_visibility_permissions FF is disabled' do
+ before do
+ stub_feature_flags(split_operations_visibility_permissions: false)
+ end
+
+ it { is_expected.not_to be_nil }
+
+ context 'and the feature is disabled' do
+ before do
+ project.update_attribute("#{item_id}_access_level", 'disabled')
+ end
+
+ it { is_expected.not_to be_nil }
+ end
+
+ context 'and operations is disabled' do
+ before do
+ project.update_attribute(:operations_access_level, 'disabled')
+ end
+
+ it do
+ is_expected.to be_nil if [:environments, :feature_flags].include?(item_id)
+ end
+ end
+ end
end
describe 'Feature Flags' do