diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/request_controller_spec.rb | 6 | ||||
-rw-r--r-- | spec/controllers/track_controller_spec.rb | 15 | ||||
-rw-r--r-- | spec/models/info_request_spec.rb | 6 | ||||
-rw-r--r-- | spec/models/request_mailer_spec.rb | 2 |
4 files changed, 24 insertions, 5 deletions
diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb index 13dbe4b74..f91f87323 100644 --- a/spec/controllers/request_controller_spec.rb +++ b/spec/controllers/request_controller_spec.rb @@ -1890,6 +1890,12 @@ describe RequestController, "when reporting a request (logged in)" do @user = users(:robin_user) session[:user_id] = @user.id end + + it "should 404 for non-existent requests" do + lambda { + post :report_request, :url_title => "hjksfdhjk_louytu_qqxxx" + }.should raise_error(ActiveRecord::RecordNotFound) + end it "should mark a request as having been reported" do ir = info_requests(:badger_request) 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 diff --git a/spec/models/info_request_spec.rb b/spec/models/info_request_spec.rb index 98ee34381..41d01c89a 100644 --- a/spec/models/info_request_spec.rb +++ b/spec/models/info_request_spec.rb @@ -353,7 +353,7 @@ describe InfoRequest do InfoRequest.should_receive(:find).with(:all, {:select=> anything, :order=> anything, - :conditions=>["awaiting_description = ? and (select created_at from info_request_events where info_request_events.info_request_id = info_requests.id and info_request_events.event_type = 'response' order by created_at desc limit 1) < ? and url_title != 'holding_pen' and prominence != 'backpage'", + :conditions=>["awaiting_description = ? and (select created_at from info_request_events where info_request_events.info_request_id = info_requests.id and info_request_events.event_type = 'response' order by created_at desc limit 1) < ? and url_title != 'holding_pen' and user_id is not null and prominence != 'backpage'", true, Time.now - 21.days]}) InfoRequest.find_old_unclassified({:conditions => ["prominence != 'backpage'"]}) end @@ -362,7 +362,7 @@ describe InfoRequest do InfoRequest.should_receive(:find).with(:all, {:select=>"*, (select created_at from info_request_events where info_request_events.info_request_id = info_requests.id and info_request_events.event_type = 'response' order by created_at desc limit 1) as last_response_time", :order=>"last_response_time", - :conditions=>["awaiting_description = ? and (select created_at from info_request_events where info_request_events.info_request_id = info_requests.id and info_request_events.event_type = 'response' order by created_at desc limit 1) < ? and url_title != 'holding_pen'", + :conditions=>["awaiting_description = ? and (select created_at from info_request_events where info_request_events.info_request_id = info_requests.id and info_request_events.event_type = 'response' order by created_at desc limit 1) < ? and url_title != 'holding_pen' and user_id is not null", true, Time.now - 21.days]}) InfoRequest.find_old_unclassified end @@ -396,7 +396,7 @@ describe InfoRequest do end it 'should return true if it is awaiting description, isn\'t the holding pen and hasn\'t had an event in 21 days' do - @info_request.is_old_unclassified?.should be_true + (@info_request.is_external? || @info_request.is_old_unclassified?).should be_true end end diff --git a/spec/models/request_mailer_spec.rb b/spec/models/request_mailer_spec.rb index 64ac35cf7..ea75ec765 100644 --- a/spec/models/request_mailer_spec.rb +++ b/spec/models/request_mailer_spec.rb @@ -223,7 +223,7 @@ describe RequestMailer, "when sending reminders to requesters to classify a resp end it 'should ask for all requests that are awaiting description and whose latest response is older than the number of days given and that are not the holding pen' do - expected_params = {:conditions => [ "awaiting_description = ? and (select created_at from info_request_events where info_request_events.info_request_id = info_requests.id and info_request_events.event_type = 'response' order by created_at desc limit 1) < ? and url_title != 'holding_pen'", + expected_params = {:conditions => [ "awaiting_description = ? and (select created_at from info_request_events where info_request_events.info_request_id = info_requests.id and info_request_events.event_type = 'response' order by created_at desc limit 1) < ? and url_title != 'holding_pen' and user_id is not null", true, Time.now() - 7.days ], :include => [ :user ], :order => "info_requests.id"} |