diff options
Diffstat (limited to 'spec/controllers/track_controller_spec.rb')
-rw-r--r-- | spec/controllers/track_controller_spec.rb | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/spec/controllers/track_controller_spec.rb b/spec/controllers/track_controller_spec.rb index 5505afe59..a16024828 100644 --- a/spec/controllers/track_controller_spec.rb +++ b/spec/controllers/track_controller_spec.rb @@ -49,14 +49,14 @@ describe TrackController, "when making a new track on a request" do it "should save a search track and redirect to the right place" do session[:user_id] = @user.id @track_thing.should_receive(:save!) - get :track_search_query, :query_array => ["bob variety:sent"], :feed => 'track' + get :track_search_query, :query_array => "bob variety:sent", :feed => 'track' response.should redirect_to(:controller => 'general', :action => 'search', :combined => ["bob", "requests"]) end end describe TrackController, "when sending alerts for a track" do - integrate_views + render_views before(:each) do load_raw_emails_data @@ -64,9 +64,6 @@ describe TrackController, "when sending alerts for a track" do end it "should send alerts" do - # Don't do clever locale-insertion-unto-URL stuff - old_filters = ActionController::Routing::Routes.filters - ActionController::Routing::Routes.filters = RoutingFilter::Chain.new # set the time the comment event happened at to within the last week ire = info_request_events(:silly_comment_event) @@ -80,7 +77,7 @@ describe TrackController, "when sending alerts for a track" do mail = deliveries[0] mail.body.should =~ /Alter your subscription/ mail.to_addrs.first.to_s.should include(users(:silly_name_user).email) - mail.body =~ /(http:\/\/.*\/c\/(.*))/ + mail.body.to_s =~ /(http:\/\/.*\/c\/(.*))/ mail_url = $1 mail_token = $2 @@ -112,9 +109,6 @@ describe TrackController, "when sending alerts for a track" do TrackMailer.alert_tracks deliveries = ActionMailer::Base.deliveries deliveries.size.should == 0 - - # Restore the routing filters - ActionController::Routing::Routes.filters = old_filters end it "should send localised alerts" do @@ -133,7 +127,7 @@ describe TrackController, "when sending alerts for a track" do end describe TrackController, "when viewing RSS feed for a track" do - integrate_views + render_views before(:each) do load_raw_emails_data @@ -145,6 +139,7 @@ describe TrackController, "when viewing RSS feed for a track" do get :track_request, :feed => 'feed', :url_title => track_thing.info_request.url_title response.should render_template('track/atom_feed') + response.content_type.should == 'application/atom+xml' # XXX should check it is an atom.builder type being rendered, not sure how to assigns[:xapian_object].matches_estimated.should == 3 @@ -159,11 +154,23 @@ describe TrackController, "when viewing RSS feed for a track" do get :track_user, :feed => 'feed', :url_name => "there_is_no_such_user" }.should raise_error(ActiveRecord::RecordNotFound) end + + it 'should return atom/xml for a feed url without format specified, even if the + requester prefers json' do + + request.env['HTTP_ACCEPT'] = 'application/json,text/xml' + track_thing = track_things(:track_fancy_dog_request) + + get :track_request, :feed => 'feed', :url_title => track_thing.info_request.url_title + response.should render_template('track/atom_feed') + response.content_type.should == 'application/atom+xml' + end + end describe TrackController, "when viewing JSON version of a track feed" do - integrate_views + render_views before(:each) do load_raw_emails_data @@ -205,7 +212,7 @@ end describe TrackController, "when tracking a public body" do - integrate_views + render_views before(:each) do load_raw_emails_data |