Commit 6d7078e7 authored by Bala Kumar's avatar Bala Kumar Committed by Shinya Maeda

Resolve "Use Same Endpoint for HTML and JSON in OperationsController"

parent b8376928
# frozen_string_literal: true
# Note: Both Operations dashboard (https://docs.gitlab.com/ee/user/operations_dashboard/) and Environments dashboard (https://docs.gitlab.com/ee/ci/environments/environments_dashboard.html) features are co-existing in the same controller.
class OperationsController < ApplicationController
before_action :authorize_read_operations_dashboard!
respond_to :json, only: [:list]
feature_category :release_orchestration
POLLING_INTERVAL = 120_000
# Used by Operations dashboard.
def index
end
respond_to do |format|
format.html
def environments
end
format.json do
set_polling_interval_header
projects = load_projects
def list
Gitlab::PollingInterval.set_header(response, interval: POLLING_INTERVAL)
projects = load_projects
render json: { projects: serialize_as_json(projects) }
render json: { projects: serialize_as_json(projects) }
end
end
end
def environments_list
Gitlab::PollingInterval.set_header(response, interval: POLLING_INTERVAL)
projects = load_environments_projects
# Used by Environments dashboard.
def environments
respond_to do |format|
format.html
render json: { projects: serialize_as_json_for_environments(projects) }
format.json do
set_polling_interval_header
projects = load_environments_projects
render json: { projects: serialize_as_json_for_environments(projects) }
end
end
end
# Used by Operations and Environments dashboard.
def create
project_ids = params['project_ids']
result = add_projects(project_ids)
render json: {
added: result.added_project_ids,
duplicate: result.duplicate_project_ids,
invalid: result.invalid_project_ids
}
respond_to do |format|
format.json do
project_ids = params['project_ids']
result = add_projects(project_ids)
render json: {
added: result.added_project_ids,
duplicate: result.duplicate_project_ids,
invalid: result.invalid_project_ids
}
end
end
end
# Used by Operations and Environments dashboard.
def destroy
project_id = params['project_id']
......@@ -57,6 +70,10 @@ class OperationsController < ApplicationController
render_404 unless can?(current_user, :read_operations_dashboard)
end
def set_polling_interval_header
Gitlab::PollingInterval.set_header(response, interval: POLLING_INTERVAL)
end
def load_projects
Dashboard::Operations::ListService.new(current_user).execute
end
......
......@@ -6,8 +6,8 @@ module EE
def operations_data
{
'add-path' => add_operations_project_path,
'list-path' => operations_list_path,
'add-path' => add_operations_project_path(format: :json),
'list-path' => operations_path(format: :json),
'empty-dashboard-svg-path' => image_path('illustrations/operations-dashboard_empty.svg'),
'empty-dashboard-help-path' => help_page_path('user/operations_dashboard/index.md')
}
......@@ -15,8 +15,8 @@ module EE
def environments_data
{
'add-path' => add_operations_project_path,
'list-path' => operations_environments_list_path,
'add-path' => add_operations_environments_project_path(format: :json),
'list-path' => operations_environments_path(format: :json),
'empty-dashboard-svg-path' => image_path('illustrations/operations-dashboard_empty.svg'),
'empty-dashboard-help-path' => help_page_path('ci/environments/environments_dashboard.md'),
'environments-dashboard-help-path' => help_page_path('ci/environments/environments_dashboard.md')
......
......@@ -9,7 +9,7 @@ class DashboardEnvironmentsProjectEntity < Grape::Entity
expose :web_url
expose :remove_path do |project|
remove_operations_project_path(project_id: project.id)
remove_operations_environments_project_path(project_id: project.id)
end
expose :namespace, using: API::Entities::NamespaceBasic
......
# frozen_string_literal: true
# Used by Operations dashboard
get 'operations' => 'operations#index'
get 'operations/environments' => 'operations#environments'
get 'operations/list' => 'operations#list'
get 'operations/environments_list' => 'operations#environments_list'
post 'operations' => 'operations#create', as: :add_operations_project
delete 'operations' => 'operations#destroy', as: :remove_operations_project
# Used by Environments dashboard
get 'operations/environments' => 'operations#environments'
post 'operations/environments' => 'operations#create', as: :add_operations_environments_project
delete 'operations/environments' => 'operations#destroy', as: :remove_operations_environments_project
......@@ -14,634 +14,648 @@ RSpec.describe OperationsController do
sign_in(user)
end
shared_examples 'unlicensed' do |http_method, action|
shared_examples 'unlicensed' do |http_method, action, format = :html|
before do
stub_licensed_features(operations_dashboard: false)
end
it 'renders 404' do
public_send(http_method, action)
public_send(http_method, action, format: format)
expect(response).to have_gitlab_http_status(:not_found)
end
end
describe 'GET #index' do
it_behaves_like 'unlicensed', :get, :index
def get_index(format)
get :index, format: format
end
it 'renders index with 200 status code' do
get :index
describe 'format html' do
it_behaves_like 'unlicensed', :get, :index, :html
expect(response).to have_gitlab_http_status(:ok)
expect(response).to render_template(:index)
end
it 'renders index with 200 status code' do
get_index(:html)
context 'with an anonymous user' do
before do
sign_out(user)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to render_template(:index)
end
it 'redirects to sign-in page' do
get :index
context 'with an anonymous user' do
before do
sign_out(user)
end
expect(response).to redirect_to(new_user_session_path)
it 'redirects to sign-in page' do
get_index(:html)
expect(response).to redirect_to(new_user_session_path)
end
end
end
end
describe 'GET #environments' do
it_behaves_like 'unlicensed', :get, :environments
describe 'format json' do
let(:now) { Time.current.change(usec: 0) }
let(:project) { create(:project, :repository) }
let(:commit) { project.commit }
let!(:environment) { create(:environment, name: 'production', project: project) }
let!(:deployment) { create(:deployment, :success, environment: environment, sha: commit.id, created_at: now, project: project) }
it 'renders the view' do
get :environments
it_behaves_like 'unlicensed', :get, :index, :json
expect(response).to have_gitlab_http_status(:ok)
expect(response).to render_template(:environments)
end
shared_examples 'empty project list' do
it 'returns an empty list' do
get_index(:json)
context 'with an anonymous user' do
before do
sign_out(user)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to match_schema('dashboard/operations/list', dir: 'ee')
expect(json_response['projects']).to eq([])
end
end
it 'redirects to sign-in page' do
get :environments
context 'with added projects' do
let(:alert1) { create(:prometheus_alert, project: project, environment: environment) }
let(:alert2) { create(:prometheus_alert, project: project, environment: environment) }
expect(response).to redirect_to(new_user_session_path)
end
end
end
let!(:alert_events) do
[
create(:alert_management_alert, prometheus_alert: alert1, project: project, environment: environment),
create(:alert_management_alert, prometheus_alert: alert2, project: project, environment: environment),
create(:alert_management_alert, prometheus_alert: alert1, project: project, environment: environment),
create(:alert_management_alert, :resolved, prometheus_alert: alert2, project: project, environment: environment)
]
end
describe 'GET #list' do
let(:now) { Time.current.change(usec: 0) }
let(:project) { create(:project, :repository) }
let(:commit) { project.commit }
let!(:environment) { create(:environment, name: 'production', project: project) }
let!(:deployment) { create(:deployment, :success, environment: environment, sha: commit.id, created_at: now, project: project) }
let(:open_alerts) { alert_events.select(&:triggered?) + alert_events.select(&:acknowledged?) }
let(:last_firing_alert) { open_alerts.last.prometheus_alert }
it_behaves_like 'unlicensed', :get, :list
let(:alert_path) do
metrics_project_environment_path(project, environment)
end
shared_examples 'empty project list' do
it 'returns an empty list' do
get :list
let(:alert_json_path) do
project_prometheus_alert_path(project, last_firing_alert.prometheus_metric_id,
environment_id: environment, format: :json)
end
expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to match_schema('dashboard/operations/list', dir: 'ee')
expect(json_response['projects']).to eq([])
end
end
let(:expected_project) { json_response['projects'].first }
context 'with added projects' do
let(:alert1) { create(:prometheus_alert, project: project, environment: environment) }
let(:alert2) { create(:prometheus_alert, project: project, environment: environment) }
let!(:alert_events) do
[
create(:alert_management_alert, prometheus_alert: alert1, project: project, environment: environment),
create(:alert_management_alert, prometheus_alert: alert2, project: project, environment: environment),
create(:alert_management_alert, prometheus_alert: alert1, project: project, environment: environment),
create(:alert_management_alert, :resolved, prometheus_alert: alert2, project: project, environment: environment)
]
end
before do
user.update!(ops_dashboard_projects: [project])
project.add_developer(user)
end
let(:open_alerts) { alert_events.select(&:triggered?) + alert_events.select(&:acknowledged?) }
let(:last_firing_alert) { open_alerts.last.prometheus_alert }
it 'returns a list of added projects' do
get_index(:json)
let(:alert_path) do
metrics_project_environment_path(project, environment)
end
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('dashboard/operations/list', dir: 'ee')
let(:alert_json_path) do
project_prometheus_alert_path(project, last_firing_alert.prometheus_metric_id,
environment_id: environment, format: :json)
end
expect(json_response['projects'].size).to eq(1)
let(:expected_project) { json_response['projects'].first }
expect(expected_project['id']).to eq(project.id)
expect(expected_project['remove_path'])
.to eq(remove_operations_project_path(project_id: project.id))
expect(expected_project['last_deployment']['id']).to eq(deployment.id)
expect(expected_project['alert_count']).to eq(open_alerts.size)
expect(expected_project['alert_path']).to eq(alert_path)
expect(expected_project['last_alert']['id']).to eq(last_firing_alert.id)
end
before do
user.update!(ops_dashboard_projects: [project])
project.add_developer(user)
end
it "returns as many projects as are in the user's dashboard" do
projects = Array.new(8).map do
project = create(:project)
project.add_developer(user)
project
end
user.update!(ops_dashboard_projects: projects)
it 'returns a list of added projects' do
get :list
get_index(:json)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('dashboard/operations/list', dir: 'ee')
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('dashboard/operations/list', dir: 'ee')
expect(json_response['projects'].size).to eq(1)
expect(json_response['projects'].size).to eq(8)
end
expect(expected_project['id']).to eq(project.id)
expect(expected_project['remove_path'])
.to eq(remove_operations_project_path(project_id: project.id))
expect(expected_project['last_deployment']['id']).to eq(deployment.id)
expect(expected_project['alert_count']).to eq(open_alerts.size)
expect(expected_project['alert_path']).to eq(alert_path)
expect(expected_project['last_alert']['id']).to eq(last_firing_alert.id)
end
it 'returns a list of added projects' do
get_index(:json)
it "returns as many projects as are in the user's dashboard" do
projects = Array.new(8).map do
project = create(:project)
project.add_developer(user)
project
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('dashboard/operations/list', dir: 'ee')
expect(json_response['projects'].size).to eq(1)
expect(expected_project['id']).to eq(project.id)
end
user.update!(ops_dashboard_projects: projects)
get :list
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('dashboard/operations/list', dir: 'ee')
context 'without sufficient access level' do
before do
project.add_reporter(user)
end
expect(json_response['projects'].size).to eq(8)
it_behaves_like 'empty project list'
end
end
it 'returns a list of added projects' do
get :list
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('dashboard/operations/list', dir: 'ee')
expect(json_response['projects'].size).to eq(1)
expect(expected_project['id']).to eq(project.id)
context 'without projects' do
it_behaves_like 'empty project list'
end
context 'without sufficient access level' do
context 'with an anonymous user' do
before do
project.add_reporter(user)
sign_out(user)
end
it_behaves_like 'empty project list'
end
end
context 'without projects' do
it_behaves_like 'empty project list'
end
context 'with an anonymous user' do
before do
sign_out(user)
end
it 'returns unauthorized response' do
get_index(:json)
it 'redirects to sign-in page' do
get :list
expect(response).to redirect_to(new_user_session_path)
expect(response).to have_gitlab_http_status(:unauthorized)
expect(json_response['error']).to include('sign in or sign up before continuing')
end
end
end
end
describe 'GET #environments_list' do
it_behaves_like 'unlicensed', :get, :environments_list
describe 'GET #environments' do
def get_environments(format, params = nil)
get :environments, params: params, format: format
end
context 'with an anonymous user' do
before do
sign_out(user)
end
describe 'format html' do
it_behaves_like 'unlicensed', :get, :environments, :html
it 'redirects to sign-in page' do
get :environments_list
it 'renders the view' do
get_environments(:html)
expect(response).to redirect_to(new_user_session_path)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to render_template(:environments)
end
end
context 'with an authenticated user without sufficient access_level' do
it 'returns an empty project list' do
project = create(:project)
project.add_reporter(user)
user.update!(ops_dashboard_projects: [project])
context 'with an anonymous user' do
before do
sign_out(user)
end
get :environments_list
it 'redirects to sign-in page' do
get_environments(:html)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['projects']).to eq([])
expect(response).to redirect_to(new_user_session_path)
end
end
end
context 'with an authenticated developer' do
it 'returns an empty project list' do
get :environments_list
describe 'format json' do
it_behaves_like 'unlicensed', :get, :environments, :json
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['projects']).to eq([])
end
context 'with an anonymous user' do
before do
sign_out(user)
end
it 'sets the polling interval header' do
get :environments_list
it 'returns unauthorized response' do
get_environments(:json)
expect(response).to have_gitlab_http_status(:ok)
expect(response.headers[Gitlab::PollingInterval::HEADER_NAME]).to eq('120000')
expect(response).to have_gitlab_http_status(:unauthorized)
expect(json_response['error']).to include('sign in or sign up before continuing')
end
end
it "returns an empty project list when the project is not in the developer's dashboard" do
project = create(:project)
project.add_developer(user)
user.update!(ops_dashboard_projects: [])
context 'with an authenticated user without sufficient access_level' do
it 'returns an empty project list' do
project = create(:project)
project.add_reporter(user)
user.update!(ops_dashboard_projects: [project])
get :environments_list
get_environments(:json)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['projects']).to eq([])
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['projects']).to eq([])
end
end
context 'with a project in the dashboard' do
let(:project) { create(:project, :with_avatar, :repository) }
context 'with an authenticated developer' do
it 'returns an empty project list' do
get_environments(:json)
before do
project.add_developer(user)
user.update!(ops_dashboard_projects: [project])
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['projects']).to eq([])
end
it 'returns a project without an environment' do
get :environments_list
it 'sets the polling interval header' do
get_environments(:json)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('dashboard/operations/environments_list', dir: 'ee')
expect(response.headers[Gitlab::PollingInterval::HEADER_NAME]).to eq('120000')
end
project_json = json_response['projects'].first
it "returns an empty project list when the project is not in the developer's dashboard" do
project = create(:project)
project.add_developer(user)
user.update!(ops_dashboard_projects: [])
get_environments(:json)
expect(project_json['id']).to eq(project.id)
expect(project_json['name']).to eq(project.name)
expect(project_json['namespace']['id']).to eq(project.namespace.id)
expect(project_json['namespace']['name']).to eq(project.namespace.name)
expect(project_json['environments']).to eq([])
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['projects']).to eq([])
end
it 'returns one project with one environment' do
environment = create(:environment, project: project, name: 'staging')
context 'with a project in the dashboard' do
let(:project) { create(:project, :with_avatar, :repository) }
get :environments_list
before do
project.add_developer(user)
user.update!(ops_dashboard_projects: [project])
end
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('dashboard/operations/environments_list', dir: 'ee')
it 'returns a project without an environment' do
get_environments(:json)
project_json = json_response['projects'].first
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('dashboard/operations/environments', dir: 'ee')
expect(project_json['id']).to eq(project.id)
expect(project_json['name']).to eq(project.name)
expect(project_json['namespace']['id']).to eq(project.namespace.id)
expect(project_json['namespace']['name']).to eq(project.namespace.name)
expect(project_json['environments'].count).to eq(1)
expect(project_json['environments'].first['id']).to eq(environment.id)
expect(project_json['environments'].first['environment_path']).to eq(project_environment_path(project, environment))
end
project_json = json_response['projects'].first
it 'returns multiple projects and environments' do
project2 = create(:project)
project2.add_developer(user)
user.update!(ops_dashboard_projects: [project, project2])
environment1 = create(:environment, project: project)
environment2 = create(:environment, project: project)
environment3 = create(:environment, project: project2)
expect(project_json['id']).to eq(project.id)
expect(project_json['name']).to eq(project.name)
expect(project_json['namespace']['id']).to eq(project.namespace.id)
expect(project_json['namespace']['name']).to eq(project.namespace.name)
expect(project_json['environments']).to eq([])
end
get :environments_list
it 'returns one project with one environment' do
environment = create(:environment, project: project, name: 'staging')
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('dashboard/operations/environments_list', dir: 'ee')
expect(json_response['projects'].count).to eq(2)
expect(json_response['projects'].map { |p| p['id'] }.sort).to eq([project.id, project2.id])
get_environments(:json)
project_json = json_response['projects'].find { |p| p['id'] == project.id }
project2_json = json_response['projects'].find { |p| p['id'] == project2.id }
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('dashboard/operations/environments', dir: 'ee')
expect(project_json['environments'].map { |e| e['id'] }.sort).to eq([environment1.id, environment2.id])
expect(project2_json['environments'].map { |e| e['id'] }).to eq([environment3.id])
end
project_json = json_response['projects'].first
it 'does not return environments that would be grouped into a folder' do
create(:environment, project: project, name: 'review/test-feature')
create(:environment, project: project, name: 'review/another-feature')
expect(project_json['id']).to eq(project.id)
expect(project_json['name']).to eq(project.name)
expect(project_json['namespace']['id']).to eq(project.namespace.id)
expect(project_json['namespace']['name']).to eq(project.namespace.name)
expect(project_json['environments'].count).to eq(1)
expect(project_json['environments'].first['id']).to eq(environment.id)
expect(project_json['environments'].first['environment_path']).to eq(project_environment_path(project, environment))
end
get :environments_list
it 'returns multiple projects and environments' do
project2 = create(:project)
project2.add_developer(user)
user.update!(ops_dashboard_projects: [project, project2])
environment1 = create(:environment, project: project)
environment2 = create(:environment, project: project)
environment3 = create(:environment, project: project2)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('dashboard/operations/environments_list', dir: 'ee')
get_environments(:json)
project_json = json_response['projects'].first
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('dashboard/operations/environments', dir: 'ee')
expect(json_response['projects'].count).to eq(2)
expect(json_response['projects'].map { |p| p['id'] }.sort).to eq([project.id, project2.id])
expect(project_json['environments'].count).to eq(0)
end
project_json = json_response['projects'].find { |p| p['id'] == project.id }
project2_json = json_response['projects'].find { |p| p['id'] == project2.id }
it 'does not return environments that would be grouped into a folder even when there is only a single environment' do
create(:environment, project: project, name: 'staging/test-feature')
expect(project_json['environments'].map { |e| e['id'] }.sort).to eq([environment1.id, environment2.id])
expect(project2_json['environments'].map { |e| e['id'] }).to eq([environment3.id])
end
get :environments_list
it 'does not return environments that would be grouped into a folder' do
create(:environment, project: project, name: 'review/test-feature')
create(:environment, project: project, name: 'review/another-feature')
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('dashboard/operations/environments_list', dir: 'ee')
get_environments(:json)
project_json = json_response['projects'].first
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('dashboard/operations/environments', dir: 'ee')
expect(project_json['environments'].count).to eq(0)
end
project_json = json_response['projects'].first
it 'returns an environment not in a folder' do
environment = create(:environment, project: project, name: 'production')
expect(project_json['environments'].count).to eq(0)
end
get :environments_list
it 'does not return environments that would be grouped into a folder even when there is only a single environment' do
create(:environment, project: project, name: 'staging/test-feature')
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('dashboard/operations/environments_list', dir: 'ee')
get_environments(:json)
project_json = json_response['projects'].first
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('dashboard/operations/environments', dir: 'ee')
expect(project_json['environments'].count).to eq(1)
expect(project_json['environments'].first['id']).to eq(environment.id)
end
project_json = json_response['projects'].first
it 'returns the last deployment for an environment' do
environment = create(:environment, project: project)
deployment = create(:deployment, :success, project: project, environment: environment)
expect(project_json['environments'].count).to eq(0)
end
get :environments_list
it 'returns an environment not in a folder' do
environment = create(:environment, project: project, name: 'production')
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('dashboard/operations/environments_list', dir: 'ee')
get_environments(:json)
project_json = json_response['projects'].first
environment_json = project_json['environments'].first
last_deployment_json = environment_json['last_deployment']
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('dashboard/operations/environments', dir: 'ee')
expect(last_deployment_json['id']).to eq(deployment.id)
end
project_json = json_response['projects'].first
it "returns the last deployment's deployable" do
environment = create(:environment, project: project)
ci_build = create(:ci_build, project: project)
create(:deployment, :success, project: project, environment: environment, deployable: ci_build)
expect(project_json['environments'].count).to eq(1)
expect(project_json['environments'].first['id']).to eq(environment.id)
end
get :environments_list
it 'returns the last deployment for an environment' do
environment = create(:environment, project: project)
deployment = create(:deployment, :success, project: project, environment: environment)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('dashboard/operations/environments_list', dir: 'ee')
get_environments(:json)
project_json = json_response['projects'].first
environment_json = project_json['environments'].first
deployable_json = environment_json['last_deployment']['deployable']
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('dashboard/operations/environments', dir: 'ee')
expect(deployable_json['id']).to eq(ci_build.id)
expect(deployable_json['build_path']).to eq(project_job_path(project, ci_build))
end
project_json = json_response['projects'].first
environment_json = project_json['environments'].first
last_deployment_json = environment_json['last_deployment']
it 'returns a failed deployment' do
environment = create(:environment, project: project)
deployment = create(:deployment, :failed, project: project, environment: environment)
expect(last_deployment_json['id']).to eq(deployment.id)
end
get :environments_list
it "returns the last deployment's deployable" do
environment = create(:environment, project: project)
ci_build = create(:ci_build, project: project)
create(:deployment, :success, project: project, environment: environment, deployable: ci_build)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('dashboard/operations/environments_list', dir: 'ee')
get_environments(:json)
project_json = json_response['projects'].first
environment_json = project_json['environments'].first
last_deployment_json = environment_json['last_deployment']
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('dashboard/operations/environments', dir: 'ee')
expect(last_deployment_json['id']).to eq(deployment.id)
end
project_json = json_response['projects'].first
environment_json = project_json['environments'].first
deployable_json = environment_json['last_deployment']['deployable']
context 'with environments pagination' do
shared_examples_for 'environments pagination' do |params, projects_count|
specify do
get :environments_list, params: params
expect(deployable_json['id']).to eq(ci_build.id)
expect(deployable_json['build_path']).to eq(project_job_path(project, ci_build))
end
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('dashboard/operations/environments_list', dir: 'ee')
expect(json_response['projects'].count).to eq(projects_count)
expect(response).to include_pagination_headers
end
it 'returns a failed deployment' do
environment = create(:environment, project: project)
deployment = create(:deployment, :failed, project: project, environment: environment)
get_environments(:json)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('dashboard/operations/environments', dir: 'ee')
project_json = json_response['projects'].first
environment_json = project_json['environments'].first
last_deployment_json = environment_json['last_deployment']
expect(last_deployment_json['id']).to eq(deployment.id)
end
context 'pagination behaviour' do
before do
projects = create_list(:project, 8) do |project|
project.add_developer(user)
context 'with environments pagination' do
shared_examples_for 'environments pagination' do |params, projects_count|
specify do
get_environments(:json, params)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('dashboard/operations/environments', dir: 'ee')
expect(json_response['projects'].count).to eq(projects_count)
expect(response).to include_pagination_headers
end
user.update!(ops_dashboard_projects: projects)
end
context 'with `per_page`' do
it_behaves_like 'environments pagination', { per_page: 7 }, 7
end
context 'pagination behaviour' do
before do
projects = create_list(:project, 8) do |project|
project.add_developer(user)
end
user.update!(ops_dashboard_projects: projects)
end
context 'with `page=1`' do
it_behaves_like 'environments pagination', { per_page: 7, page: 1 }, 7
end
context 'with `per_page`' do
it_behaves_like 'environments pagination', { per_page: 7 }, 7
end
context 'with `page=2`' do
it_behaves_like 'environments pagination', { per_page: 7, page: 2 }, 1
context 'with `page=1`' do
it_behaves_like 'environments pagination', { per_page: 7, page: 1 }, 7
end
context 'with `page=2`' do
it_behaves_like 'environments pagination', { per_page: 7, page: 2 }, 1
end
end
end
context 'N+1 queries' do
subject { get :environments_list }
context 'N+1 queries' do
subject { get_environments(:json) }
it 'avoids N+1 database queries' do
control_count = ActiveRecord::QueryRecorder.new { subject }.count
it 'avoids N+1 database queries' do
control_count = ActiveRecord::QueryRecorder.new { subject }.count
projects = create_list(:project, 8) do |project|
project.add_developer(user)
end
user.update!(ops_dashboard_projects: projects)
projects = create_list(:project, 8) do |project|
project.add_developer(user)
end
user.update!(ops_dashboard_projects: projects)
expect { subject }.not_to exceed_query_limit(control_count)
expect { subject }.not_to exceed_query_limit(control_count)
end
end
end
end
it 'does not return a project for which the operations dashboard feature is unavailable' do
stub_application_setting(check_namespace_plan: true)
namespace = create(:namespace, visibility_level: PRIVATE)
unavailable_project = create(:project, namespace: namespace, visibility_level: PRIVATE)
unavailable_project.add_developer(user)
user.update!(ops_dashboard_projects: [unavailable_project])
get :environments_list
it 'does not return a project for which the operations dashboard feature is unavailable' do
stub_application_setting(check_namespace_plan: true)
namespace = create(:namespace, visibility_level: PRIVATE)
unavailable_project = create(:project, namespace: namespace, visibility_level: PRIVATE)
unavailable_project.add_developer(user)
user.update!(ops_dashboard_projects: [unavailable_project])
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('dashboard/operations/environments_list', dir: 'ee')
expect(json_response['projects'].count).to eq(0)
end
get_environments(:json)
it 'returns seven projects when some projects do not have the dashboard feature available' do
stub_application_setting(check_namespace_plan: true)
public_namespace = create(:namespace, visibility_level: PUBLIC)
public_projects = Array.new(7).map do
project = create(:project, namespace: public_namespace, visibility_level: PUBLIC)
project.add_developer(user)
project
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('dashboard/operations/environments', dir: 'ee')
expect(json_response['projects'].count).to eq(0)
end
private_namespace = create(:namespace, visibility_level: PRIVATE)
private_project = create(:project, namespace: private_namespace, visibility_level: PRIVATE)
private_project.add_developer(user)
it 'returns seven projects when some projects do not have the dashboard feature available' do
stub_application_setting(check_namespace_plan: true)
all_projects = [private_project] + public_projects
user.update!(ops_dashboard_projects: all_projects)
public_namespace = create(:namespace, visibility_level: PUBLIC)
public_projects = Array.new(7).map do
project = create(:project, namespace: public_namespace, visibility_level: PUBLIC)
project.add_developer(user)
project
end
get :environments_list
private_namespace = create(:namespace, visibility_level: PRIVATE)
private_project = create(:project, namespace: private_namespace, visibility_level: PRIVATE)
private_project.add_developer(user)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('dashboard/operations/environments_list', dir: 'ee')
expect(json_response['projects'].count).to eq(7)
all_projects = [private_project] + public_projects
user.update!(ops_dashboard_projects: all_projects)
actual_ids = json_response['projects'].map { |p| p['id'].to_i }
expected_ids = public_projects.map(&:id)
get_environments(:json)
expect(actual_ids).to contain_exactly(*expected_ids)
end
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('dashboard/operations/environments', dir: 'ee')
expect(json_response['projects'].count).to eq(7)
it 'returns a maximum of three environments for a project' do
create(:environment, project: project)
create(:environment, project: project)
create(:environment, project: project)
create(:environment, project: project)
actual_ids = json_response['projects'].map { |p| p['id'].to_i }
expected_ids = public_projects.map(&:id)
get :environments_list
expect(actual_ids).to contain_exactly(*expected_ids)
end
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('dashboard/operations/environments_list', dir: 'ee')
it 'returns a maximum of three environments for a project' do
create(:environment, project: project)
create(:environment, project: project)
create(:environment, project: project)
create(:environment, project: project)
project_json = json_response['projects'].first
get_environments(:json)
expect(project_json['environments'].count).to eq(3)
end
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('dashboard/operations/environments', dir: 'ee')
it 'returns a maximum of three environments for multiple projects' do
project_b = create(:project)
project_b.add_developer(user)
create(:environment, project: project)
create(:environment, project: project)
create(:environment, project: project)
create(:environment, project: project)
create(:environment, project: project_b)
create(:environment, project: project_b)
create(:environment, project: project_b)
create(:environment, project: project_b)
user.update!(ops_dashboard_projects: [project, project_b])
get :environments_list
project_json = json_response['projects'].first
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('dashboard/operations/environments_list', dir: 'ee')
expect(project_json['environments'].count).to eq(3)
end
project_json = json_response['projects'].find { |p| p['id'] == project.id }
project_b_json = json_response['projects'].find { |p| p['id'] == project_b.id }
it 'returns a maximum of three environments for multiple projects' do
project_b = create(:project)
project_b.add_developer(user)
create(:environment, project: project)
create(:environment, project: project)
create(:environment, project: project)
create(:environment, project: project)
create(:environment, project: project_b)
create(:environment, project: project_b)
create(:environment, project: project_b)
create(:environment, project: project_b)
user.update!(ops_dashboard_projects: [project, project_b])
get_environments(:json)
expect(project_json['environments'].count).to eq(3)
expect(project_b_json['environments'].count).to eq(3)
end
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('dashboard/operations/environments', dir: 'ee')
context 'with a pipeline' do
let(:project) { create(:project, :repository) }
let(:commit) { project.commit }
let(:environment) { create(:environment, project: project) }
project_json = json_response['projects'].find { |p| p['id'] == project.id }
project_b_json = json_response['projects'].find { |p| p['id'] == project_b.id }
before do
project.add_developer(user)
user.update!(ops_dashboard_projects: [project])
expect(project_json['environments'].count).to eq(3)
expect(project_b_json['environments'].count).to eq(3)
end
it 'returns the last pipeline for an environment' do
pipeline = create(:ci_pipeline, project: project, user: user, sha: commit.sha)
ci_build = create(:ci_build, project: project, pipeline: pipeline)
create(:deployment, :success, project: project, environment: environment, deployable: ci_build, sha: commit.sha)
context 'with a pipeline' do
let(:project) { create(:project, :repository) }
let(:commit) { project.commit }
let(:environment) { create(:environment, project: project) }
get :environments_list
before do
project.add_developer(user)
user.update!(ops_dashboard_projects: [project])
end
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('dashboard/operations/environments_list', dir: 'ee')
it 'returns the last pipeline for an environment' do
pipeline = create(:ci_pipeline, project: project, user: user, sha: commit.sha)
ci_build = create(:ci_build, project: project, pipeline: pipeline)
create(:deployment, :success, project: project, environment: environment, deployable: ci_build, sha: commit.sha)
project_json = json_response['projects'].first
environment_json = project_json['environments'].first
last_pipeline_json = environment_json['last_pipeline']
get_environments(:json)
expect(last_pipeline_json['id']).to eq(pipeline.id)
expect(last_pipeline_json['triggered']).to eq([])
expect(last_pipeline_json['triggered_by']).to be_nil
end
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('dashboard/operations/environments', dir: 'ee')
it 'returns the last pipeline details' do
pipeline = create(:ci_pipeline, project: project, user: user, sha: commit.sha, status: :canceled)
ci_build = create(:ci_build, project: project, pipeline: pipeline)
create(:deployment, :canceled, project: project, environment: environment, deployable: ci_build, sha: commit.sha)
project_json = json_response['projects'].first
environment_json = project_json['environments'].first
last_pipeline_json = environment_json['last_pipeline']
get :environments_list
expect(last_pipeline_json['id']).to eq(pipeline.id)
expect(last_pipeline_json['triggered']).to eq([])
expect(last_pipeline_json['triggered_by']).to be_nil
end
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('dashboard/operations/environments_list', dir: 'ee')
it 'returns the last pipeline details' do
pipeline = create(:ci_pipeline, project: project, user: user, sha: commit.sha, status: :canceled)
ci_build = create(:ci_build, project: project, pipeline: pipeline)
create(:deployment, :canceled, project: project, environment: environment, deployable: ci_build, sha: commit.sha)
project_json = json_response['projects'].first
environment_json = project_json['environments'].first
last_pipeline_json = environment_json['last_pipeline']
expected_details_path = project_pipeline_path(project, pipeline)
get_environments(:json)
expect(last_pipeline_json.dig('details', 'status', 'group')).to eq('canceled')
expect(last_pipeline_json.dig('details', 'status', 'tooltip')).to eq('canceled')
expect(last_pipeline_json.dig('details', 'status', 'details_path')).to eq(expected_details_path)
end
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('dashboard/operations/environments', dir: 'ee')
it 'returns an upstream pipeline' do
project_b = create(:project, :repository)
project_b.add_developer(user)
commit_b = project_b.commit
pipeline_b = create(:ci_pipeline, project: project_b, user: user, sha: commit_b.sha)
ci_build_b = create(:ci_build, project: project_b, pipeline: pipeline_b)
pipeline = create(:ci_pipeline, project: project, user: user, sha: commit.sha)
ci_build = create(:ci_build, project: project, pipeline: pipeline)
create(:deployment, :success, project: project, environment: environment, deployable: ci_build, sha: commit.sha)
create(:ci_sources_pipeline, project: project, pipeline: pipeline, source_project: project_b, source_pipeline: pipeline_b, source_job: ci_build_b)
project_json = json_response['projects'].first
environment_json = project_json['environments'].first
last_pipeline_json = environment_json['last_pipeline']
expected_details_path = project_pipeline_path(project, pipeline)
get :environments_list
expect(last_pipeline_json.dig('details', 'status', 'group')).to eq('canceled')
expect(last_pipeline_json.dig('details', 'status', 'tooltip')).to eq('canceled')
expect(last_pipeline_json.dig('details', 'status', 'details_path')).to eq(expected_details_path)
end
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('dashboard/operations/environments_list', dir: 'ee')
it 'returns an upstream pipeline' do
project_b = create(:project, :repository)
project_b.add_developer(user)
commit_b = project_b.commit
pipeline_b = create(:ci_pipeline, project: project_b, user: user, sha: commit_b.sha)
ci_build_b = create(:ci_build, project: project_b, pipeline: pipeline_b)
pipeline = create(:ci_pipeline, project: project, user: user, sha: commit.sha)
ci_build = create(:ci_build, project: project, pipeline: pipeline)
create(:deployment, :success, project: project, environment: environment, deployable: ci_build, sha: commit.sha)
create(:ci_sources_pipeline, project: project, pipeline: pipeline, source_project: project_b, source_pipeline: pipeline_b, source_job: ci_build_b)
project_json = json_response['projects'].first
environment_json = project_json['environments'].first
last_pipeline_json = environment_json['last_pipeline']
triggered_by_pipeline_json = last_pipeline_json['triggered_by']
get_environments(:json)
expected_details_path = project_pipeline_path(project_b, pipeline_b)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('dashboard/operations/environments', dir: 'ee')
expect(last_pipeline_json['id']).to eq(pipeline.id)
expect(triggered_by_pipeline_json['id']).to eq(pipeline_b.id)
expect(triggered_by_pipeline_json.dig('details', 'status', 'details_path')).to eq(expected_details_path)
expect(triggered_by_pipeline_json.dig('project', 'full_name')).to eq(project_b.full_name)
end
project_json = json_response['projects'].first
environment_json = project_json['environments'].first
last_pipeline_json = environment_json['last_pipeline']
triggered_by_pipeline_json = last_pipeline_json['triggered_by']
it 'returns a downstream pipeline' do
project_b = create(:project, :repository)
project_b.add_developer(user)
commit_b = project_b.commit
pipeline_b = create(:ci_pipeline, :failed, project: project_b, user: user, sha: commit_b.sha)
create(:ci_build, :failed, project: project_b, pipeline: pipeline_b)
pipeline = create(:ci_pipeline, project: project, user: user, sha: commit.sha)
ci_build = create(:ci_build, project: project, pipeline: pipeline)
create(:deployment, :success, project: project, environment: environment, deployable: ci_build, sha: commit.sha)
create(:ci_sources_pipeline, project: project_b, pipeline: pipeline_b, source_project: project, source_pipeline: pipeline, source_job: ci_build)
expected_details_path = project_pipeline_path(project_b, pipeline_b)
get :environments_list
expect(last_pipeline_json['id']).to eq(pipeline.id)
expect(triggered_by_pipeline_json['id']).to eq(pipeline_b.id)
expect(triggered_by_pipeline_json.dig('details', 'status', 'details_path')).to eq(expected_details_path)
expect(triggered_by_pipeline_json.dig('project', 'full_name')).to eq(project_b.full_name)
end
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('dashboard/operations/environments_list', dir: 'ee')
it 'returns a downstream pipeline' do
project_b = create(:project, :repository)
project_b.add_developer(user)
commit_b = project_b.commit
pipeline_b = create(:ci_pipeline, :failed, project: project_b, user: user, sha: commit_b.sha)
create(:ci_build, :failed, project: project_b, pipeline: pipeline_b)
pipeline = create(:ci_pipeline, project: project, user: user, sha: commit.sha)
ci_build = create(:ci_build, project: project, pipeline: pipeline)
create(:deployment, :success, project: project, environment: environment, deployable: ci_build, sha: commit.sha)
create(:ci_sources_pipeline, project: project_b, pipeline: pipeline_b, source_project: project, source_pipeline: pipeline, source_job: ci_build)
project_json = json_response['projects'].first
environment_json = project_json['environments'].first
last_pipeline_json = environment_json['last_pipeline']
get_environments(:json)
expect(last_pipeline_json['triggered'].count).to eq(1)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('dashboard/operations/environments', dir: 'ee')
triggered_pipeline_json = last_pipeline_json['triggered'].first
project_json = json_response['projects'].first
environment_json = project_json['environments'].first
last_pipeline_json = environment_json['last_pipeline']
expected_details_path = project_pipeline_path(project_b, pipeline_b)
expect(last_pipeline_json['triggered'].count).to eq(1)
expect(last_pipeline_json['id']).to eq(pipeline.id)
expect(triggered_pipeline_json['id']).to eq(pipeline_b.id)
expect(triggered_pipeline_json.dig('details', 'status', 'details_path')).to eq(expected_details_path)
expect(triggered_pipeline_json.dig('details', 'status', 'group')).to eq('failed')
expect(triggered_pipeline_json.dig('project', 'full_name')).to eq(project_b.full_name)
triggered_pipeline_json = last_pipeline_json['triggered'].first
expected_details_path = project_pipeline_path(project_b, pipeline_b)
expect(last_pipeline_json['id']).to eq(pipeline.id)
expect(triggered_pipeline_json['id']).to eq(pipeline_b.id)
expect(triggered_pipeline_json.dig('details', 'status', 'details_path')).to eq(expected_details_path)
expect(triggered_pipeline_json.dig('details', 'status', 'group')).to eq('failed')
expect(triggered_pipeline_json.dig('project', 'full_name')).to eq(project_b.full_name)
end
end
end
end
......@@ -649,88 +663,94 @@ RSpec.describe OperationsController do
end
describe 'POST #create' do
it_behaves_like 'unlicensed', :post, :create
context 'without added projects' do
let(:project_a) { create(:project) }
let(:project_b) { create(:project) }
describe 'format json' do
it_behaves_like 'unlicensed', :post, :create, :json
before do
project_a.add_developer(user)
project_b.add_developer(user)
def post_create(params)
post :create, params: params, format: :json
end
it 'adds projects to the dashboard' do
post :create, params: { project_ids: [project_a.id, project_b.id.to_s] }
context 'without added projects' do
let(:project_a) { create(:project) }
let(:project_b) { create(:project) }
expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to match_schema('dashboard/operations/add', dir: 'ee')
expect(json_response['added']).to contain_exactly(project_a.id, project_b.id)
expect(json_response['duplicate']).to be_empty
expect(json_response['invalid']).to be_empty
before do
project_a.add_developer(user)
project_b.add_developer(user)
end
user.reload
expect(user.ops_dashboard_projects).to contain_exactly(project_a, project_b)
end
it 'adds projects to the dashboard' do
post_create({ project_ids: [project_a.id, project_b.id.to_s] })
it 'cannot add a project twice' do
post :create, params: { project_ids: [project_a.id, project_a.id] }
expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to match_schema('dashboard/operations/add', dir: 'ee')
expect(json_response['added']).to contain_exactly(project_a.id, project_b.id)
expect(json_response['duplicate']).to be_empty
expect(json_response['invalid']).to be_empty
expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to match_schema('dashboard/operations/add', dir: 'ee')
expect(json_response['added']).to contain_exactly(project_a.id)
expect(json_response['duplicate']).to be_empty
expect(json_response['invalid']).to be_empty
user.reload
expect(user.ops_dashboard_projects).to contain_exactly(project_a, project_b)
end
user.reload
expect(user.ops_dashboard_projects).to eq([project_a])
end
it 'cannot add a project twice' do
post_create({ project_ids: [project_a.id, project_a.id] })
it 'does not add invalid project ids' do
post :create, params: { project_ids: ['', -1, '-2'] }
expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to match_schema('dashboard/operations/add', dir: 'ee')
expect(json_response['added']).to contain_exactly(project_a.id)
expect(json_response['duplicate']).to be_empty
expect(json_response['invalid']).to be_empty
expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to match_schema('dashboard/operations/add', dir: 'ee')
expect(json_response['added']).to be_empty
expect(json_response['duplicate']).to be_empty
expect(json_response['invalid']).to contain_exactly(0, -1, -2)
user.reload
expect(user.ops_dashboard_projects).to eq([project_a])
end
user.reload
expect(user.ops_dashboard_projects).to be_empty
end
end
it 'does not add invalid project ids' do
post_create({ project_ids: ['', -1, '-2'] })
context 'with added project' do
let(:project) { create(:project) }
expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to match_schema('dashboard/operations/add', dir: 'ee')
expect(json_response['added']).to be_empty
expect(json_response['duplicate']).to be_empty
expect(json_response['invalid']).to contain_exactly(0, -1, -2)
before do
user.ops_dashboard_projects << project
project.add_developer(user)
user.reload
expect(user.ops_dashboard_projects).to be_empty
end
end
it 'does not add already added project' do
post :create, params: { project_ids: [project.id] }
context 'with added project' do
let(:project) { create(:project) }
expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to match_schema('dashboard/operations/add', dir: 'ee')
expect(json_response['added']).to be_empty
expect(json_response['duplicate']).to contain_exactly(project.id)
expect(json_response['invalid']).to be_empty
before do
user.ops_dashboard_projects << project
project.add_developer(user)
end
user.reload
expect(user.ops_dashboard_projects).to eq([project])
end
end
it 'does not add already added project' do
post_create({ project_ids: [project.id] })
context 'with an anonymous user' do
before do
sign_out(user)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to match_schema('dashboard/operations/add', dir: 'ee')
expect(json_response['added']).to be_empty
expect(json_response['duplicate']).to contain_exactly(project.id)
expect(json_response['invalid']).to be_empty
user.reload
expect(user.ops_dashboard_projects).to eq([project])
end
end
it 'redirects to sign-in page' do
post :create
context 'with an anonymous user' do
before do
sign_out(user)
end
expect(response).to redirect_to(new_user_session_path)
it 'redirects to sign-in page' do
post :create
expect(response).to redirect_to(new_user_session_path)
end
end
end
end
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Operations routing', 'routing' do
describe '/-/operations' do
it 'routes to the operations index action' do
expect(get("#{operations_path}.html")).to route_to(
controller: 'operations',
action: 'index',
format: 'html')
expect(get("#{operations_path}.json")).to route_to(
controller: 'operations',
action: 'index',
format: 'json')
end
it 'routes to the operations create action' do
expect(post("#{add_operations_project_path}.json")).to route_to(
controller: 'operations',
action: 'create',
format: 'json')
end
it 'routes to operations destroy action' do
expect(delete("#{remove_operations_project_path}.json")).to route_to(
controller: 'operations',
action: 'destroy',
format: 'json')
end
end
describe '/-/operations/environments' do
it 'routes to the environments list action' do
expect(get("#{operations_environments_path}.html")).to route_to(
controller: 'operations',
action: 'environments',
format: 'html')
expect(get("#{operations_environments_path}.json")).to route_to(
controller: 'operations',
action: 'environments',
format: 'json')
end
it 'routes to the environments create action' do
expect(post("#{add_operations_environments_project_path}.json")).to route_to(
controller: 'operations',
action: 'create',
format: 'json')
end
it 'routes to environments destroy action' do
expect(delete("#{remove_operations_environments_project_path}.json")).to route_to(
controller: 'operations',
action: 'destroy',
format: 'json')
end
end
end
......@@ -6,8 +6,8 @@ RSpec.describe 'operations/environments.html.haml' do
it 'renders the frontend configuration' do
render
expect(rendered).to match %r{data-add-path="/-/operations"}
expect(rendered).to match %r{data-list-path="/-/operations/environments_list"}
expect(rendered).to match %r{data-add-path="/-/operations/environments.json"}
expect(rendered).to match %r{data-list-path="/-/operations/environments.json"}
expect(rendered).to match %r{data-empty-dashboard-svg-path="/assets/illustrations/operations-dashboard_empty.*\.svg"}
expect(rendered).to match %r{data-empty-dashboard-help-path="/help/ci/environments/environments_dashboard.md"}
expect(rendered).to match %r{data-environments-dashboard-help-path="/help/ci/environments/environments_dashboard.md"}
......
......@@ -6,8 +6,8 @@ RSpec.describe 'operations/index.html.haml' do
it 'renders the frontend configuration' do
render
expect(rendered).to match %r{data-add-path="/-/operations"}
expect(rendered).to match %r{data-list-path="/-/operations/list"}
expect(rendered).to match %r{data-add-path="/-/operations.json"}
expect(rendered).to match %r{data-list-path="/-/operations.json"}
expect(rendered).to match %{data-empty-dashboard-svg-path="/assets/illustrations/operations-dashboard_empty.*\.svg"}
expect(rendered).to match %r{data-empty-dashboard-help-path="/help/user/operations_dashboard/index.md"}
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment