diff options
author | Robin Houston <robin.houston@gmail.com> | 2012-01-26 23:21:12 +0000 |
---|---|---|
committer | Robin Houston <robin.houston@gmail.com> | 2012-01-26 23:21:12 +0000 |
commit | 24bbaa5afac5ce27c351e3b460be1b0182446ba1 (patch) | |
tree | 3527992bb6e08e13fa1e7d686663bf10f491cd9e /spec/controllers/user_controller_spec.rb | |
parent | 00aa3e5675d2137b55e8e0bf494f4a2078a5151f (diff) |
Refactor test code so new test data can be added
Previously many of the tests made assumptions about the global
structure of the test data set: the total number of requests, for
example, or the names of all public bodies. This makes it difficult
to add to the test data. This change is intended to make the test
data easier to extend by eliminating such global assumptions.
Diffstat (limited to 'spec/controllers/user_controller_spec.rb')
-rw-r--r-- | spec/controllers/user_controller_spec.rb | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/spec/controllers/user_controller_spec.rb b/spec/controllers/user_controller_spec.rb index a90fa18df..81d3ff2e5 100644 --- a/spec/controllers/user_controller_spec.rb +++ b/spec/controllers/user_controller_spec.rb @@ -46,16 +46,19 @@ describe UserController, "when showing a user" do it "should search the user's contributions" do get :show, :url_name => "bob_smith" - assigns[:xapian_requests].results.count.should == 3 + assigns[:xapian_requests].results.map{|x|x[:model].info_request}.should =~ InfoRequest.all(:conditions => "user_id = #{users(:bob_smith_user).id}") + get :show, :url_name => "bob_smith", :user_query => "money" - assigns[:xapian_requests].results.count.should == 1 + assigns[:xapian_requests].results.map{|x|x[:model].info_request}.should == [info_requests(:naughty_chicken_request)] end -# Error handling not quite good enough for this yet -# it "should not show unconfirmed users" do -# get :show, :url_name => "silly_emnameem" -# assigns[:display_users].should == [ users(:silly_name_user) ] -# end + it "should not show unconfirmed users" do + begin + get :show, :url_name => "unconfirmed_user" + rescue => e + end + e.should be_an_instance_of(ActiveRecord::RecordNotFound) + end end |