Commit 7eed995e authored by Ryan Cobb's avatar Ryan Cobb

Clean up specs

parent 9b7e934c
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Projects::MetricsDashboardController do
let_it_be(:project) { create(:project) }
let_it_be(:maintainer) { create(:user, name: 'main-dos').tap { |u| project.add_maintainer(u) } }
let(:user) { maintainer }
let!(:environment) { create(:environment, name: 'production', project: project) }
let!(:second_environment) { create(:environment, name: 'staging', project: project) }
before do
sign_in(user)
end
describe 'GET d' do
it 'responds with status code 200' do
get :metrics_dashboard_page, params: params
expect(response).to have_gitlab_http_status(:ok)
end
it 'assigns default environment' do
get :metrics_dashboard_page, params: params
expect(assigns(:environment).id).to eq(environment.id)
end
context 'with valid environment parameter' do
let(:valid_environment_params) { params(environment: second_environment.id) }
it 'responds with status code 200' do
get :metrics_dashboard_page, params: valid_environment_params
expect(response).to have_gitlab_http_status(:ok)
end
it 'assigns param environment' do
get :metrics_dashboard_page, params: valid_environment_params
expect(assigns(:environment).id).to eq(second_environment.id)
end
end
context 'with invalid environment parameter' do
let(:invalid_environment_params) { params(environment: 9999)}
it 'responds with 404' do
get :metrics_dashboard_page, params: invalid_environment_params
expect(response).to have_gitlab_http_status(:not_found)
end
end
context 'with custom dashboard path' do
it 'responds with status code 200' do
get :metrics_dashboard_page, params: params(dashboard_path: 'custom_dashboard_path.yml')
expect(response).to have_gitlab_http_status(:ok)
end
end
end
def params(opts = {})
opts.reverse_merge({
namespace_id: project.namespace,
project_id: project
})
end
end
......@@ -4,10 +4,10 @@ require 'spec_helper'
describe 'metrics dashboard page' do
# Further tests can be found at metrics_dashboard_controller_spec.rb
let(:project) { create(:project) }
let!(:environment) { create(:environment, project: project) }
let!(:environment2) { create(:environment, project: project) }
let(:user) { project.owner }
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)
......@@ -53,7 +53,7 @@ describe 'metrics dashboard page' do
expect(response).to have_gitlab_http_status(:ok)
end
it 'assigns environment0' do
it 'assigns environment' do
send_request(dashboard_path: dashboard_path)
expect(assigns(:environment).id).to eq(environment.id)
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