aboutsummaryrefslogtreecommitdiffstats
path: root/spec/controllers/api_controller_spec.rb
diff options
context:
space:
mode:
authorSeb Bacon <seb.bacon@gmail.com>2012-05-24 13:50:23 +0100
committerRobin Houston <robin.houston@gmail.com>2012-06-06 19:34:57 +0100
commit257ba137aa1ba1b2357e3fdc8a83e2c6947cae3d (patch)
treea9b70c403c85d40d0f25a1c38134beb3d45a08f1 /spec/controllers/api_controller_spec.rb
parent8263c7a92c8ef4313a65dc6bfd75b6eca1250ebc (diff)
Fix test and fixtures so they only fail due to missing business logic (corrected typo, added missing fixture data, etc)
Diffstat (limited to 'spec/controllers/api_controller_spec.rb')
-rw-r--r--spec/controllers/api_controller_spec.rb9
1 files changed, 5 insertions, 4 deletions
diff --git a/spec/controllers/api_controller_spec.rb b/spec/controllers/api_controller_spec.rb
index 91d113dac..dec652361 100644
--- a/spec/controllers/api_controller_spec.rb
+++ b/spec/controllers/api_controller_spec.rb
@@ -3,7 +3,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe ApiController, "when using the API" do
it "should create a new request from a POST" do
geraldine = public_bodies(:geraldine_public_body)
- number_of_requests = InfoRequest.count(:conditions = ["public_body_id = ?", geraldine.id])
+ number_of_requests = InfoRequest.count(:conditions => ["public_body_id = ?", geraldine.id])
request_data = {
"title" => "Tell me about your chickens",
@@ -15,12 +15,13 @@ describe ApiController, "when using the API" do
post :create_request, :k => geraldine.api_key, :request_json => request_data.to_json
response.should be_success
- response.headers["Content-Type"].should == "application/json"
+
+ response.content_type.should == "application/json"
- response_body = response.body.from_json
+ response_body = ActiveSupport::JSON.decode(response.body)
response_body["url"].should =~ /^http/
- InfoRequest.count(:conditions = ["public_body_id = ?", geraldine.id]).should == number_of_requests + 1
+ InfoRequest.count(:conditions => ["public_body_id = ?", geraldine.id]).should == number_of_requests + 1
new_request = InfoRequest.find(response_body["id"])
new_request.user_id.should be_nil