summaryrefslogtreecommitdiff
path: root/spec/requests/projects
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-07-20 12:26:25 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-07-20 12:26:25 +0000
commita09983ae35713f5a2bbb100981116d31ce99826e (patch)
tree2ee2af7bd104d57086db360a7e6d8c9d5d43667a /spec/requests/projects
parent18c5ab32b738c0b6ecb4d0df3994000482f34bd8 (diff)
downloadgitlab-ce-a09983ae35713f5a2bbb100981116d31ce99826e.tar.gz
Add latest changes from gitlab-org/gitlab@13-2-stable-ee
Diffstat (limited to 'spec/requests/projects')
-rw-r--r--spec/requests/projects/cycle_analytics_events_spec.rb2
-rw-r--r--spec/requests/projects/incident_management/pagerduty_incidents_spec.rb36
-rw-r--r--spec/requests/projects/merge_requests/creations_spec.rb2
-rw-r--r--spec/requests/projects/merge_requests_discussions_spec.rb2
-rw-r--r--spec/requests/projects/metrics_dashboard_spec.rb85
-rw-r--r--spec/requests/projects/uploads_spec.rb2
6 files changed, 125 insertions, 4 deletions
diff --git a/spec/requests/projects/cycle_analytics_events_spec.rb b/spec/requests/projects/cycle_analytics_events_spec.rb
index 773f243e733..8c3058d405c 100644
--- a/spec/requests/projects/cycle_analytics_events_spec.rb
+++ b/spec/requests/projects/cycle_analytics_events_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-describe 'value stream analytics events' do
+RSpec.describe 'value stream analytics events' do
let(:user) { create(:user) }
let(:project) { create(:project, :repository, public_builds: false) }
let(:issue) { create(:issue, project: project, created_at: 2.days.ago) }
diff --git a/spec/requests/projects/incident_management/pagerduty_incidents_spec.rb b/spec/requests/projects/incident_management/pagerduty_incidents_spec.rb
new file mode 100644
index 00000000000..c246aacb4c7
--- /dev/null
+++ b/spec/requests/projects/incident_management/pagerduty_incidents_spec.rb
@@ -0,0 +1,36 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe 'PagerDuty webhook' do
+ let_it_be(:project) { create(:project) }
+
+ describe 'POST /incidents/pagerduty' do
+ let(:payload) { Gitlab::Json.parse(fixture_file('pager_duty/webhook_incident_trigger.json')) }
+ let(:webhook_processor_class) { ::IncidentManagement::PagerDuty::ProcessWebhookService }
+ let(:webhook_processor) { instance_double(webhook_processor_class) }
+
+ def make_request
+ headers = { 'Content-Type' => 'application/json' }
+ post project_incidents_pagerduty_url(project, token: 'VALID-TOKEN'), params: payload.to_json, headers: headers
+ end
+
+ before do
+ allow(webhook_processor_class).to receive(:new).and_return(webhook_processor)
+ allow(webhook_processor).to receive(:execute).and_return(ServiceResponse.success(http_status: :accepted))
+ end
+
+ it 'calls PagerDuty webhook processor with correct parameters' do
+ make_request
+
+ expect(webhook_processor_class).to have_received(:new).with(project, nil, payload)
+ expect(webhook_processor).to have_received(:execute).with('VALID-TOKEN')
+ end
+
+ it 'responds with 202 Accepted' do
+ make_request
+
+ expect(response).to have_gitlab_http_status(:accepted)
+ end
+ end
+end
diff --git a/spec/requests/projects/merge_requests/creations_spec.rb b/spec/requests/projects/merge_requests/creations_spec.rb
index d192e1bca7f..0a3e663444f 100644
--- a/spec/requests/projects/merge_requests/creations_spec.rb
+++ b/spec/requests/projects/merge_requests/creations_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-describe 'merge requests creations' do
+RSpec.describe 'merge requests creations' do
describe 'GET /:namespace/:project/merge_requests/new' do
include ProjectForksHelper
diff --git a/spec/requests/projects/merge_requests_discussions_spec.rb b/spec/requests/projects/merge_requests_discussions_spec.rb
index 94e9c81bc3b..6ec586ed22c 100644
--- a/spec/requests/projects/merge_requests_discussions_spec.rb
+++ b/spec/requests/projects/merge_requests_discussions_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-describe 'merge requests discussions' do
+RSpec.describe 'merge requests discussions' do
# Further tests can be found at merge_requests_controller_spec.rb
describe 'GET /:namespace/:project/-/merge_requests/:iid/discussions' do
let(:project) { create(:project, :repository) }
diff --git a/spec/requests/projects/metrics_dashboard_spec.rb b/spec/requests/projects/metrics_dashboard_spec.rb
new file mode 100644
index 00000000000..ab35788387c
--- /dev/null
+++ b/spec/requests/projects/metrics_dashboard_spec.rb
@@ -0,0 +1,85 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe 'metrics dashboard page' do
+ let_it_be(:project) { create(:project) }
+ let_it_be(:environment) { create(:environment, project: project) }
+ let_it_be(:environment2) { create(:environment, project: project) }
+ let_it_be(:user) { project.owner }
+
+ before do
+ project.add_developer(user)
+ login_as(user)
+ end
+
+ describe 'GET /:namespace/:project/-/metrics' do
+ it 'returns 200' do
+ send_request
+ expect(response).to have_gitlab_http_status(:ok)
+ end
+
+ it 'assigns environment' do
+ send_request
+ expect(assigns(:environment).id).to eq(environment.id)
+ end
+ end
+
+ describe 'GET /:namespace/:project/-/metrics?environment=:environment.id' do
+ it 'returns 200' do
+ send_request(environment: environment2.id)
+ expect(response).to have_gitlab_http_status(:ok)
+ end
+
+ it 'assigns query param environment' do
+ send_request(environment: environment2.id)
+ expect(assigns(:environment).id).to eq(environment2.id)
+ end
+
+ context 'when query param environment does not exist' do
+ it 'responds with 404' do
+ send_request(environment: 99)
+ expect(response).to have_gitlab_http_status(:not_found)
+ end
+ end
+ end
+
+ describe 'GET /:namespace/:project/-/metrics/:dashboard_path' do
+ let(:dashboard_path) { '.gitlab/dashboards/dashboard_path.yml' }
+
+ it 'returns 200' do
+ send_request(dashboard_path: dashboard_path)
+ expect(response).to have_gitlab_http_status(:ok)
+ end
+
+ it 'assigns environment' do
+ send_request(dashboard_path: dashboard_path)
+ expect(assigns(:environment).id).to eq(environment.id)
+ end
+ end
+
+ describe 'GET :/namespace/:project/-/metrics/:dashboard_path?environment=:environment.id' do
+ let(:dashboard_path) { '.gitlab/dashboards/dashboard_path.yml' }
+
+ it 'returns 200' do
+ send_request(dahboard_path: dashboard_path, environment: environment.id)
+ expect(response).to have_gitlab_http_status(:ok)
+ end
+
+ it 'assigns query param environment' do
+ send_request(dashboard_path: dashboard_path, environment: environment2.id)
+ expect(assigns(:environment).id).to eq(environment2.id)
+ end
+
+ context 'when query param environment does not exist' do
+ it 'responds with 404' do
+ send_request(dashboard_path: dashboard_path, environment: 99)
+ expect(response).to have_gitlab_http_status(:not_found)
+ end
+ end
+ end
+
+ def send_request(params = {})
+ get namespace_project_metrics_dashboard_path(namespace_id: project.namespace, project_id: project, **params)
+ end
+end
diff --git a/spec/requests/projects/uploads_spec.rb b/spec/requests/projects/uploads_spec.rb
index aca4644289d..de5ef36be7e 100644
--- a/spec/requests/projects/uploads_spec.rb
+++ b/spec/requests/projects/uploads_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-describe 'File uploads' do
+RSpec.describe 'File uploads' do
include WorkhorseHelpers
let(:project) { create(:project, :public, :repository) }