From 8c395f2f7d17ed84044c91bd632e83d6b803d5ce Mon Sep 17 00:00:00 2001 From: rpereira2 Date: Wed, 6 Feb 2019 18:38:00 +0530 Subject: Implement review suggestions - Use if else end instead of unless guard. - Use allow in before block instead of expect. --- app/controllers/projects/error_tracking_controller.rb | 10 +++++----- spec/controllers/projects/error_tracking_controller_spec.rb | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/controllers/projects/error_tracking_controller.rb b/app/controllers/projects/error_tracking_controller.rb index 2cd3dad12a2..88d0755f41f 100644 --- a/app/controllers/projects/error_tracking_controller.rb +++ b/app/controllers/projects/error_tracking_controller.rb @@ -48,7 +48,11 @@ class Projects::ErrorTrackingController < Projects::ApplicationController ) result = service.execute - unless result[:status] == :success + if result[:status] == :success + render json: { + projects: serialize_projects(result[:projects]) + } + else return render( status: result[:http_status] || :bad_request, json: { @@ -56,10 +60,6 @@ class Projects::ErrorTrackingController < Projects::ApplicationController } ) end - - render json: { - projects: serialize_projects(result[:projects]) - } end def list_projects_params diff --git a/spec/controllers/projects/error_tracking_controller_spec.rb b/spec/controllers/projects/error_tracking_controller_spec.rb index db23e3d917b..844c61f1ace 100644 --- a/spec/controllers/projects/error_tracking_controller_spec.rb +++ b/spec/controllers/projects/error_tracking_controller_spec.rb @@ -161,7 +161,7 @@ describe Projects::ErrorTrackingController do end before do - expect(ErrorTracking::ListProjectsService) + allow(ErrorTracking::ListProjectsService) .to receive(:new).with(project, user, permitted_params) .and_return(list_projects_service) end -- cgit v1.2.1