summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2015-01-28 20:41:54 -0700
committermo khan <mo@mokhan.ca>2015-01-28 20:44:49 -0700
commit75aafe08cfee22e6235559313d79824fddc76dbf (patch)
tree001b987113641a9b967fd64623f4f0f689827d15
parent5d2760887c92accf322d5401611b392328029245 (diff)
return json response from deleting a cake.
-rw-r--r--app/controllers/api/v1/cakes_controller.rb1
-rw-r--r--app/views/api/v1/cakes/destroy.json.jbuilder1
-rw-r--r--spec/controllers/api/v1/cakes_controller_spec.rb7
3 files changed, 7 insertions, 2 deletions
diff --git a/app/controllers/api/v1/cakes_controller.rb b/app/controllers/api/v1/cakes_controller.rb
index 7680fa16..8888d286 100644
--- a/app/controllers/api/v1/cakes_controller.rb
+++ b/app/controllers/api/v1/cakes_controller.rb
@@ -28,7 +28,6 @@ module Api
def destroy
@cake = current_user.creations.find(params[:id])
@cake.destroy!
- render nothing: true
end
private
diff --git a/app/views/api/v1/cakes/destroy.json.jbuilder b/app/views/api/v1/cakes/destroy.json.jbuilder
new file mode 100644
index 00000000..ad6ffbe4
--- /dev/null
+++ b/app/views/api/v1/cakes/destroy.json.jbuilder
@@ -0,0 +1 @@
+json.partial! 'cake', cake: @cake
diff --git a/spec/controllers/api/v1/cakes_controller_spec.rb b/spec/controllers/api/v1/cakes_controller_spec.rb
index e0cb3a64..7f84d3ae 100644
--- a/spec/controllers/api/v1/cakes_controller_spec.rb
+++ b/spec/controllers/api/v1/cakes_controller_spec.rb
@@ -66,7 +66,7 @@ describe Api::V1::CakesController do
end
it "updates the description" do
- new_story = "what's the haps on the craps"
+ new_story = "what is the haps on the craps"
xhr :patch, :update, id: cake.id, cake: { story: new_story }
cake.reload
@@ -93,6 +93,11 @@ describe Api::V1::CakesController do
it "deletes the specified cake" do
expect(Creation.exists?(cake.id)).to be_falsey
end
+
+ it "returns an empty json response" do
+ json = JSON.parse(response.body)
+ expect(json["id"]).to eql(cake.id)
+ end
end
end
end