diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-17 12:09:52 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-17 12:09:52 +0000 |
commit | 8ae26d705abe341b03bc15d4373d6cd0c77c0baf (patch) | |
tree | 655ee03a968e340c975b8ab7d77cfd5ceaf3c969 /spec/lib/gitlab/checks/project_created_spec.rb | |
parent | fc1df8c8307fc5022f9e8aae04164c089d8fdf2e (diff) | |
download | gitlab-ce-8ae26d705abe341b03bc15d4373d6cd0c77c0baf.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/checks/project_created_spec.rb')
-rw-r--r-- | spec/lib/gitlab/checks/project_created_spec.rb | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/spec/lib/gitlab/checks/project_created_spec.rb b/spec/lib/gitlab/checks/project_created_spec.rb index 373fef2a240..bbc97155374 100644 --- a/spec/lib/gitlab/checks/project_created_spec.rb +++ b/spec/lib/gitlab/checks/project_created_spec.rb @@ -3,24 +3,29 @@ require 'spec_helper' describe Gitlab::Checks::ProjectCreated, :clean_gitlab_redis_shared_state do - let(:user) { create(:user) } - let(:project) { create(:project) } + let_it_be(:user) { create(:user) } + let_it_be(:project) { create(:project, :repository, namespace: user.namespace) } + let(:protocol) { 'http' } + let(:git_user) { user } + let(:repository) { project.repository } + + subject { described_class.new(repository, git_user, 'http') } describe '.fetch_message' do context 'with a project created message queue' do - let(:project_created) { described_class.new(project, user, 'http') } - before do - project_created.add_message + subject.add_message end it 'returns project created message' do - expect(described_class.fetch_message(user.id, project.id)).to eq(project_created.message) + expect(described_class.fetch_message(user.id, project.id)).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 + described_class.fetch_message(user.id, project.id) + expect(Gitlab::Redis::SharedState.with { |redis| redis.get("project_created:#{user.id}:#{project.id}") }).to be_nil end end @@ -34,15 +39,15 @@ describe Gitlab::Checks::ProjectCreated, :clean_gitlab_redis_shared_state do describe '#add_message' do it 'queues a project created message' do - project_created = described_class.new(project, user, 'http') - - expect(project_created.add_message).to eq('OK') + expect(subject.add_message).to eq('OK') end - it 'handles anonymous push' do - project_created = described_class.new(nil, user, 'http') + context 'when user is nil' do + let(:git_user) { nil } - expect(project_created.add_message).to be_nil + it 'handles anonymous push' do + expect(subject.add_message).to be_nil + end end end end |