diff options
author | Peter Leitzen <pleitzen@gitlab.com> | 2018-12-11 16:33:03 +0100 |
---|---|---|
committer | Peter Leitzen <pleitzen@gitlab.com> | 2019-01-02 19:41:49 +0100 |
commit | d90e44bbb5ed6c86906d3b6c3d5cf72596e47360 (patch) | |
tree | a5bdd31e82055ee00c02fcd67d367782e22f5620 | |
parent | 0f22b13dae1935e4171e856fdfaa71974c3fd9d3 (diff) | |
download | gitlab-ce-d90e44bbb5ed6c86906d3b6c3d5cf72596e47360.tar.gz |
Render empty list of errors
-rw-r--r-- | app/controllers/projects/error_tracking_controller.rb | 10 | ||||
-rw-r--r-- | app/helpers/projects/error_tracking_helper.rb | 12 | ||||
-rw-r--r-- | app/views/projects/error_tracking/list.html.haml | 3 | ||||
-rw-r--r-- | config/routes/project.rb | 6 | ||||
-rw-r--r-- | spec/controllers/projects/error_tracking_controller_spec.rb | 51 | ||||
-rw-r--r-- | spec/helpers/projects/error_tracking_helper_spec.rb | 21 |
6 files changed, 103 insertions, 0 deletions
diff --git a/app/controllers/projects/error_tracking_controller.rb b/app/controllers/projects/error_tracking_controller.rb new file mode 100644 index 00000000000..0d0472c6afb --- /dev/null +++ b/app/controllers/projects/error_tracking_controller.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +class Projects::ErrorTrackingController < Projects::ApplicationController + def list + end + + def index + render json: [] + end +end diff --git a/app/helpers/projects/error_tracking_helper.rb b/app/helpers/projects/error_tracking_helper.rb new file mode 100644 index 00000000000..4fb7278dd80 --- /dev/null +++ b/app/helpers/projects/error_tracking_helper.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +module Projects::ErrorTrackingHelper + def error_tracking_data(project) + { + 'index-path' => namespace_project_error_tracking_index_path( + namespace_id: project.namespace, + project_id: project + ) + } + end +end diff --git a/app/views/projects/error_tracking/list.html.haml b/app/views/projects/error_tracking/list.html.haml new file mode 100644 index 00000000000..bc02c5f0e5a --- /dev/null +++ b/app/views/projects/error_tracking/list.html.haml @@ -0,0 +1,3 @@ +- page_title _('Errors') + +#js-error_tracking{ data: error_tracking_data(@project) } diff --git a/config/routes/project.rb b/config/routes/project.rb index cbad8f317aa..f45fe1e1829 100644 --- a/config/routes/project.rb +++ b/config/routes/project.rb @@ -445,6 +445,12 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do end end + resources :error_tracking, only: [:index], controller: :error_tracking do + collection do + get :list + end + end + # Since both wiki and repository routing contains wildcard characters # its preferable to keep it below all other project routes draw :wiki diff --git a/spec/controllers/projects/error_tracking_controller_spec.rb b/spec/controllers/projects/error_tracking_controller_spec.rb new file mode 100644 index 00000000000..75ae0e1eb79 --- /dev/null +++ b/spec/controllers/projects/error_tracking_controller_spec.rb @@ -0,0 +1,51 @@ +# frozen_string_literal: true + +require 'rails_helper' + +RSpec.describe Projects::ErrorTrackingController, type: :controller do + set(:project) { create(:project) } + let(:user) { create(:user) } + + let(:json_response) { JSON.parse(response.body) } + + before do + sign_in(user) + project.add_maintainer(user) + end + + describe 'GET #list' do + it 'renders index with 200 status code' do + get :list, project_params + + expect(response).to have_gitlab_http_status(:ok) + expect(response).to render_template(:list) + end + + context 'with an anonymous user' do + before do + sign_out(user) + end + + it 'redirects to sign-in page' do + get :list, project_params + + expect(response).to redirect_to(new_user_session_path) + end + end + end + + describe 'GET #index' do + it 'returns an empty list of errors' do + get :index, project_params + + expect(response).to have_gitlab_http_status(:ok) + expect(json_response).to eq([]) + end + end + + private + + def project_params + { namespace_id: project.namespace, project_id: project } + end +end diff --git a/spec/helpers/projects/error_tracking_helper_spec.rb b/spec/helpers/projects/error_tracking_helper_spec.rb new file mode 100644 index 00000000000..3c709425dda --- /dev/null +++ b/spec/helpers/projects/error_tracking_helper_spec.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe Projects::ErrorTrackingHelper do + let(:project) { create(:project) } + + include Gitlab::Routing.url_helpers + + describe '#error_tracking_data' do + let(:index_path) do + "/#{project.namespace.path}/#{project.path}/error_tracking" + end + + it 'returns frontend configuration' do + expect(error_tracking_data(project)).to eq( + 'index-path' => index_path + ) + end + end +end |