Commit 32679232 authored by James Lopez's avatar James Lopez

added the rest of the stages to the controller and relevant specs

parent d4726112
class Projects::CycleAnalytics::EventsController < Projects::ApplicationController class Projects::CycleAnalytics::EventsController < Projects::ApplicationController
#before_action :authorize_read_cycle_analytics! #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| respond_to do |format|
format.html format.html
format.json { render json: events.issue_events } format.json { render json: { events: event_list } }
end end
end end
private
# TODO refactor this # TODO refactor this
def start_date def start_date
case events_params[:start_date] case events_params[:start_date]
......
...@@ -155,7 +155,13 @@ resources :namespaces, path: '/', constraints: { id: /[a-zA-Z.0-9_\-]+/ }, only: ...@@ -155,7 +155,13 @@ resources :namespaces, path: '/', constraints: { id: /[a-zA-Z.0-9_\-]+/ }, only:
namespace :cycle_analytics do namespace :cycle_analytics do
scope :events, controller: '/projects/cycle_analytics/events' 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
end end
......
...@@ -3,18 +3,62 @@ require 'spec_helper' ...@@ -3,18 +3,62 @@ require 'spec_helper'
describe 'cycle analytics events' do describe 'cycle analytics events' do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:project) } let(:project) { create(:project) }
let!(:issue) { create(:issue, project: project, created_at: 2.days.ago) }
describe 'GET /:namespace/:project/cycle_analytics/events/issues' do describe 'GET /:namespace/:project/cycle_analytics/events/issues' do
before do before do
project.team << [user, :developer] 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) login_as(user)
end end
it 'lists the issue events' do 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
end 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