diff options
Diffstat (limited to 'spec/lib/gitlab/checks/project_created_spec.rb')
-rw-r--r-- | spec/lib/gitlab/checks/project_created_spec.rb | 31 |
1 files changed, 26 insertions, 5 deletions
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 |