diff options
author | James Lopez <james@jameslopez.es> | 2016-10-24 15:49:25 +0100 |
---|---|---|
committer | James Lopez <james@jameslopez.es> | 2016-11-17 08:22:55 +0100 |
commit | 32679232635dbd0d196a91d0788ee1135ff56b43 (patch) | |
tree | e8efc365222449082446986f4428e27d68ca218d | |
parent | d4726112656df24ff7721865a96237d5168466f7 (diff) | |
download | gitlab-ce-32679232635dbd0d196a91d0788ee1135ff56b43.tar.gz |
added the rest of the stages to the controller and relevant specs
-rw-r--r-- | app/controllers/projects/cycle_analytics/events_controller.rb | 36 | ||||
-rw-r--r-- | config/routes/project.rb | 8 | ||||
-rw-r--r-- | spec/requests/projects/cycle_analytics_events_spec.rb | 48 |
3 files changed, 85 insertions, 7 deletions
diff --git a/app/controllers/projects/cycle_analytics/events_controller.rb b/app/controllers/projects/cycle_analytics/events_controller.rb index fe0135874b9..142cbc344a5 100644 --- a/app/controllers/projects/cycle_analytics/events_controller.rb +++ b/app/controllers/projects/cycle_analytics/events_controller.rb @@ -1,15 +1,43 @@ class Projects::CycleAnalytics::EventsController < Projects::ApplicationController #before_action :authorize_read_cycle_analytics! - def issues + def issue + render_events(events.issue_events) + end + + def plan + render_events(events.plan_events) + end + + def code + render_events(events.code_events) + end + + def test + render_events(events.test_events) + end + + def review + render_events(events.review_events) + end + + def staging + render_events(events.staging_events) + end + + def production + render_events(events.production_events) + end + + private + + def render_events(event_list) respond_to do |format| format.html - format.json { render json: events.issue_events } + format.json { render json: { events: event_list } } end end - private - # TODO refactor this def start_date case events_params[:start_date] diff --git a/config/routes/project.rb b/config/routes/project.rb index ed595c777f5..7e0536b464f 100644 --- a/config/routes/project.rb +++ b/config/routes/project.rb @@ -155,7 +155,13 @@ resources :namespaces, path: '/', constraints: { id: /[a-zA-Z.0-9_\-]+/ }, only: namespace :cycle_analytics do scope :events, controller: '/projects/cycle_analytics/events' do - get :issues + get :issue + get :plan + get :code + get :test + get :review + get :staging + get :production end end diff --git a/spec/requests/projects/cycle_analytics_events_spec.rb b/spec/requests/projects/cycle_analytics_events_spec.rb index 064434c127e..51db9bb07fa 100644 --- a/spec/requests/projects/cycle_analytics_events_spec.rb +++ b/spec/requests/projects/cycle_analytics_events_spec.rb @@ -3,18 +3,62 @@ require 'spec_helper' describe 'cycle analytics events' do let(:user) { create(:user) } let(:project) { create(:project) } + let!(:issue) { create(:issue, project: project, created_at: 2.days.ago) } describe 'GET /:namespace/:project/cycle_analytics/events/issues' do before do project.team << [user, :developer] + milestone = create(:milestone, project: project) + issue.update(milestone: milestone) + create_merge_request_closing_issue(issue) + + merge_merge_requests_closing_issue(issue) + deploy_master + login_as(user) end it 'lists the issue events' do - get namespace_project_cycle_analytics_issues_path(project.namespace, project, format: :json) + get namespace_project_cycle_analytics_issue_path(project.namespace, project, format: :json) + + expect(json_response['events']).not_to be_empty + end + + it 'lists the plan events' do + get namespace_project_cycle_analytics_plan_path(project.namespace, project, format: :json) + + expect(json_response['events']).not_to be_empty + end + + it 'lists the code events' do + get namespace_project_cycle_analytics_code_path(project.namespace, project, format: :json) + + expect(json_response['events']).not_to be_empty + end + + it 'lists the test events' do + get namespace_project_cycle_analytics_test_path(project.namespace, project, format: :json) + + expect(json_response['events']).not_to be_empty + end + + it 'lists the review events' do + get namespace_project_cycle_analytics_review_path(project.namespace, project, format: :json) + + expect(json_response['events']).not_to be_empty + end + + it 'lists the staging events' do + get namespace_project_cycle_analytics_staging_path(project.namespace, project, format: :json) + + expect(json_response['events']).not_to be_empty + end + + it 'lists the production events' do + get namespace_project_cycle_analytics_production_path(project.namespace, project, format: :json) - expect(json_response).to eq ([]) + expect(json_response['events']).not_to be_empty end end |