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/admin_user_controller_spec.rb2
-rw-r--r--spec/controllers/general_controller_spec.rb24
-rw-r--r--spec/controllers/public_body_controller_spec.rb6
-rw-r--r--spec/controllers/request_controller_spec.rb13
-rw-r--r--spec/controllers/track_controller_spec.rb7
-rw-r--r--spec/controllers/user_controller_spec.rb25
-rw-r--r--spec/helpers/link_to_helper_spec.rb7
-rw-r--r--spec/integration/search_request_spec.rb1
-rw-r--r--spec/lib/sendmail_return_path_spec.rb1
-rw-r--r--spec/models/info_request_event_spec.rb3
-rw-r--r--spec/models/request_mailer_spec.rb1
-rw-r--r--spec/models/track_mailer_spec.rb1
-rw-r--r--spec/models/xapian_spec.rb52
-rw-r--r--spec/views/request/show.rhtml_spec.rb14
16 files changed, 117 insertions, 61 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/admin_user_controller_spec.rb b/spec/controllers/admin_user_controller_spec.rb
index b2b2d0626..55b49f9da 100644
--- a/spec/controllers/admin_user_controller_spec.rb
+++ b/spec/controllers/admin_user_controller_spec.rb
@@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe AdminUserController, "when administering users" do
integrate_views
- fixtures :users, :info_requests, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things
+ fixtures :users, :info_requests, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things, :public_bodies, :public_body_versions, :public_body_translations
before { basic_auth_login @request }
it "shows the index/list page" do
diff --git a/spec/controllers/general_controller_spec.rb b/spec/controllers/general_controller_spec.rb
index e1539fa68..2750a33f3 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
@@ -28,6 +35,7 @@ describe GeneralController, "when searching" do
before(:each) do
load_raw_emails_data(raw_emails)
+ rebuild_xapian_index
end
it "should render the front page successfully" do
@@ -84,30 +92,28 @@ 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
describe 'when using xapian search' do
# rebuild xapian index after fixtures loaded
- before(:all) do
+ before(:each) do
+ load_raw_emails_data(raw_emails)
rebuild_xapian_index
end
diff --git a/spec/controllers/public_body_controller_spec.rb b/spec/controllers/public_body_controller_spec.rb
index 72fbe965c..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
diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb
index 665ae8489..a0ea9bb48 100644
--- a/spec/controllers/request_controller_spec.rb
+++ b/spec/controllers/request_controller_spec.rb
@@ -353,14 +353,19 @@ describe RequestController, "when showing one request" do
zipfile = Zip::ZipFile.open(File.join(File.dirname(__FILE__), "../../cache/zips", old_path)) { |zipfile|
zipfile.count.should == 3 # the message plus two "hello.txt" files
}
+
+ # The path of the zip file is based on the hash of the timestamp of the last request
+ # in the thread, so we wait for a second to make sure this one will have a different
+ # timestamp than the previous.
+ sleep 1
receive_incoming_mail('incoming-request-attachment-unknown-extension.email', ir.incoming_email)
get :download_entire_request, :url_title => title
assigns[:url_path].should have_text(/#{title}.zip$/)
+ assigns[:url_path].should_not == old_path
response.location.should have_text(/#{assigns[:url_path]}/)
zipfile = Zip::ZipFile.open(File.join(File.dirname(__FILE__), "../../cache/zips", assigns[:url_path])) { |zipfile|
zipfile.count.should == 5 # the message, two hello.txt, the unknown attachment, and its empty message
}
- assigns[:url_path].should_not == old_path
end
end
end
@@ -971,7 +976,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
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 2b5fb17e3..a90fa18df 100644
--- a/spec/controllers/user_controller_spec.rb
+++ b/spec/controllers/user_controller_spec.rb
@@ -11,6 +11,7 @@ describe UserController, "when showing a user" 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(:each) do
load_raw_emails_data(raw_emails)
+ rebuild_xapian_index
end
it "should be successful" do
@@ -96,7 +97,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 +110,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 +128,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 +153,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 +181,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 +257,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/integration/search_request_spec.rb b/spec/integration/search_request_spec.rb
index 5733dea22..c4991440a 100644
--- a/spec/integration/search_request_spec.rb
+++ b/spec/integration/search_request_spec.rb
@@ -19,6 +19,7 @@ describe "When searching" do
before(:each) do
emails = raw_emails.clone
load_raw_emails_data(emails)
+ rebuild_xapian_index
end
it "should not strip quotes from quoted query" do
diff --git a/spec/lib/sendmail_return_path_spec.rb b/spec/lib/sendmail_return_path_spec.rb
index f1a91240b..7708edb35 100644
--- a/spec/lib/sendmail_return_path_spec.rb
+++ b/spec/lib/sendmail_return_path_spec.rb
@@ -3,6 +3,7 @@
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe "when sending email with an altered return path" do
+ before(:each) { ActionMailer::Base.deliveries = [] }
it "should default to delivery method test" do
ActionMailer::Base.delivery_method.should == :test
diff --git a/spec/models/info_request_event_spec.rb b/spec/models/info_request_event_spec.rb
index 63c859007..a75f4b232 100644
--- a/spec/models/info_request_event_spec.rb
+++ b/spec/models/info_request_event_spec.rb
@@ -75,7 +75,8 @@ describe InfoRequestEvent do
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.should == nil
+
+ 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
diff --git a/spec/models/request_mailer_spec.rb b/spec/models/request_mailer_spec.rb
index ef4ed8074..2888213d7 100644
--- a/spec/models/request_mailer_spec.rb
+++ b/spec/models/request_mailer_spec.rb
@@ -4,6 +4,7 @@ describe RequestMailer, " when receiving incoming mail" 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
before(:each) do
load_raw_emails_data(raw_emails)
+ ActionMailer::Base.deliveries = []
end
it "should append it to the appropriate request" do
diff --git a/spec/models/track_mailer_spec.rb b/spec/models/track_mailer_spec.rb
index 67a64ee10..4f5499a90 100644
--- a/spec/models/track_mailer_spec.rb
+++ b/spec/models/track_mailer_spec.rb
@@ -155,6 +155,7 @@ describe TrackMailer do
@post_redirect = mock_model(PostRedirect, :save! => true,
:email_token => "token")
PostRedirect.stub!(:new).and_return(@post_redirect)
+ ActionMailer::Base.deliveries = []
end
it 'should deliver one email, with right headers' do
diff --git a/spec/models/xapian_spec.rb b/spec/models/xapian_spec.rb
index ebd6b1890..412146b53 100644
--- a/spec/models/xapian_spec.rb
+++ b/spec/models/xapian_spec.rb
@@ -3,17 +3,19 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe User, " when indexing users with Xapian" 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
- it "should search by name" do
- parse_all_incoming_messages
+ before(:each) do
+ load_raw_emails_data(raw_emails)
rebuild_xapian_index
- # def InfoRequest.full_search(models, query, order, ascending, collapse, per_page, page)
+ end
+
+ it "should search by name" do
+ # def InfoRequest.full_search(models, query, order, ascending, collapse, per_page, page)
xapian_object = InfoRequest.full_search([User], "Silly", 'created_at', true, nil, 100, 1)
xapian_object.results.size.should == 1
xapian_object.results[0][:model].should == users(:silly_name_user)
end
it "should search by 'about me' text" do
- rebuild_xapian_index
user = users(:bob_smith_user)
# def InfoRequest.full_search(models, query, order, ascending, collapse, per_page, page)
@@ -38,27 +40,22 @@ describe PublicBody, " when indexing public bodies with Xapian" 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
before(:each) do
load_raw_emails_data(raw_emails)
+ rebuild_xapian_index
end
it "should search index the main name field" do
- rebuild_xapian_index
-
xapian_object = InfoRequest.full_search([PublicBody], "humpadinking", 'created_at', true, nil, 100, 1)
xapian_object.results.size.should == 1
xapian_object.results[0][:model].should == public_bodies(:humpadink_public_body)
end
it "should search index the notes field" do
- rebuild_xapian_index
-
xapian_object = InfoRequest.full_search([PublicBody], "albatross", 'created_at', true, nil, 100, 1)
xapian_object.results.size.should == 1
xapian_object.results[0][:model].should == public_bodies(:humpadink_public_body)
end
it "should delete public bodies from the index when they are destroyed" do
- rebuild_xapian_index
-
xapian_object = InfoRequest.full_search([PublicBody], "albatross", 'created_at', true, nil, 100, 1)
xapian_object.results.size.should == 1
xapian_object.results[0][:model].should == public_bodies(:humpadink_public_body)
@@ -80,17 +77,16 @@ describe PublicBody, " when indexing requests by body they are to" do
before(:each) do
load_raw_emails_data(raw_emails)
+ rebuild_xapian_index
end
it "should find requests to the body" do
- rebuild_xapian_index
xapian_object = InfoRequest.full_search([InfoRequestEvent], "requested_from:tgq", 'created_at', true, nil, 100, 1)
xapian_object.results.size.should == 4
end
it "should update index correctly when URL name of body changes" do
# initial search
- rebuild_xapian_index
xapian_object = InfoRequest.full_search([InfoRequestEvent], "requested_from:tgq", 'created_at', true, nil, 100, 1)
xapian_object.results.size.should == 4
models_found_before = xapian_object.results.map { |x| x[:model] }
@@ -115,8 +111,6 @@ describe PublicBody, " when indexing requests by body they are to" do
# if you index via the Xapian TermGenerator, it ignores terms of this length,
# this checks we're using Document:::add_term() instead
it "should work with URL names that are longer than 64 characters" do
- rebuild_xapian_index
-
# change the URL name of the body
body = public_bodies(:geraldine_public_body)
body.short_name = 'The Uncensored, Complete Name of the Quasi-Autonomous Public Body Also Known As Geraldine'
@@ -139,16 +133,15 @@ describe User, " when indexing requests by user they are from" do
fixtures :users, :info_requests, :raw_emails, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things
before(:each) do
load_raw_emails_data(raw_emails)
+ rebuild_xapian_index
end
it "should find requests from the user" do
- rebuild_xapian_index
xapian_object = InfoRequest.full_search([InfoRequestEvent], "requested_by:bob_smith", 'created_at', true, nil, 100, 1)
xapian_object.results.size.should == 5
end
it "should find just the sent message events from a particular user" do
- rebuild_xapian_index
# def InfoRequest.full_search(models, query, order, ascending, collapse, per_page, page)
xapian_object = InfoRequest.full_search([InfoRequestEvent], "requested_by:bob_smith variety:sent", 'created_at', true, nil, 100, 1)
xapian_object.results.size.should == 3
@@ -157,7 +150,6 @@ describe User, " when indexing requests by user they are from" do
end
it "should not find it when one of the request's users is changed" do
- rebuild_xapian_index
silly_user = users(:silly_name_user)
naughty_chicken_request = info_requests(:naughty_chicken_request)
naughty_chicken_request.user = silly_user
@@ -172,8 +164,6 @@ describe User, " when indexing requests by user they are from" do
end
it "should not get confused searching for requests when one user has a name which has same stem as another" do
- rebuild_xapian_index
-
bob_smith_user = users(:bob_smith_user)
bob_smith_user.name = "John King"
bob_smith_user.url_name.should == 'john_king'
@@ -199,7 +189,6 @@ describe User, " when indexing requests by user they are from" do
it "should update index correctly when URL name of user changes" do
# initial search
- rebuild_xapian_index
xapian_object = InfoRequest.full_search([InfoRequestEvent], "requested_by:bob_smith", 'created_at', true, nil, 100, 1)
xapian_object.results.size.should == 5
models_found_before = xapian_object.results.map { |x| x[:model] }
@@ -226,17 +215,16 @@ describe User, " when indexing comments by user they are by" do
fixtures :users, :info_requests, :raw_emails, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things
before(:each) do
load_raw_emails_data(raw_emails)
+ rebuild_xapian_index
end
it "should find requests from the user" do
- rebuild_xapian_index
xapian_object = InfoRequest.full_search([InfoRequestEvent], "commented_by:silly_emnameem", 'created_at', true, nil, 100, 1)
xapian_object.results.size.should == 1
end
it "should update index correctly when URL name of user changes" do
# initial search
- rebuild_xapian_index
xapian_object = InfoRequest.full_search([InfoRequestEvent], "commented_by:silly_emnameem", 'created_at', true, nil, 100, 1)
xapian_object.results.size.should == 1
models_found_before = xapian_object.results.map { |x| x[:model] }
@@ -263,10 +251,10 @@ describe InfoRequest, " when indexing requests by their title" do
fixtures :users, :info_requests, :raw_emails, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things
before(:each) do
load_raw_emails_data(raw_emails)
+ rebuild_xapian_index
end
it "should find events for the request" do
- rebuild_xapian_index
xapian_object = InfoRequest.full_search([InfoRequestEvent], "request:how_much_public_money_is_wasted_o", 'created_at', true, nil, 100, 1)
xapian_object.results.size.should == 1
xapian_object.results[0][:model] == info_request_events(:silly_outgoing_message_event)
@@ -274,7 +262,6 @@ describe InfoRequest, " when indexing requests by their title" do
it "should update index correctly when URL title of request changes" do
# change the URL name of the body
- rebuild_xapian_index
ir = info_requests(:naughty_chicken_request)
ir.title = 'Really naughty'
ir.save!
@@ -294,10 +281,10 @@ describe InfoRequest, " when indexing requests by tag" do
fixtures :users, :info_requests, :raw_emails, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things
before(:each) do
load_raw_emails_data(raw_emails)
+ rebuild_xapian_index
end
it "should find request by tag, even when changes" do
- rebuild_xapian_index
ir = info_requests(:naughty_chicken_request)
ir.tag_string = 'bunnyrabbit'
ir.save!
@@ -316,10 +303,10 @@ describe PublicBody, " when indexing authorities by tag" 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
before(:each) do
load_raw_emails_data(raw_emails)
+ rebuild_xapian_index
end
it "should find request by tag, even when changes" do
- rebuild_xapian_index
body = public_bodies(:geraldine_public_body)
body.tag_string = 'mice:3'
body.save!
@@ -341,10 +328,10 @@ describe PublicBody, " when only indexing selected things on a rebuild" 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
before(:each) do
load_raw_emails_data(raw_emails)
+ rebuild_xapian_index
end
it "should only index what we ask it to" do
- rebuild_xapian_index
body = public_bodies(:geraldine_public_body)
body.tag_string = 'mice:3'
body.name = 'frobzn'
@@ -396,14 +383,3 @@ describe PublicBody, " when only indexing selected things on a rebuild" do
end
end
-
-
-
-
-
-
-
-
-
-
-
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