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>2021-07-20 12:55:51 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-07-20 12:55:51 +0300
commite8d2c2579383897a1dd7f9debd359abe8ae8373d (patch)
treec42be41678c2586d49a75cabce89322082698334 /spec/lib/gitlab/checks
parentfc845b37ec3a90aaa719975f607740c22ba6a113 (diff)
Add latest changes from gitlab-org/gitlab@14-1-stable-eev14.1.0-rc42
Diffstat (limited to 'spec/lib/gitlab/checks')
-rw-r--r--spec/lib/gitlab/checks/container_moved_spec.rb (renamed from spec/lib/gitlab/checks/project_moved_spec.rb)44
-rw-r--r--spec/lib/gitlab/checks/project_created_spec.rb31
2 files changed, 61 insertions, 14 deletions
diff --git a/spec/lib/gitlab/checks/project_moved_spec.rb b/spec/lib/gitlab/checks/container_moved_spec.rb
index 469aea8d093..00ef5604e1d 100644
--- a/spec/lib/gitlab/checks/project_moved_spec.rb
+++ b/spec/lib/gitlab/checks/container_moved_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Gitlab::Checks::ProjectMoved, :clean_gitlab_redis_shared_state do
+RSpec.describe Gitlab::Checks::ContainerMoved, :clean_gitlab_redis_shared_state do
let_it_be(:user) { create(:user) }
let_it_be(:project) { create(:project, :repository, :wiki_repo, namespace: user.namespace) }
@@ -14,27 +14,48 @@ RSpec.describe Gitlab::Checks::ProjectMoved, :clean_gitlab_redis_shared_state do
subject { described_class.new(repository, git_user, protocol, redirect_path) }
describe '.fetch_message' do
+ let(:key) { "redirect_namespace:#{user.id}:#{project.repository.gl_repository}" }
+ let(:legacy_key) { "redirect_namespace:#{user.id}:#{project.id}" }
+
context 'with a redirect message queue' do
before do
subject.add_message
end
it 'returns the redirect message' do
- expect(described_class.fetch_message(user.id, project.id)).to eq(subject.message)
+ expect(described_class.fetch_message(user, project.repository)).to eq(subject.message)
end
it 'deletes the redirect message from redis' do
- expect(Gitlab::Redis::SharedState.with { |redis| redis.get("redirect_namespace:#{user.id}:#{project.id}") }).not_to be_nil
+ expect(Gitlab::Redis::SharedState.with { |redis| redis.get(key) }).not_to be_nil
- described_class.fetch_message(user.id, project.id)
+ described_class.fetch_message(user, project.repository)
- expect(Gitlab::Redis::SharedState.with { |redis| redis.get("redirect_namespace:#{user.id}:#{project.id}") }).to be_nil
+ expect(Gitlab::Redis::SharedState.with { |redis| redis.get(key) }).to be_nil
+ end
+
+ context 'with a message in the legacy key' do
+ before do
+ Gitlab::Redis::SharedState.with do |redis|
+ redis.set(legacy_key, 'legacy message')
+ end
+ end
+
+ it 'returns and deletes the legacy message' do
+ expect(Gitlab::Redis::SharedState.with { |redis| redis.get(key) }).not_to be_nil
+ expect(Gitlab::Redis::SharedState.with { |redis| redis.get(legacy_key) }).not_to be_nil
+
+ expect(described_class.fetch_message(user, project.repository)).to eq('legacy message')
+
+ expect(Gitlab::Redis::SharedState.with { |redis| redis.get(key) }).to be_nil
+ expect(Gitlab::Redis::SharedState.with { |redis| redis.get(legacy_key) }).to be_nil
+ end
end
end
context 'with no redirect message queue' do
it 'returns nil' do
- expect(described_class.fetch_message(1, 2)).to be_nil
+ expect(described_class.fetch_message(user, project.repository)).to be_nil
end
end
end
@@ -58,7 +79,7 @@ RSpec.describe Gitlab::Checks::ProjectMoved, :clean_gitlab_redis_shared_state do
shared_examples 'returns redirect message' do
it do
message = <<~MSG
- Project '#{redirect_path}' was moved to '#{project.full_path}'.
+ #{container_label} '#{redirect_path}' was moved to '#{repository.container.full_path}'.
Please update your Git remote:
@@ -86,6 +107,7 @@ RSpec.describe Gitlab::Checks::ProjectMoved, :clean_gitlab_redis_shared_state do
context 'with project' do
it_behaves_like 'errors per protocol' do
+ let(:container_label) { 'Project' }
let(:http_url_to_repo) { project.http_url_to_repo }
let(:ssh_url_to_repo) { project.ssh_url_to_repo }
end
@@ -95,6 +117,7 @@ RSpec.describe Gitlab::Checks::ProjectMoved, :clean_gitlab_redis_shared_state do
let(:repository) { project.wiki.repository }
it_behaves_like 'errors per protocol' do
+ let(:container_label) { 'Project wiki' }
let(:http_url_to_repo) { project.wiki.http_url_to_repo }
let(:ssh_url_to_repo) { project.wiki.ssh_url_to_repo }
end
@@ -106,6 +129,7 @@ RSpec.describe Gitlab::Checks::ProjectMoved, :clean_gitlab_redis_shared_state do
let(:repository) { snippet.repository }
it_behaves_like 'errors per protocol' do
+ let(:container_label) { 'Project snippet' }
let(:http_url_to_repo) { snippet.http_url_to_repo }
let(:ssh_url_to_repo) { snippet.ssh_url_to_repo }
end
@@ -116,8 +140,10 @@ RSpec.describe Gitlab::Checks::ProjectMoved, :clean_gitlab_redis_shared_state do
let(:repository) { snippet.repository }
- it 'returns nil' do
- expect(subject.add_message).to be_nil
+ it_behaves_like 'errors per protocol' do
+ let(:container_label) { 'Personal snippet' }
+ let(:http_url_to_repo) { snippet.http_url_to_repo }
+ let(:ssh_url_to_repo) { snippet.ssh_url_to_repo }
end
end
end
diff --git a/spec/lib/gitlab/checks/project_created_spec.rb b/spec/lib/gitlab/checks/project_created_spec.rb
index 74e43b04b6b..6a2e4201030 100644
--- a/spec/lib/gitlab/checks/project_created_spec.rb
+++ b/spec/lib/gitlab/checks/project_created_spec.rb
@@ -13,27 +13,48 @@ RSpec.describe Gitlab::Checks::ProjectCreated, :clean_gitlab_redis_shared_state
subject { described_class.new(repository, git_user, 'http') }
describe '.fetch_message' do
+ let(:key) { "project_created:#{user.id}:#{project.repository.gl_repository}" }
+ let(:legacy_key) { "project_created:#{user.id}:#{project.id}" }
+
context 'with a project created message queue' do
before do
subject.add_message
end
it 'returns project created message' do
- expect(described_class.fetch_message(user.id, project.id)).to eq(subject.message)
+ expect(described_class.fetch_message(user, project.repository)).to eq(subject.message)
end
it 'deletes the project created message from redis' do
- expect(Gitlab::Redis::SharedState.with { |redis| redis.get("project_created:#{user.id}:#{project.id}") }).not_to be_nil
+ expect(Gitlab::Redis::SharedState.with { |redis| redis.get(key) }).not_to be_nil
+
+ described_class.fetch_message(user, project.repository)
+
+ expect(Gitlab::Redis::SharedState.with { |redis| redis.get(key) }).to be_nil
+ end
+
+ context 'with a message in the legacy key' do
+ before do
+ Gitlab::Redis::SharedState.with do |redis|
+ redis.set(legacy_key, 'legacy message')
+ end
+ end
+
+ it 'returns and deletes the legacy message' do
+ expect(Gitlab::Redis::SharedState.with { |redis| redis.get(key) }).not_to be_nil
+ expect(Gitlab::Redis::SharedState.with { |redis| redis.get(legacy_key) }).not_to be_nil
- described_class.fetch_message(user.id, project.id)
+ expect(described_class.fetch_message(user, project.repository)).to eq('legacy message')
- expect(Gitlab::Redis::SharedState.with { |redis| redis.get("project_created:#{user.id}:#{project.id}") }).to be_nil
+ expect(Gitlab::Redis::SharedState.with { |redis| redis.get(key) }).to be_nil
+ expect(Gitlab::Redis::SharedState.with { |redis| redis.get(legacy_key) }).to be_nil
+ end
end
end
context 'with no project created message queue' do
it 'returns nil' do
- expect(described_class.fetch_message(1, 2)).to be_nil
+ expect(described_class.fetch_message(user, project.repository)).to be_nil
end
end
end