diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-30 12:07:58 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-30 12:07:58 +0300 |
commit | 45b4df3e57c949c88107840c44ccbfaf2eabdf26 (patch) | |
tree | f73c1533a75b03d2ceb1361644e0d8ab97568a8f /spec/requests | |
parent | 7421e6f9f2b5889b05738af7eba568af6ae3fcbc (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/requests')
4 files changed, 48 insertions, 7 deletions
diff --git a/spec/requests/api/container_registry_event_spec.rb b/spec/requests/api/container_registry_event_spec.rb new file mode 100644 index 00000000000..9c144f80fd4 --- /dev/null +++ b/spec/requests/api/container_registry_event_spec.rb @@ -0,0 +1,41 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe API::ContainerRegistryEvent do + let(:secret_token) { 'secret_token' } + let(:events) { [{ action: 'push' }] } + let(:registry_headers) { { 'Content-Type' => ::API::ContainerRegistryEvent::DOCKER_DISTRIBUTION_EVENTS_V1_JSON } } + + describe 'POST /container_registry_event/events' do + before do + allow(Gitlab.config.registry).to receive(:notification_secret) { secret_token } + end + + subject do + post api('/container_registry_event/events'), + params: { events: events }.to_json, + headers: registry_headers.merge('Authorization' => secret_token) + end + + it 'returns 200 status and events are passed to event handler' do + event = spy(:event) + allow(::ContainerRegistry::Event).to receive(:new).and_return(event) + expect(event).to receive(:supported?).and_return(true) + + subject + + expect(event).to have_received(:handle!).once + expect(event).to have_received(:track!).once + expect(response.status).to eq 200 + end + + it 'returns 401 error status when token is invalid' do + post api('/container_registry_event/events'), + params: { events: events }.to_json, + headers: registry_headers.merge('Authorization' => 'invalid_token') + + expect(response.status).to eq 401 + end + end +end diff --git a/spec/requests/api/graphql/namespace/root_storage_statistics_spec.rb b/spec/requests/api/graphql/namespace/root_storage_statistics_spec.rb index ac76d991bd4..f7e28043930 100644 --- a/spec/requests/api/graphql/namespace/root_storage_statistics_spec.rb +++ b/spec/requests/api/graphql/namespace/root_storage_statistics_spec.rb @@ -6,7 +6,7 @@ describe 'rendering namespace statistics' do include GraphqlHelpers let(:namespace) { user.namespace } - let!(:statistics) { create(:namespace_root_storage_statistics, namespace: namespace, packages_size: 5.megabytes) } + let!(:statistics) { create(:namespace_root_storage_statistics, namespace: namespace, packages_size: 5.gigabytes) } let(:user) { create(:user) } let(:query) do @@ -26,7 +26,7 @@ describe 'rendering namespace statistics' do post_graphql(query, current_user: user) expect(graphql_data['namespace']['rootStorageStatistics']).not_to be_blank - expect(graphql_data['namespace']['rootStorageStatistics']['packagesSize']).to eq(5.megabytes) + expect(graphql_data['namespace']['rootStorageStatistics']['packagesSize']).to eq(5.gigabytes) end end diff --git a/spec/requests/api/graphql/project/project_statistics_spec.rb b/spec/requests/api/graphql/project/project_statistics_spec.rb index ddee8537454..05dd5d36c26 100644 --- a/spec/requests/api/graphql/project/project_statistics_spec.rb +++ b/spec/requests/api/graphql/project/project_statistics_spec.rb @@ -6,7 +6,7 @@ describe 'rendering project statistics' do include GraphqlHelpers let(:project) { create(:project) } - let!(:project_statistics) { create(:project_statistics, project: project, packages_size: 5.megabytes) } + let!(:project_statistics) { create(:project_statistics, project: project, packages_size: 5.gigabytes) } let(:user) { create(:user) } let(:query) do @@ -28,7 +28,7 @@ describe 'rendering project statistics' do it "includes the packages size if the user can read the statistics" do post_graphql(query, current_user: user) - expect(graphql_data['project']['statistics']['packagesSize']).to eq(5.megabytes) + expect(graphql_data['project']['statistics']['packagesSize']).to eq(5.gigabytes) end context 'when the project is public' do diff --git a/spec/requests/api/project_templates_spec.rb b/spec/requests/api/project_templates_spec.rb index 50b950fb5c1..5dabce20043 100644 --- a/spec/requests/api/project_templates_spec.rb +++ b/spec/requests/api/project_templates_spec.rb @@ -3,9 +3,9 @@ require 'spec_helper' describe API::ProjectTemplates do - let(:public_project) { create(:project, :public) } - let(:private_project) { create(:project, :private) } - let(:developer) { create(:user) } + let_it_be(:public_project) { create(:project, :public) } + let_it_be(:private_project) { create(:project, :private) } + let_it_be(:developer) { create(:user) } before do private_project.add_developer(developer) |