diff options
author | Tiago Botelho <tiagonbotelho@hotmail.com> | 2018-01-25 12:26:52 +0000 |
---|---|---|
committer | Tiago Botelho <tiagonbotelho@hotmail.com> | 2018-02-06 13:35:35 +0000 |
commit | e42a548f1dac02577d0c1731fef508dab68c45a5 (patch) | |
tree | 9781b82ec0da58683ebeb0fd0ba2062a9ce10e43 /spec/lib | |
parent | bc78ae6985ee37f9ac2ffc2dbf6f445078d16038 (diff) | |
download | gitlab-ce-e42a548f1dac02577d0c1731fef508dab68c45a5.tar.gz |
Move new project on push logic to a service
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/gitlab/checks/new_project_spec.rb | 46 | ||||
-rw-r--r-- | spec/lib/gitlab/checks/project_created_spec.rb | 46 | ||||
-rw-r--r-- | spec/lib/gitlab/git_access_spec.rb | 13 |
3 files changed, 49 insertions, 56 deletions
diff --git a/spec/lib/gitlab/checks/new_project_spec.rb b/spec/lib/gitlab/checks/new_project_spec.rb deleted file mode 100644 index c696e02e41a..00000000000 --- a/spec/lib/gitlab/checks/new_project_spec.rb +++ /dev/null @@ -1,46 +0,0 @@ -require 'rails_helper' - -describe Gitlab::Checks::NewProject, :clean_gitlab_redis_shared_state do - let(:user) { create(:user) } - let(:project) { create(:project) } - - describe '.fetch_new_project_message' do - context 'with a new project message queue' do - let(:new_project) { described_class.new(user, project, 'http') } - - before do - new_project.add_new_project_message - end - - it 'returns new project message' do - expect(described_class.fetch_new_project_message(user.id, project.id)).to eq(new_project.new_project_message) - end - - it 'deletes the new project message from redis' do - expect(Gitlab::Redis::SharedState.with { |redis| redis.get("new_project:#{user.id}:#{project.id}") }).not_to be_nil - described_class.fetch_new_project_message(user.id, project.id) - expect(Gitlab::Redis::SharedState.with { |redis| redis.get("new_project:#{user.id}:#{project.id}") }).to be_nil - end - end - - context 'with no new project message queue' do - it 'returns nil' do - expect(described_class.fetch_new_project_message(1, 2)).to be_nil - end - end - end - - describe '#add_new_project_message' do - it 'queues a new project message' do - new_project = described_class.new(user, project, 'http') - - expect(new_project.add_new_project_message).to eq('OK') - end - - it 'handles anonymous push' do - new_project = described_class.new(user, nil, 'http') - - expect(new_project.add_new_project_message).to be_nil - end - end -end diff --git a/spec/lib/gitlab/checks/project_created_spec.rb b/spec/lib/gitlab/checks/project_created_spec.rb new file mode 100644 index 00000000000..c79798bc84d --- /dev/null +++ b/spec/lib/gitlab/checks/project_created_spec.rb @@ -0,0 +1,46 @@ +require 'rails_helper' + +describe Gitlab::Checks::ProjectCreated, :clean_gitlab_redis_shared_state do + let(:user) { create(:user) } + let(:project) { create(:project) } + + describe '.fetch_project_created_message' do + context 'with a project created message queue' do + let(:project_created) { described_class.new(user, project, 'http') } + + before do + project_created.add_project_created_message + end + + it 'returns project created message' do + expect(described_class.fetch_project_created_message(user.id, project.id)).to eq(project_created.project_created_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_project_created_message(user.id, project.id) + expect(Gitlab::Redis::SharedState.with { |redis| redis.get("project_created:#{user.id}:#{project.id}") }).to be_nil + end + end + + context 'with no project created message queue' do + it 'returns nil' do + expect(described_class.fetch_project_created_message(1, 2)).to be_nil + end + end + end + + describe '#add_project_created_message' do + it 'queues a project created message' do + project_created = described_class.new(user, project, 'http') + + expect(project_created.add_project_created_message).to eq('OK') + end + + it 'handles anonymous push' do + project_created = described_class.new(user, nil, 'http') + + expect(project_created.add_project_created_message).to be_nil + end + end +end diff --git a/spec/lib/gitlab/git_access_spec.rb b/spec/lib/gitlab/git_access_spec.rb index 3c98c95e301..e6ad35867c0 100644 --- a/spec/lib/gitlab/git_access_spec.rb +++ b/spec/lib/gitlab/git_access_spec.rb @@ -335,7 +335,7 @@ describe Gitlab::GitAccess do end end - describe '#check_namespace_accessibility!' do + describe '#check_namespace_existence!' do context 'when project exists' do context 'when user can pull or push' do before do @@ -838,18 +838,11 @@ describe Gitlab::GitAccess do end def raise_not_found - raise_error(Gitlab::GitAccess::NotFoundError, - Gitlab::GitAccess::ERROR_MESSAGES[:project_not_found]) + raise_error(Gitlab::GitAccess::NotFoundError, Gitlab::GitAccess::ERROR_MESSAGES[:project_not_found]) end def raise_namespace_not_found - raise_error(Gitlab::GitAccess::NotFoundError, - Gitlab::GitAccess::ERROR_MESSAGES[:namespace_not_found]) - end - - def raise_project_create - raise_error(Gitlab::GitAccess::NotFoundError, - Gitlab::GitAccess::ERROR_MESSAGES[:create]) + raise_error(Gitlab::GitAccess::NotFoundError, Gitlab::GitAccess::ERROR_MESSAGES[:namespace_not_found]) end def build_authentication_abilities |