Update Planner API with correct status codes

Refs FALCOR-183

Change-Id: Iab0447b92ce959ee31e8ba1734379639c93a7f62
Reviewed-on: https://gerrit.instructure.com/112323
Reviewed-by: Steven Burnett <sburnett@instructure.com>
Tested-by: Jenkins
Product-Review: Dan Minkevitch <dan@instructure.com>
QA-Review: Dan Minkevitch <dan@instructure.com>
This commit is contained in:
Dan Minkevitch 2017-05-18 12:32:04 -07:00
parent 16276bb5bb
commit 0258c4d760
3 changed files with 13 additions and 11 deletions

View File

@ -133,7 +133,7 @@ class PlannerOverridesController < ApplicationController
#
# @returns PlannerOverride
def show
planner_override = PlannerOverride.find(params[:override_id])
planner_override = PlannerOverride.find(params[:id])
if planner_override.present?
render json: planner_override
@ -148,11 +148,11 @@ class PlannerOverridesController < ApplicationController
#
# @returns PlannerOverride
def update
planner_override = PlannerOverride.find(params[:override_id])
planner_override = PlannerOverride.find(params[:id])
planner_override.visible = value_to_boolean(params[:visible])
if planner_override.save
render json: planner_override, status: :updated
render json: planner_override, status: :ok
else
render json: planner_override.errors, status: :bad_request
end
@ -182,10 +182,10 @@ class PlannerOverridesController < ApplicationController
#
# @returns PlannerOverride
def destroy
planner_override = PlannerOverride.find(params[:override_id])
planner_override = PlannerOverride.find(params[:id])
if planner_override.destroy
render json: planner_override, status: :deleted
render json: planner_override, status: :ok
else
render json: planner_override.errors, status: :bad_request
end

View File

@ -1947,10 +1947,10 @@ CanvasRails::Application.routes.draw do
scope(controller: :planner_overrides) do
get 'planner/items', action: :items_index, as: :planner_overrides
get 'planner/overrides', action: :index
get 'planner/overrides/:override_id', action: :show
put 'planner/overrides/:override_id', action: :update
get 'planner/overrides/:id', action: :show
put 'planner/overrides/:id', action: :update
post 'planner/overrides', action: :create
delete 'planner/overrides/:override_id', action: :destroy
delete 'planner/overrides/:id', action: :destroy
end
end

View File

@ -74,7 +74,7 @@ describe PlannerOverridesController do
describe "GET #show" do
it "returns http success" do
get :show, override_id: @planner_override.id
get :show, id: @planner_override.id
expect(response).to have_http_status(:success)
end
end
@ -82,7 +82,8 @@ describe PlannerOverridesController do
describe "PUT #update" do
it "returns http success" do
expect(@planner_override.visible).to be_truthy
put :update, override_id: @planner_override.id, visible: false
put :update, id: @planner_override.id, visible: false
expect(response).to have_http_status(:success)
expect(@planner_override.reload.visible).to be_falsey
end
end
@ -97,7 +98,8 @@ describe PlannerOverridesController do
describe "DELETE #destroy" do
it "returns http success" do
delete :destroy, override_id: @planner_override.id
delete :destroy, id: @planner_override.id
expect(response).to have_http_status(:success)
expect(@planner_override.reload).to be_deleted
end
end