aboutsummaryrefslogtreecommitdiffstats
path: root/spec/controllers
diff options
context:
space:
mode:
authorFrancis Irving <francis@mysociety.org>2010-10-18 11:09:24 +0100
committerFrancis Irving <francis@mysociety.org>2010-10-18 11:09:24 +0100
commit77a519ff2dbc85b4f60ac4dcc1c49f899030ef2a (patch)
treed93c481d1fce97ebfacb712e9f175ffb953197a1 /spec/controllers
parente85eb6806ca8fe2265baa5cda81464477e9a5bb4 (diff)
Add test for JSON requests
Diffstat (limited to 'spec/controllers')
-rw-r--r--spec/controllers/request_controller_spec.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb
index 81879f7f1..ae1b5084d 100644
--- a/spec/controllers/request_controller_spec.rb
+++ b/spec/controllers/request_controller_spec.rb
@@ -1,5 +1,7 @@
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+require 'json'
+
describe RequestController, "when listing recent requests" do
before(:all) do
@@ -1219,7 +1221,24 @@ describe RequestController, "authority uploads a response from the web interface
end
end
+describe RequestController, "when showing JSON version for API" do
+
+ fixtures :info_requests, :info_request_events, :public_bodies, :users, :incoming_messages, :raw_emails, :outgoing_messages, :comments # all needed as integrating views
+ integrate_views
+
+ it "should be successful" do
+ get :show, :url_title => 'why_do_you_have_such_a_fancy_dog', :format => 'json'
+
+ ir = JSON.parse(response.body)
+ ir.class.to_s.should == 'Hash'
+
+ ir['url_title'].should == 'why_do_you_have_such_a_fancy_dog'
+ ir['public_body'].should == 'tgq'
+ ir['user'].should == 'bob_smith'
+ end
+
+end