aboutsummaryrefslogtreecommitdiffstats
path: root/spec/controllers/track_controller_spec.rb
diff options
context:
space:
mode:
authorRobin Houston <robin.houston@gmail.com>2012-09-06 15:00:05 +0100
committerRobin Houston <robin.houston@gmail.com>2012-09-06 15:00:05 +0100
commit006717f1ac39557e50052bb5755d430a1fa100ee (patch)
treed07209a4ad2003111c03948d537127d40dda9799 /spec/controllers/track_controller_spec.rb
parent537b97ff069cac999da3ca80ede77fedc79e39ff (diff)
parent74531a783a8ea62a80596b435bd151cec2bf82c8 (diff)
Merge branch 'master' of git.mysociety.org:/data/git/public/alaveteli
Conflicts: spec/controllers/api_controller_spec.rb
Diffstat (limited to 'spec/controllers/track_controller_spec.rb')
-rw-r--r--spec/controllers/track_controller_spec.rb15
1 files changed, 14 insertions, 1 deletions
diff --git a/spec/controllers/track_controller_spec.rb b/spec/controllers/track_controller_spec.rb
index 1d38b3055..7daa23769 100644
--- a/spec/controllers/track_controller_spec.rb
+++ b/spec/controllers/track_controller_spec.rb
@@ -11,7 +11,13 @@ describe TrackController, "when making a new track on a request" do
TrackThing.stub!(:create_track_for_request).and_return(@track_thing)
TrackThing.stub!(:create_track_for_search_query).and_return(@track_thing)
TrackThing.stub!(:find_by_existing_track).and_return(nil)
- InfoRequest.stub!(:find_by_url_title).and_return(@ir)
+ InfoRequest.stub!(:find_by_url_title!) do |url_title|
+ if url_title == "myrequest"
+ @ir
+ else
+ raise ActiveRecord::RecordNotFound.new("Not found")
+ end
+ end
@user = mock_model(User)
User.stub!(:find).and_return(@user)
@@ -32,6 +38,13 @@ describe TrackController, "when making a new track on a request" do
get :track_request, :url_title => @ir.url_title, :feed => 'track'
response.should redirect_to(:controller => 'request', :action => 'show', :url_title => @ir.url_title)
end
+
+ it "should 404 for non-existent requests" do
+ session[:user_id] = @user.id
+ lambda {
+ get :track_request, :url_title => "hjksfdhjk_louytu_qqxxx", :feed => 'track'
+ }.should raise_error(ActiveRecord::RecordNotFound)
+ end
it "should save a search track and redirect to the right place" do
session[:user_id] = @user.id