aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/admin_public_body_controller_spec.rb7
-rw-r--r--spec/controllers/admin_request_controller_spec.rb14
-rw-r--r--spec/controllers/application_controller_spec.rb24
-rw-r--r--spec/controllers/general_controller_spec.rb20
-rw-r--r--spec/controllers/public_body_controller_spec.rb9
-rw-r--r--spec/controllers/request_controller_spec.rb30
-rw-r--r--spec/controllers/track_controller_spec.rb7
-rw-r--r--spec/controllers/user_controller_spec.rb24
-rw-r--r--spec/helpers/link_to_helper_spec.rb7
-rw-r--r--spec/models/info_request_event_spec.rb8
-rw-r--r--spec/models/outgoing_mailer_spec.rb8
-rw-r--r--spec/models/track_thing_spec.rb7
-rw-r--r--spec/spec_helper.rb10
-rw-r--r--spec/views/request/list.rhtml_spec.rb2
-rw-r--r--spec/views/request/show.rhtml_spec.rb14
15 files changed, 169 insertions, 22 deletions
diff --git a/spec/controllers/admin_public_body_controller_spec.rb b/spec/controllers/admin_public_body_controller_spec.rb
index 97636023a..2670f2add 100644
--- a/spec/controllers/admin_public_body_controller_spec.rb
+++ b/spec/controllers/admin_public_body_controller_spec.rb
@@ -198,8 +198,13 @@ describe AdminPublicBodyController, "when creating public bodies with i18n" do
password = MySociety::Config.get('ADMIN_PASSWORD', '')
basic_auth_login @request
- ActionController::Routing::Routes.filters.clear # don't auto-insert locale, complicates assertions
+ @old_filters = ActionController::Routing::Routes.filters
+ ActionController::Routing::Routes.filters = RoutingFilter::Chain.new
end
+ after do
+ ActionController::Routing::Routes.filters = @old_filters
+ end
+
it "creates a new public body in one locale" do
PublicBody.count.should == 2
diff --git a/spec/controllers/admin_request_controller_spec.rb b/spec/controllers/admin_request_controller_spec.rb
index 635d73b9e..6d3c955bb 100644
--- a/spec/controllers/admin_request_controller_spec.rb
+++ b/spec/controllers/admin_request_controller_spec.rb
@@ -5,6 +5,15 @@ describe AdminRequestController, "when administering requests" do
fixtures :users, :public_bodies, :public_body_translations, :public_body_versions, :info_requests, :raw_emails, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things
before { basic_auth_login @request }
+ before(:each) do
+ load_raw_emails_data(raw_emails)
+ @old_filters = ActionController::Routing::Routes.filters
+ ActionController::Routing::Routes.filters = RoutingFilter::Chain.new
+ end
+ after do
+ ActionController::Routing::Routes.filters = @old_filters
+ end
+
it "shows the index/list page" do
get :index
end
@@ -45,6 +54,11 @@ describe AdminRequestController, "when administering the holding pen" do
before(:each) do
basic_auth_login @request
load_raw_emails_data(raw_emails)
+ @old_filters = ActionController::Routing::Routes.filters
+ ActionController::Routing::Routes.filters = RoutingFilter::Chain.new
+ end
+ after do
+ ActionController::Routing::Routes.filters = @old_filters
end
it "shows a rejection reason for an incoming message from an invalid address" do
diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb
index 1d6802940..f16cee312 100644
--- a/spec/controllers/application_controller_spec.rb
+++ b/spec/controllers/application_controller_spec.rb
@@ -2,6 +2,19 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
require 'fakeweb'
describe ApplicationController, "when accessing third party services" do
+ before (:each) do
+ FakeWeb.clean_registry
+ end
+ after (:each) do
+ FakeWeb.clean_registry
+ end
+ it "should succeed if the service responds OK" do
+ config = MySociety::Config.load_default()
+ config['GAZE_URL'] = 'http://denmark.com'
+ FakeWeb.register_uri(:get, %r|denmark.com|, :body => "DK")
+ country = self.controller.send :country_from_ip
+ country.should == "DK"
+ end
it "should fail silently if the country_from_ip domain doesn't exist" do
config = MySociety::Config.load_default()
config['GAZE_URL'] = 'http://12123sdf14qsd.com'
@@ -15,7 +28,7 @@ describe ApplicationController, "when accessing third party services" do
country.should == config['ISO_COUNTRY_CODE']
end
it "should fail silently if the country_from_ip service returns an error" do
- FakeWeb.register_uri(:get, %r|.*|, :body => "Error", :status => ["500", "Error"])
+ FakeWeb.register_uri(:get, %r|500.com|, :body => "Error", :status => ["500", "Error"])
config = MySociety::Config.load_default()
config['GAZE_URL'] = 'http://500.com'
country = self.controller.send :country_from_ip
@@ -23,3 +36,12 @@ describe ApplicationController, "when accessing third party services" do
end
end
+describe ApplicationController, "when caching fragments" do
+ it "should not fail with long filenames" do
+ long_name = "blahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblah.txt"
+ path = self.controller.send(:foi_fragment_cache_path, long_name)
+ self.controller.send(:foi_fragment_cache_write, path, "whassap")
+ end
+
+end
+
diff --git a/spec/controllers/general_controller_spec.rb b/spec/controllers/general_controller_spec.rb
index e1539fa68..bcd577484 100644
--- a/spec/controllers/general_controller_spec.rb
+++ b/spec/controllers/general_controller_spec.rb
@@ -2,6 +2,13 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
require 'fakeweb'
describe GeneralController, "when trying to show the blog" do
+ before (:each) do
+ FakeWeb.clean_registry
+ end
+ after (:each) do
+ FakeWeb.clean_registry
+ end
+
it "should fail silently if the blog is returning an error" do
FakeWeb.register_uri(:get, %r|.*|, :body => "Error", :status => ["500", "Error"])
get :blog
@@ -84,23 +91,20 @@ describe GeneralController, "when searching" do
describe "when using different locale settings" do
home_link_regex = /href=".*\/en"/
it "should generate URLs with a locale prepended when there's more than one locale set" do
- ActionController::Routing::Routes.add_filters('conditionallyprependlocale')
get :frontpage
response.should have_text(home_link_regex)
end
it "should generate URLs without a locale prepended when there's only one locale set" do
- ActionController::Routing::Routes.add_filters('conditionallyprependlocale')
- old_available_locales = FastGettext.default_available_locales
- available_locales = ['en']
- FastGettext.default_available_locales = available_locales
- I18n.available_locales = available_locales
+ old_fgt_available_locales = FastGettext.default_available_locales
+ old_i18n_available_locales = I18n.available_locales
+ FastGettext.default_available_locales = I18n.available_locales = ['en']
get :frontpage
response.should_not have_text(home_link_regex)
- FastGettext.default_available_locales = old_available_locales
- I18n.available_locales = old_available_locales
+ FastGettext.default_available_locales = old_fgt_available_locales
+ I18n.available_locales = old_i18n_available_locales
end
end
diff --git a/spec/controllers/public_body_controller_spec.rb b/spec/controllers/public_body_controller_spec.rb
index a563b92ad..131412a90 100644
--- a/spec/controllers/public_body_controller_spec.rb
+++ b/spec/controllers/public_body_controller_spec.rb
@@ -50,9 +50,13 @@ describe PublicBodyController, "when showing a body" do
end
it "should redirect use to the relevant locale even when url_name is for a different locale" do
- ActionController::Routing::Routes.filters.clear
+ old_filters = ActionController::Routing::Routes.filters
+ ActionController::Routing::Routes.filters = RoutingFilter::Chain.new
+
get :show, {:url_name => "edfh", :view => 'all'}
response.should redirect_to "http://test.host/body/dfh"
+
+ ActionController::Routing::Routes.filters = old_filters
end
it "should redirect to newest name if you use historic name of public body in URL" do
@@ -181,6 +185,8 @@ end
describe PublicBodyController, "when doing type ahead searches" do
fixtures :public_bodies, :public_body_translations, :public_body_versions, :users, :info_requests, :raw_emails, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things
+ integrate_views
+
it "should return nothing for the empty query string" do
get :search_typeahead, :query => ""
response.should render_template('public_body/_search_ahead')
@@ -190,6 +196,7 @@ describe PublicBodyController, "when doing type ahead searches" do
it "should return a body matching the given keyword, but not users with a matching description" do
get :search_typeahead, :query => "Geraldine"
response.should render_template('public_body/_search_ahead')
+ response.body.should include('search_ahead')
assigns[:xapian_requests].results.size.should == 1
assigns[:xapian_requests].results[0][:model].name.should == public_bodies(:geraldine_public_body).name
end
diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb
index 86665a793..6c6ccc76a 100644
--- a/spec/controllers/request_controller_spec.rb
+++ b/spec/controllers/request_controller_spec.rb
@@ -53,14 +53,24 @@ describe RequestController, "when listing recent requests" do
it "should assign the first page of results" do
xap_results = mock_model(ActsAsXapian::Search,
:results => (1..25).to_a.map { |m| { :model => m } },
- :matches_estimated => 103)
+ :matches_estimated => 1000000)
InfoRequest.should_receive(:full_search).
with([InfoRequestEvent]," (variety:sent OR variety:followup_sent OR variety:response OR variety:comment)", "created_at", anything, anything, anything, anything).
and_return(xap_results)
get :list, :view => 'all'
assigns[:list_results].size.should == 25
+ assigns[:show_no_more_than].should == RequestController::MAX_RESULTS
end
+ it "should return 404 for pages we don't want to serve up" do
+ xap_results = mock_model(ActsAsXapian::Search,
+ :results => (1..25).to_a.map { |m| { :model => m } },
+ :matches_estimated => 1000000)
+ lambda {
+ get :list, :view => 'all', :page => 100
+ }.should raise_error(ActiveRecord::RecordNotFound)
+ end
+
end
describe RequestController, "when showing one request" do
@@ -171,6 +181,16 @@ describe RequestController, "when showing one request" do
response.should have_text(/Second hello/)
end
+ it "should return 404 for ugly URLs contain a request id that isn't an integer " do
+ ir = info_requests(:fancy_dog_request)
+ receive_incoming_mail('incoming-request-two-same-name.email', ir.incoming_email)
+ ir.reload
+ ugly_id = "55195"
+ lambda {
+ get :get_attachment_as_html, :incoming_message_id => ir.incoming_messages[1].id, :id => ugly_id, :part => 2, :file_name => ['hello.txt.html'], :skip_cache => 1
+ }.should raise_error(ActiveRecord::RecordNotFound)
+ end
+
it "should generate valid HTML verson of PDF attachments " do
ir = info_requests(:fancy_dog_request)
receive_incoming_mail('incoming-request-pdf-attachment.email', ir.incoming_email)
@@ -937,7 +957,11 @@ describe RequestController, "when classifying an information request" do
session[:user_id] = @request_owner.id
@dog_request = info_requests(:fancy_dog_request)
InfoRequest.stub!(:find).and_return(@dog_request)
- ActionController::Routing::Routes.filters.clear
+ @old_filters = ActionController::Routing::Routes.filters
+ ActionController::Routing::Routes.filters = RoutingFilter::Chain.new
+ end
+ after do
+ ActionController::Routing::Routes.filters = @old_filters
end
def request_url
@@ -1493,6 +1517,8 @@ end
describe RequestController, "when doing type ahead searches" do
fixtures :public_bodies, :public_body_translations, :public_body_versions, :users, :info_requests, :raw_emails, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things
+ integrate_views
+
it "should return nothing for the empty query string" do
get :search_typeahead, :q => ""
response.should render_template('request/_search_ahead.rhtml')
diff --git a/spec/controllers/track_controller_spec.rb b/spec/controllers/track_controller_spec.rb
index 90d13495f..ad4d651cb 100644
--- a/spec/controllers/track_controller_spec.rb
+++ b/spec/controllers/track_controller_spec.rb
@@ -46,7 +46,9 @@ describe TrackController, "when sending alerts for a track" do
it "should send alerts" do
# Don't do clever locale-insertion-unto-URL stuff
- ActionController::Routing::Routes.filters.clear
+ 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)
ire.created_at = Time.now - 3.days
@@ -91,6 +93,9 @@ 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
diff --git a/spec/controllers/user_controller_spec.rb b/spec/controllers/user_controller_spec.rb
index 0cf574aa9..d8e92fbd0 100644
--- a/spec/controllers/user_controller_spec.rb
+++ b/spec/controllers/user_controller_spec.rb
@@ -96,7 +96,9 @@ describe UserController, "when signing in" do
end
it "should log in when you give right email/password, and redirect to where you were" do
- ActionController::Routing::Routes.filters.clear
+ old_filters = ActionController::Routing::Routes.filters
+ ActionController::Routing::Routes.filters = RoutingFilter::Chain.new
+
get :signin, :r => "/list"
response.should render_template('sign')
post_redirect = get_last_postredirect
@@ -107,10 +109,14 @@ describe UserController, "when signing in" do
# response doesn't contain /en/ but redirect_to does...
response.should redirect_to(:controller => 'request', :action => 'list', :post_redirect => 1)
response.should_not send_email
+
+ ActionController::Routing::Routes.filters = old_filters
end
it "should not log you in if you use an invalid PostRedirect token, and shouldn't give 500 error either" do
- ActionController::Routing::Routes.filters.clear
+ old_filters = ActionController::Routing::Routes.filters
+ ActionController::Routing::Routes.filters = RoutingFilter::Chain.new
+
post_redirect = "something invalid"
lambda {
post :signin, { :user_signin => { :email => 'bob@localhost', :password => 'jonespassword' },
@@ -121,6 +127,8 @@ describe UserController, "when signing in" do
:token => post_redirect }
response.should render_template('sign')
assigns[:post_redirect].should == nil
+
+ ActionController::Routing::Routes.filters = old_filters
end
# No idea how to test this in the test framework :(
@@ -144,7 +152,9 @@ describe UserController, "when signing in" do
end
it "should confirm your email, log you in and redirect you to where you were after you click an email link" do
- ActionController::Routing::Routes.filters.clear
+ old_filters = ActionController::Routing::Routes.filters
+ ActionController::Routing::Routes.filters = RoutingFilter::Chain.new
+
get :signin, :r => "/list"
post_redirect = get_last_postredirect
@@ -170,6 +180,8 @@ describe UserController, "when signing in" do
get :confirm, :email_token => post_redirect.email_token
session[:user_id].should == users(:unconfirmed_user).id
response.should redirect_to(:controller => 'request', :action => 'list', :post_redirect => 1)
+
+ ActionController::Routing::Routes.filters = old_filters
end
end
@@ -244,11 +256,15 @@ describe UserController, "when signing out" do
end
it "should log you out and redirect you to where you were" do
- ActionController::Routing::Routes.filters.clear
+ old_filters = ActionController::Routing::Routes.filters
+ ActionController::Routing::Routes.filters = RoutingFilter::Chain.new
+
session[:user_id] = users(:bob_smith_user).id
get :signout, :r => '/list'
session[:user_id].should be_nil
response.should redirect_to(:controller => 'request', :action => 'list')
+
+ ActionController::Routing::Routes.filters = old_filters
end
end
diff --git a/spec/helpers/link_to_helper_spec.rb b/spec/helpers/link_to_helper_spec.rb
index f85d2e70d..3fa91a8f8 100644
--- a/spec/helpers/link_to_helper_spec.rb
+++ b/spec/helpers/link_to_helper_spec.rb
@@ -7,9 +7,14 @@ describe LinkToHelper do
describe 'when creating a url for a request' do
before do
- ActionController::Routing::Routes.filters.clear
@mock_request = mock_model(InfoRequest, :url_title => 'test_title')
+ @old_filters = ActionController::Routing::Routes.filters
+ ActionController::Routing::Routes.filters = RoutingFilter::Chain.new
end
+ after do
+ ActionController::Routing::Routes.filters = @old_filters
+ end
+
it 'should return a path like /request/test_title' do
request_url(@mock_request).should == '/request/test_title'
diff --git a/spec/models/info_request_event_spec.rb b/spec/models/info_request_event_spec.rb
index 5423b8da8..a75f4b232 100644
--- a/spec/models/info_request_event_spec.rb
+++ b/spec/models/info_request_event_spec.rb
@@ -73,6 +73,14 @@ describe InfoRequestEvent do
event.search_text_main.strip.should == "No way! I'm not going to tell you that in a month of Thursdays.\n\nThe Geraldine Quango"
end
+ it 'should get clipped text for incoming messages, and cache it too' do
+ event = info_request_events(:useless_incoming_message_event)
+
+ event.incoming_message_selective_columns("cached_main_body_text_folded").cached_main_body_text_folded = nil
+ event.search_text_main(true).strip.should == "No way! I'm not going to tell you that in a month of Thursdays.\n\nThe Geraldine Quango"
+ event.incoming_message_selective_columns("cached_main_body_text_folded").cached_main_body_text_folded.should_not == nil
+ end
+
end
diff --git a/spec/models/outgoing_mailer_spec.rb b/spec/models/outgoing_mailer_spec.rb
index 75c8053b4..c5fde93fc 100644
--- a/spec/models/outgoing_mailer_spec.rb
+++ b/spec/models/outgoing_mailer_spec.rb
@@ -24,6 +24,7 @@ describe OutgoingMailer, " when working out follow up addresses" do
im = ir.incoming_messages[0]
im.raw_email.data = im.raw_email.data.sub("\"FOI Person\" <foiperson@localhost>", "foiperson@localhost")
+ im.parse_raw_email! true
# check the basic entry in the fixture is fine
OutgoingMailer.name_and_email_for_followup(ir, im).should == "foiperson@localhost"
@@ -36,6 +37,7 @@ describe OutgoingMailer, " when working out follow up addresses" do
im = ir.incoming_messages[0]
im.raw_email.data = im.raw_email.data.sub("FOI Person", "FOI [ Person")
+ im.parse_raw_email! true
# check the basic entry in the fixture is fine
OutgoingMailer.name_and_email_for_followup(ir, im).should == "\"FOI [ Person\" <foiperson@localhost>"
@@ -48,6 +50,7 @@ describe OutgoingMailer, " when working out follow up addresses" do
im = ir.incoming_messages[0]
im.raw_email.data = im.raw_email.data.sub("FOI Person", "FOI \\\" Person")
+ im.parse_raw_email! true
# check the basic entry in the fixture is fine
OutgoingMailer.name_and_email_for_followup(ir, im).should == "\"FOI \\\" Person\" <foiperson@localhost>"
@@ -60,6 +63,7 @@ describe OutgoingMailer, " when working out follow up addresses" do
im = ir.incoming_messages[0]
im.raw_email.data = im.raw_email.data.sub("FOI Person", "FOI @ Person")
+ im.parse_raw_email! true
# check the basic entry in the fixture is fine
OutgoingMailer.name_and_email_for_followup(ir, im).should == "\"FOI @ Person\" <foiperson@localhost>"
@@ -116,6 +120,8 @@ describe OutgoingMailer, "when working out follow up subjects" do
om.incoming_message_followup = im
im.raw_email.data = im.raw_email.data.sub("Subject: Geraldine FOI Code AZXB421", "Subject: re: Geraldine FOI Code AZXB421")
+ im.parse_raw_email! true
+
OutgoingMailer.subject_for_followup(ir, om).should == "re: Geraldine FOI Code AZXB421"
end
@@ -127,6 +133,8 @@ describe OutgoingMailer, "when working out follow up subjects" do
im.raw_email.data = im.raw_email.data.sub("foiperson@localhost", "postmaster@localhost")
im.raw_email.data = im.raw_email.data.sub("Subject: Geraldine FOI Code AZXB421", "Subject: Delivery Failed")
+ im.parse_raw_email! true
+
OutgoingMailer.subject_for_followup(ir, om).should == "Re: Freedom of Information request - Why do you have & such a fancy dog?"
end
end
diff --git a/spec/models/track_thing_spec.rb b/spec/models/track_thing_spec.rb
index 4922a96c7..7891bd229 100644
--- a/spec/models/track_thing_spec.rb
+++ b/spec/models/track_thing_spec.rb
@@ -28,6 +28,13 @@ describe TrackThing, "when tracking changes" do
found_track.should == @track_thing
end
+ it "can display the description of a deleted track_thing" do
+ track_thing = TrackThing.create_track_for_search_query('fancy dog')
+ description = track_thing.track_query_description
+ track_thing.destroy
+ track_thing.track_query_description.should == description
+ end
+
it "will make some sane descriptions of search-based tracks" do
tests = [['bob variety:user', "users matching text 'bob'"],
['bob (variety:sent OR variety:followup_sent OR variety:response OR variety:comment) (latest_status:successful OR latest_status:partially_successful OR latest_status:rejected OR latest_status:not_held)', "requests which are successful or unsuccessful or comments matching text 'bob'"],
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index e58c3890a..33a28449e 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -143,7 +143,10 @@ if $tempfilecount.nil?
module TestProcess
# Hook into the process function, so can automatically get HTML after each request
alias :original_process :process
-
+ def is_fragment
+ # XXX there must be a better way of doing this!
+ return @request.query_parameters["action"] == "search_typeahead"
+ end
def process(action, parameters = nil, session = nil, flash = nil, http_method = 'GET')
self.original_process(action, parameters, session, flash, http_method)
# don't validate auto-generated HTML
@@ -152,7 +155,12 @@ if $tempfilecount.nil?
return unless @response.template.controller.instance_eval { integrate_views? }
# And then if HTML, not a redirect (302, 301)
if @response.content_type == "text/html" && ! [301,302,401].include?(@response.response_code)
+ if !is_fragment
validate_html(@response.body)
+ else
+ # it's a partial
+ validate_as_body(@response.body)
+ end
end
end
end
diff --git a/spec/views/request/list.rhtml_spec.rb b/spec/views/request/list.rhtml_spec.rb
index 1f86ec641..c7067294f 100644
--- a/spec/views/request/list.rhtml_spec.rb
+++ b/spec/views/request/list.rhtml_spec.rb
@@ -33,6 +33,7 @@ describe "when listing recent requests" do
it "should be successful" do
assigns[:list_results] = [ make_mock_event, make_mock_event ]
assigns[:matches_estimated] = 2
+ assigns[:show_no_more_than] = 100
render "request/list"
response.should have_tag("div.request_listing")
response.should_not have_tag("p", /No requests of this sort yet/m)
@@ -41,6 +42,7 @@ describe "when listing recent requests" do
it "should cope with no results" do
assigns[:list_results] = [ ]
assigns[:matches_estimated] = 0
+ assigns[:show_no_more_than] = 0
render "request/list"
response.should have_tag("p", /No requests of this sort yet/m)
response.should_not have_tag("div.request_listing")
diff --git a/spec/views/request/show.rhtml_spec.rb b/spec/views/request/show.rhtml_spec.rb
index adb244f47..ef7d1a47c 100644
--- a/spec/views/request/show.rhtml_spec.rb
+++ b/spec/views/request/show.rhtml_spec.rb
@@ -84,10 +84,15 @@ describe 'when viewing an information request' do
describe 'when there is a last response' do
before do
- ActionController::Routing::Routes.filters.clear
@mock_response = mock_model(IncomingMessage)
@mock_request.stub!(:get_last_response).and_return(@mock_response)
+ @old_filters = ActionController::Routing::Routes.filters
+ ActionController::Routing::Routes.filters = RoutingFilter::Chain.new
end
+ after do
+ ActionController::Routing::Routes.filters = @old_filters
+ end
+
it 'should show a link to follow up the last response with clarification' do
request_page
@@ -100,9 +105,14 @@ describe 'when viewing an information request' do
describe 'when there is no last response' do
before do
- ActionController::Routing::Routes.filters.clear
@mock_request.stub!(:get_last_response).and_return(nil)
+ @old_filters = ActionController::Routing::Routes.filters
+ ActionController::Routing::Routes.filters = RoutingFilter::Chain.new
end
+ after do
+ ActionController::Routing::Routes.filters = @old_filters
+ end
+
it 'should show a link to follow up the request without reference to a specific response' do
request_page