diff options
51 files changed, 137 insertions, 182 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 1849f23f3..b681f455d 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -363,7 +363,10 @@ class ApplicationController < ActionController::Base else @page = this_page end - return InfoRequest.full_search(models, @query, order, ascending, collapse, @per_page, @page) + result = InfoRequest.full_search(models, @query, order, ascending, collapse, @per_page, @page) + result.results # Touch the results to load them, otherwise accessing them from the view + # might fail later if the database has subsequently been reopened. + return result end def get_search_page_from_params return (params[:page] || "1").to_i diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index fc1ffdd75..2295d6718 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -207,18 +207,28 @@ class RequestController < ApplicationController end # Banned from making new requests? + user_exceeded_limit = false if !authenticated_user.nil? && !authenticated_user.can_file_requests? - if authenticated_user.exceeded_limit? - render :template => 'user/rate_limited' - else + # If the reason the user cannot make new requests is that they are + # rate-limited, it’s possible they composed a request before they + # logged in and we want to include the text of the request so they + # can squirrel it away for tomorrow, so we detect this later after + # we have constructed the InfoRequest. + user_exceeded_limit = authenticated_user.exceeded_limit? + if !user_exceeded_limit @details = authenticated_user.can_fail_html render :template => 'user/banned' + return end - return end # First time we get to the page, just display it if params[:submitted_new_request].nil? || params[:reedit] + if user_exceeded_limit + render :template => 'user/rate_limited' + return + end + params[:info_request] = { } if !params[:info_request] # Read parameters in - first the public body (by URL name or id) @@ -318,6 +328,11 @@ class RequestController < ApplicationController return end + if user_exceeded_limit + render :template => 'user/rate_limited' + return + end + if !authenticated?( :web => _("To send your FOI request"), :email => _("Then your FOI request to {{public_body_name}} will be sent.",:public_body_name=>@info_request.public_body.name), @@ -701,7 +716,10 @@ class RequestController < ApplicationController @incoming_message.parse_raw_email! @info_request = @incoming_message.info_request if @incoming_message.info_request_id != params[:id].to_i - message = "Incoming message %d does not belong to request %d" % [@incoming_message.info_request_id, params[:id]] + # Note that params[:id] might not be an integer, though + # if we’ve got this far then it must begin with an integer + # and that integer must be the id number of an actual request. + message = "Incoming message %d does not belong to request '%s'" % [@incoming_message.info_request_id, params[:id]] raise ActiveRecord::RecordNotFound.new(message) end @part_number = params[:part].to_i diff --git a/app/models/user.rb b/app/models/user.rb index 2193805ea..8c4b35fe6 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -132,7 +132,7 @@ class User < ActiveRecord::Base name.strip! end if self.public_banned? - name = _("{{user_name}} (Banned)", :user_name=>name) + name = _("{{user_name}} (Account suspended)", :user_name=>name) end name end diff --git a/app/views/admin_public_body/import_csv.rhtml b/app/views/admin_public_body/import_csv.rhtml index ecd2c38b7..d5717de23 100644 --- a/app/views/admin_public_body/import_csv.rhtml +++ b/app/views/admin_public_body/import_csv.rhtml @@ -31,7 +31,7 @@ <p><strong>CSV file format:</strong> A first row with the list of fields, starting with '#', is optional but highly recommended. The fields 'name' - and 'request_email' are required; additionaly, translated values are supported by + and 'request_email' are required; additionally, translated values are supported by adding the locale name to the field name, e.g. 'name.es', 'name.de'... Example: </p> diff --git a/app/views/user/rate_limited.rhtml b/app/views/user/rate_limited.rhtml index d513cec9e..c1e8f360e 100644 --- a/app/views/user/rate_limited.rhtml +++ b/app/views/user/rate_limited.rhtml @@ -2,4 +2,16 @@ <h1><%=@title%></h1> -<p><%= _('You have made too many requests today. Please try again tomorrow.')%></p> +<p><%= _("There is a limit on the number of requests that you can make in any one day. You can make more requests tomorrow.")%></p> + +<!-- Insert explanation of why we have a limit --> + +<p><%= _("If you need to make more requests than this, <a href='%s'>get in touch</a> and we’ll consider it.") % [help_contact_path] %></p> + +<% if @info_request %> + <p><%= _("Here is the message you wrote, in case you would like to copy the text and save it for later.") %></p> + + <div class="correspondence"> + <div class="correspondence_text"><%= @info_request.outgoing_messages[0].get_body_for_html_display %></div> + </div> +<% end %> diff --git a/config/environments/test.rb b/config/environments/test.rb index 8d6041ad9..be28c3df6 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -1,5 +1,7 @@ # Settings specified here will take precedence over those in config/environment.rb +require 'lib/patches/fixtures_constraint_disabling' + # The test environment is used exclusively to run your application's # test suite. You never need to work with it otherwise. Remember that # your test database is "scratch space" for the test suite and is wiped diff --git a/lib/patches/fixtures_constraint_disabling.rb b/lib/patches/fixtures_constraint_disabling.rb new file mode 100644 index 000000000..7d97e81f7 --- /dev/null +++ b/lib/patches/fixtures_constraint_disabling.rb @@ -0,0 +1,21 @@ +# An alternative way of disabling foreign keys in fixture loading in Postgres and +# does not require superuser permissions +# http://kopongo.com/2008/7/25/postgres-ri_constrainttrigger-error +require 'active_record/connection_adapters/postgresql_adapter' +module ActiveRecord + module ConnectionAdapters + class PostgreSQLAdapter < AbstractAdapter + def disable_referential_integrity(&block) + transaction { + begin + execute "SET CONSTRAINTS ALL DEFERRED" + yield + ensure + execute "SET CONSTRAINTS ALL IMMEDIATE" + end + } + end + end + end +end + diff --git a/locale/app.pot b/locale/app.pot index c370a1dcb..eef335b5c 100644 --- a/locale/app.pot +++ b/locale/app.pot @@ -1195,6 +1195,10 @@ msgstr "" msgid "Follow these requests" msgstr "" +#: app/models/user.rb:133 +msgid "{{user_name}} (Account suspended)" +msgstr "" + #: app/views/public_body/show.rhtml:4 msgid "Follow this authority" msgstr "" diff --git a/locale/cy/app.po b/locale/cy/app.po index 954f20f9f..617f7bbff 100644 --- a/locale/cy/app.po +++ b/locale/cy/app.po @@ -3908,7 +3908,7 @@ msgid "" msgstr "" #: app/models/user.rb:122 -msgid "{{user_name}} (Banned)" +msgid "{{user_name}} (Account suspended)" msgstr "" #: app/views/request_mailer/comment_on_alert.rhtml:1 diff --git a/locale/de/app.po b/locale/de/app.po index 10aac0f9e..da1a55b11 100644 --- a/locale/de/app.po +++ b/locale/de/app.po @@ -5078,8 +5078,8 @@ msgstr "" "{{site_name}} Benutzer haben {{number_of_requests}} Anfragen gestellt, u.a.:" #: app/models/user.rb:133 -msgid "{{user_name}} (Banned)" -msgstr "{{user_name}} (Banned)" +msgid "{{user_name}} (Account suspended)" +msgstr "{{user_name}} (Account suspended)" #: app/views/track_mailer/event_digest.rhtml:31 msgid "{{user_name}} added an annotation" diff --git a/locale/en/app.po b/locale/en/app.po index c8693fbd0..436f63b10 100644 --- a/locale/en/app.po +++ b/locale/en/app.po @@ -3968,7 +3968,7 @@ msgid "" msgstr "" #: app/models/user.rb:122 -msgid "{{user_name}} (Banned)" +msgid "{{user_name}} (Account suspended)" msgstr "" #: app/views/request_mailer/comment_on_alert.rhtml:1 diff --git a/locale/es/app.po b/locale/es/app.po index f51a7327e..a7e7a97e2 100644 --- a/locale/es/app.po +++ b/locale/es/app.po @@ -1219,7 +1219,7 @@ msgstr "" "para el nombre" #: app/models/user.rb:133 -msgid "{{user_name}} (Banned)" +msgid "{{user_name}} (Account suspended)" msgstr "{{user_name}} (Expulsado)" #: app/models/user.rb:146 diff --git a/locale/fr/app.po b/locale/fr/app.po index 74dbbdb33..21def02ca 100644 --- a/locale/fr/app.po +++ b/locale/fr/app.po @@ -1078,7 +1078,7 @@ msgstr "" "nom." #: app/models/user.rb:133 -msgid "{{user_name}} (Banned)" +msgid "{{user_name}} (Account suspended)" msgstr "" #: app/models/user.rb:146 diff --git a/locale/sq/app.po b/locale/sq/app.po index cf09cf3b5..7f09488ad 100644 --- a/locale/sq/app.po +++ b/locale/sq/app.po @@ -5021,7 +5021,7 @@ msgstr "" "përfshirë:" #: app/models/user.rb:133 -msgid "{{user_name}} (Banned)" +msgid "{{user_name}} (Account suspended)" msgstr "{{user_name}} (Përjashtuar)" #: app/views/track_mailer/event_digest.rhtml:31 diff --git a/locale/sq/app.po_ b/locale/sq/app.po_ index 2bf510317..b4988db14 100644 --- a/locale/sq/app.po_ +++ b/locale/sq/app.po_ @@ -4283,7 +4283,7 @@ msgid "" msgstr "" #: app/models/user.rb:122 -msgid "{{user_name}} (Banned)" +msgid "{{user_name}} (Account suspended)" msgstr "" #: app/views/request_mailer/comment_on_alert.rhtml:1 diff --git a/locale/sq/app_old3.po b/locale/sq/app_old3.po index 548775fc1..07463d4e7 100644 --- a/locale/sq/app_old3.po +++ b/locale/sq/app_old3.po @@ -4529,7 +4529,7 @@ msgstr "" "strong> për këtë autoritet." #: app/models/user.rb:122 -msgid "{{user_name}} (Banned)" +msgid "{{user_name}} (Account suspended)" msgstr "" #: app/views/request_mailer/comment_on_alert.rhtml:1 diff --git a/locale/sq/app_old4.po b/locale/sq/app_old4.po index a0a7b952e..d80e13397 100644 --- a/locale/sq/app_old4.po +++ b/locale/sq/app_old4.po @@ -4283,7 +4283,7 @@ msgid "" msgstr "" #: app/models/user.rb:122 -msgid "{{user_name}} (Banned)" +msgid "{{user_name}} (Account suspended)" msgstr "" #: app/views/request_mailer/comment_on_alert.rhtml:1 diff --git a/locale/sq/app_old5.po b/locale/sq/app_old5.po index 780ae4b41..40b79ed7b 100644 --- a/locale/sq/app_old5.po +++ b/locale/sq/app_old5.po @@ -4423,7 +4423,7 @@ msgstr "" "për këtë autoritet." #: app/models/user.rb:122 -msgid "{{user_name}} (Banned)" +msgid "{{user_name}} (Account suspended)" msgstr "{{user_name}} (Përjashtuar)" #: app/views/request_mailer/comment_on_alert.rhtml:1 diff --git a/locale/sr/app.po b/locale/sr/app.po index 9d13a3a0d..bfbab585f 100644 --- a/locale/sr/app.po +++ b/locale/sr/app.po @@ -3899,7 +3899,7 @@ msgid "" msgstr "" #: app/models/user.rb:122 -msgid "{{user_name}} (Banned)" +msgid "{{user_name}} (Account suspended)" msgstr "" #: app/views/request_mailer/comment_on_alert.rhtml:1 diff --git a/locale/sr@latin/app.po b/locale/sr@latin/app.po index d362dc935..92c1da85c 100644 --- a/locale/sr@latin/app.po +++ b/locale/sr@latin/app.po @@ -3900,7 +3900,7 @@ msgid "" msgstr "" #: app/models/user.rb:122 -msgid "{{user_name}} (Banned)" +msgid "{{user_name}} (Account suspended)" msgstr "" #: app/views/request_mailer/comment_on_alert.rhtml:1 diff --git a/script/spec-all-pairs b/script/spec-all-pairs index 338f56147..e8fa77be9 100755 --- a/script/spec-all-pairs +++ b/script/spec-all-pairs @@ -4,8 +4,7 @@ # to winkle out order-dependent failures. test_pair () { - rake db:test:purge > /dev/null - rake db:test:clone_structure > /dev/null + rake db:test:prepare > /dev/null 2>&1 if script/spec "$1" "$2" > /dev/null 2>&1 then echo "OK: $1 $2" @@ -40,8 +39,8 @@ pairs_from_stdin() { while read line do case "$line" in - \*\ FAILED:\ *) - spec/*.rb spec/$.rb) + \*\ FAILED:\ *|\ + spec/*.rb\ spec/*.rb) line=${line#\* FAILED: } if ! test_pair $line then diff --git a/spec/controllers/admin_public_body_controller_spec.rb b/spec/controllers/admin_public_body_controller_spec.rb index 08d465ca5..1e82a0ba4 100644 --- a/spec/controllers/admin_public_body_controller_spec.rb +++ b/spec/controllers/admin_public_body_controller_spec.rb @@ -2,7 +2,6 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe AdminPublicBodyController, "when administering public bodies" do integrate_views - 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 do username = MySociety::Config.get('ADMIN_USERNAME', '') @@ -80,7 +79,6 @@ end describe AdminPublicBodyController, "when administering public bodies and paying attention to authentication" do integrate_views - 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 "disallows non-authenticated users to do anything" do @request.env["HTTP_AUTHORIZATION"] = "" @@ -133,7 +131,6 @@ end describe AdminPublicBodyController, "when administering public bodies with i18n" do integrate_views - 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 do username = MySociety::Config.get('ADMIN_USERNAME', '') @@ -202,7 +199,6 @@ end describe AdminPublicBodyController, "when creating public bodies with i18n" do integrate_views - 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 do username = MySociety::Config.get('ADMIN_USERNAME', '') diff --git a/spec/controllers/admin_request_controller_spec.rb b/spec/controllers/admin_request_controller_spec.rb index 5e6f6c2a5..ece1fe389 100644 --- a/spec/controllers/admin_request_controller_spec.rb +++ b/spec/controllers/admin_request_controller_spec.rb @@ -2,7 +2,6 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe AdminRequestController, "when administering requests" do integrate_views - 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 @@ -50,7 +49,6 @@ end describe AdminRequestController, "when administering the holding pen" do integrate_views - 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 basic_auth_login @request load_raw_emails_data diff --git a/spec/controllers/admin_track_controller_spec.rb b/spec/controllers/admin_track_controller_spec.rb index b87ee9f0e..728c79f1f 100644 --- a/spec/controllers/admin_track_controller_spec.rb +++ b/spec/controllers/admin_track_controller_spec.rb @@ -2,7 +2,6 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe AdminTrackController, "when administering tracks" do integrate_views - fixtures :users, :info_requests, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things it "shows the list page" do get :list diff --git a/spec/controllers/admin_user_controller_spec.rb b/spec/controllers/admin_user_controller_spec.rb index 55b49f9da..65ecbc37d 100644 --- a/spec/controllers/admin_user_controller_spec.rb +++ b/spec/controllers/admin_user_controller_spec.rb @@ -2,7 +2,6 @@ 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, :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/comment_controller_spec.rb b/spec/controllers/comment_controller_spec.rb index 4c14b8d24..93752537c 100644 --- a/spec/controllers/comment_controller_spec.rb +++ b/spec/controllers/comment_controller_spec.rb @@ -2,7 +2,6 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe CommentController, "when commenting on a request" do integrate_views - fixtures :users, :public_bodies, :public_body_translations, :public_body_versions, :info_requests, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things it "should give an error and render 'new' template when body text is just some whitespace" do post :new, :url_title => info_requests(:naughty_chicken_request).url_title, diff --git a/spec/controllers/general_controller_spec.rb b/spec/controllers/general_controller_spec.rb index 9a5421a78..7fc019c64 100644 --- a/spec/controllers/general_controller_spec.rb +++ b/spec/controllers/general_controller_spec.rb @@ -19,19 +19,6 @@ end describe GeneralController, "when searching" do integrate_views - 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 diff --git a/spec/controllers/public_body_controller_spec.rb b/spec/controllers/public_body_controller_spec.rb index 06077ac60..e6eca0781 100644 --- a/spec/controllers/public_body_controller_spec.rb +++ b/spec/controllers/public_body_controller_spec.rb @@ -1,11 +1,9 @@ -# -*- coding: undecided -*- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') require 'json' describe PublicBodyController, "when showing a body" do integrate_views - 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 @@ -83,7 +81,6 @@ end describe PublicBodyController, "when listing bodies" do integrate_views - 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 be successful" do get :list @@ -183,8 +180,6 @@ end describe PublicBodyController, "when showing JSON version for API" 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 be successful" do get :show, :url_name => "dfh", :format => "json", :view => 'all' @@ -198,7 +193,6 @@ describe PublicBodyController, "when showing JSON version for API" do 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 diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb index 3b58df869..25dce3f22 100644 --- a/spec/controllers/request_controller_spec.rb +++ b/spec/controllers/request_controller_spec.rb @@ -4,7 +4,6 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') require 'json' describe RequestController, "when listing recent 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(:each) do load_raw_emails_data @@ -122,8 +121,6 @@ end describe RequestController, "when showing one request" 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 # all needed as integrating views - before(:each) do load_raw_emails_data end @@ -238,7 +235,7 @@ describe RequestController, "when showing one request" do response.should have_text(/tënde/u) end - it "should generate valid HTML verson of plain text attachments " do + it "should generate valid HTML verson of plain text attachments" do ir = info_requests(:fancy_dog_request) receive_incoming_mail('incoming-request-two-same-name.email', ir.incoming_email) ir.reload @@ -247,16 +244,53 @@ 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 + # This is a regression test for a bug where URLs of this form were causing 500 errors + # instead of 404s. + # + # (Note that in fact only the integer-prefix of the URL part is used, so there are + # *some* “ugly URLs containing a request id that isn't an integer” that actually return + # a 200 response. The point is that IDs of this sort were triggering an error in the + # error-handling path, causing the wrong sort of error response to be returned in the + # case where the integer prefix referred to the wrong request.) + # + # https://github.com/sebbacon/alaveteli/issues/351 + it "should return 404 for ugly URLs containing 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 = "55195" 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 + get :get_attachment, :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) + + lambda { + get :get_attachment_as_html, :incoming_message_id => ir.incoming_messages[1].id, :id => ugly_id, :part => 2, :file_name => ['hello.txt'], :skip_cache => 1 + }.should raise_error(ActiveRecord::RecordNotFound) + end + it "should return 404 when incoming message and request ids don't match" do + ir = info_requests(:fancy_dog_request) + wrong_id = info_requests(:naughty_chicken_request).id + receive_incoming_mail('incoming-request-two-same-name.email', ir.incoming_email) + ir.reload + lambda { + get :get_attachment_as_html, :incoming_message_id => ir.incoming_messages[1].id, :id => wrong_id, :part => 2, :file_name => ['hello.txt.html'], :skip_cache => 1 + }.should raise_error(ActiveRecord::RecordNotFound) + end + it "should return 404 for ugly URLs contain a request id that isn't an integer, even if the integer prefix refers to an actual request" do + ir = info_requests(:fancy_dog_request) + receive_incoming_mail('incoming-request-two-same-name.email', ir.incoming_email) + ir.reload + ugly_id = "%d95" % [info_requests(:naughty_chicken_request).id] + + lambda { + get :get_attachment, :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) + + lambda { + get :get_attachment_as_html, :incoming_message_id => ir.incoming_messages[1].id, :id => ugly_id, :part => 2, :file_name => ['hello.txt'], :skip_cache => 1 }.should raise_error(ActiveRecord::RecordNotFound) end - it "should return 404 when incoming message and request ids don't match " do + it "should return 404 when incoming message and request ids don't match" do ir = info_requests(:fancy_dog_request) wrong_id = info_requests(:naughty_chicken_request).id receive_incoming_mail('incoming-request-two-same-name.email', ir.incoming_email) @@ -443,7 +477,6 @@ describe RequestController, "when showing one request" do end describe RequestController, "when changing prominence of a request" do - fixtures :public_bodies, :public_body_translations, :public_body_versions, :users, :info_requests, :raw_emails, :incoming_messages, :outgoing_messages, :info_request_events, :track_things # all needed as integrating views before(:each) do load_raw_emails_data @@ -531,7 +564,6 @@ end # end describe RequestController, "when searching for an authority" do - fixtures :public_bodies, :users # Whether or not sign-in is required for this step is configurable, # so we make sure we're logged in, just in case @@ -573,7 +605,6 @@ end describe RequestController, "when creating a new request" do integrate_views - fixtures :public_bodies, :public_body_translations, :public_body_versions, :users, :info_requests, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things before do @user = users(:bob_smith_user) @@ -810,7 +841,6 @@ end describe RequestController, "when viewing an individual response for reply/followup" do integrate_views - fixtures :public_bodies, :public_body_translations, :public_body_versions, :users, :info_requests, :raw_emails, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things # all needed as integrating views before(:each) do load_raw_emails_data @@ -857,8 +887,6 @@ end describe RequestController, "when classifying an information request" 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 # all needed as integrating views - before(:each) do @dog_request = info_requests(:fancy_dog_request) @dog_request.stub!(:is_old_unclassified?).and_return(false) @@ -1197,7 +1225,6 @@ end describe RequestController, "when sending a followup message" do integrate_views - fixtures :public_bodies, :public_body_translations, :public_body_versions, :users, :info_requests, :raw_emails, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things # all needed as integrating views before(:each) do load_raw_emails_data @@ -1280,7 +1307,6 @@ end describe RequestController, "sending overdue request alerts" do integrate_views - fixtures :public_bodies, :public_body_translations, :public_body_versions, :users, :info_requests, :raw_emails, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things # all needed as integrating views before(:each) do load_raw_emails_data @@ -1368,7 +1394,6 @@ end describe RequestController, "sending unclassified new response reminder alerts" do integrate_views - fixtures :public_bodies, :public_body_translations, :public_body_versions, :users, :info_requests, :raw_emails, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things # all needed as integrating views before(:each) do load_raw_emails_data @@ -1399,7 +1424,6 @@ end describe RequestController, "clarification required alerts" do integrate_views - fixtures :public_bodies, :public_body_translations, :public_body_versions, :users, :info_requests, :raw_emails, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things # all needed as integrating views before(:each) do load_raw_emails_data end @@ -1453,7 +1477,6 @@ end describe RequestController, "comment alerts" do integrate_views - fixtures :public_bodies, :public_body_translations, :public_body_versions, :users, :info_requests, :raw_emails, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things # all needed as integrating views before(:each) do load_raw_emails_data end @@ -1528,7 +1551,6 @@ end describe RequestController, "when viewing comments" do integrate_views - fixtures :users, :info_requests, :raw_emails, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things before(:each) do load_raw_emails_data end @@ -1552,7 +1574,6 @@ end describe RequestController, "authority uploads a response from the web interface" do integrate_views - fixtures :public_bodies, :public_body_translations, :public_body_versions, :users, :info_requests, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things before(:each) do # domain after the @ is used for authentication of FOI officers, so to test it @@ -1638,8 +1659,6 @@ describe RequestController, "authority uploads a response from the web interface end describe RequestController, "when showing JSON version for API" 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 @@ -1659,7 +1678,6 @@ describe RequestController, "when showing JSON version for API" do 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 diff --git a/spec/controllers/request_game_controller_spec.rb b/spec/controllers/request_game_controller_spec.rb index 1383554a1..7247cd388 100644 --- a/spec/controllers/request_game_controller_spec.rb +++ b/spec/controllers/request_game_controller_spec.rb @@ -1,8 +1,6 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe RequestGameController, "when playing the game" 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 # all needed as integrating views before(:each) do load_raw_emails_data end diff --git a/spec/controllers/track_controller_spec.rb b/spec/controllers/track_controller_spec.rb index 509aa6725..38a447640 100644 --- a/spec/controllers/track_controller_spec.rb +++ b/spec/controllers/track_controller_spec.rb @@ -36,7 +36,6 @@ end describe TrackController, "when sending alerts for a track" do integrate_views - fixtures :public_bodies, :public_body_translations, :public_body_versions, :users, :info_requests, :raw_emails, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things, :track_things_sent_emails include LinkToHelper # for main_url before(:each) do @@ -115,7 +114,6 @@ end describe TrackController, "when viewing RSS feed for a track" do integrate_views - 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 @@ -141,7 +139,6 @@ end describe TrackController, "when viewing JSON version of a track feed" do integrate_views - 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 diff --git a/spec/controllers/user_controller_spec.rb b/spec/controllers/user_controller_spec.rb index 4e14aeaa3..1a701ad43 100644 --- a/spec/controllers/user_controller_spec.rb +++ b/spec/controllers/user_controller_spec.rb @@ -8,7 +8,6 @@ require 'json' describe UserController, "when showing a user" do integrate_views - 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 rebuild_xapian_index @@ -68,7 +67,6 @@ end describe UserController, "when signing in" do integrate_views - fixtures :users def get_last_postredirect post_redirects = PostRedirect.find_by_sql("select * from post_redirects order by id desc limit 1") @@ -196,7 +194,6 @@ end describe UserController, "when signing up" do integrate_views - fixtures :users it "should be an error if you type the password differently each time" do post :signup, { :user_signup => { :email => 'new@localhost', :name => 'New Person', @@ -254,7 +251,6 @@ end describe UserController, "when signing out" do integrate_views - fixtures :users it "should log you out and redirect to the home page" do session[:user_id] = users(:bob_smith_user).id @@ -279,7 +275,6 @@ end describe UserController, "when sending another user a message" do integrate_views - fixtures :users it "should redirect to signin page if you go to the contact form and aren't signed in" do get :contact, :id => users(:silly_name_user) @@ -317,7 +312,6 @@ end describe UserController, "when changing password" do integrate_views - fixtures :users it "should show the email form when not logged in" do get :signchangepassword @@ -388,7 +382,6 @@ end describe UserController, "when changing email address" do integrate_views - fixtures :users it "should require login" do get :signchangeemail @@ -534,7 +527,6 @@ end describe UserController, "when using profile photos" do integrate_views - fixtures :users before do @user = users(:bob_smith_user) @@ -590,8 +582,6 @@ describe UserController, "when using profile photos" do end describe UserController, "when showing JSON version for API" do - - fixtures :users it "should be successful" do get :show, :url_name => "bob_smith", :format => "json" diff --git a/spec/integration/errors_spec.rb b/spec/integration/errors_spec.rb index ea9caaf12..ec2e1c376 100644 --- a/spec/integration/errors_spec.rb +++ b/spec/integration/errors_spec.rb @@ -2,20 +2,6 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe "When rendering errors" do - fixtures [ - :users, - :public_bodies, - :public_body_translations, - :public_body_versions, - :info_requests, - :raw_emails, - :outgoing_messages, - :incoming_messages, - :comments, - :info_request_events, - :track_things, - ] - before(:each) do load_raw_emails_data ActionController::Base.consider_all_requests_local = false diff --git a/spec/integration/search_request_spec.rb b/spec/integration/search_request_spec.rb index 61f8df313..b62f0a4c4 100644 --- a/spec/integration/search_request_spec.rb +++ b/spec/integration/search_request_spec.rb @@ -2,20 +2,6 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe "When searching" do - fixtures [ - :users, - :public_bodies, - :public_body_translations, - :public_body_versions, - :info_requests, - :raw_emails, - :outgoing_messages, - :incoming_messages, - :comments, - :info_request_events, - :track_things, - ] - before(:each) do load_raw_emails_data rebuild_xapian_index diff --git a/spec/integration/view_request_spec.rb b/spec/integration/view_request_spec.rb index 0787644ff..442721890 100644 --- a/spec/integration/view_request_spec.rb +++ b/spec/integration/view_request_spec.rb @@ -2,20 +2,6 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe "When viewing requests" do - fixtures [ - :users, - :public_bodies, - :public_body_translations, - :public_body_versions, - :info_requests, - :raw_emails, - :outgoing_messages, - :incoming_messages, - :comments, - :info_request_events, - :track_things, - ] - before(:each) do load_raw_emails_data end diff --git a/spec/lib/tmail_extensions_spec.rb b/spec/lib/tmail_extensions_spec.rb index 02ef8b82e..bd89e6a84 100644 --- a/spec/lib/tmail_extensions_spec.rb +++ b/spec/lib/tmail_extensions_spec.rb @@ -5,7 +5,6 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe "when using TMail" do - fixtures :info_requests, :incoming_messages before(:each) do ActionMailer::Base.deliveries.clear diff --git a/spec/models/foi_attachment_spec.rb b/spec/models/foi_attachment_spec.rb index 0d122aa1b..9d44957e4 100644 --- a/spec/models/foi_attachment_spec.rb +++ b/spec/models/foi_attachment_spec.rb @@ -1,7 +1,6 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe FoiAttachment, " when calculating due date" do - fixtures :incoming_messages, :raw_emails, :public_bodies, :public_body_translations, :info_requests, :users, :foi_attachments before(:each) do load_raw_emails_data diff --git a/spec/models/has_tag_string_tag_spec.rb b/spec/models/has_tag_string_tag_spec.rb index 1acd2e27d..57c301471 100644 --- a/spec/models/has_tag_string_tag_spec.rb +++ b/spec/models/has_tag_string_tag_spec.rb @@ -1,7 +1,6 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe HasTagString::HasTagStringTag, " when fiddling with tag strings " do - fixtures :public_bodies, :public_body_translations, :public_body_versions, :info_requests, :raw_emails, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things it "should be able to make a new tag and save it" do @tag = HasTagString::HasTagStringTag.new diff --git a/spec/models/holiday_spec.rb b/spec/models/holiday_spec.rb index 973b067d6..00ebc7279 100644 --- a/spec/models/holiday_spec.rb +++ b/spec/models/holiday_spec.rb @@ -1,7 +1,6 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe Holiday, " when calculating due date" do - fixtures :holidays def due_date(ymd) return Holiday.due_date_from(Date.strptime(ymd), 20).strftime("%F") diff --git a/spec/models/incoming_message_spec.rb b/spec/models/incoming_message_spec.rb index c096e61e0..b6fee7898 100644 --- a/spec/models/incoming_message_spec.rb +++ b/spec/models/incoming_message_spec.rb @@ -2,7 +2,6 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe IncomingMessage, " when dealing with incoming mail" do - fixtures :users, :raw_emails, :public_bodies, :public_body_translations, :public_body_versions, :info_requests, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things before(:each) do @im = incoming_messages(:useless_incoming_message) @@ -191,7 +190,6 @@ describe IncomingMessage, " checking validity to reply to" do end describe IncomingMessage, " checking validity to reply to with real emails" do - fixtures :users, :raw_emails, :public_bodies, :public_body_translations, :info_requests, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things after(:all) do ActionMailer::Base.deliveries.clear @@ -215,7 +213,6 @@ describe IncomingMessage, " checking validity to reply to with real emails" do end describe IncomingMessage, " when censoring data" do - fixtures :users, :raw_emails, :public_bodies, :public_body_translations, :public_body_versions, :info_requests, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things before(:each) do @test_data = "There was a mouse called Stilton, he wished that he was blue." @@ -323,7 +320,6 @@ describe IncomingMessage, " when censoring data" do end describe IncomingMessage, " when censoring whole users" do - fixtures :users, :raw_emails, :public_bodies, :public_body_translations, :public_body_versions, :info_requests, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things before(:each) do @test_data = "There was a mouse called Stilton, he wished that he was blue." @@ -354,7 +350,6 @@ end describe IncomingMessage, " when uudecoding bad messages" do - fixtures :incoming_messages, :raw_emails, :public_bodies, :public_body_translations, :info_requests, :users, :foi_attachments before(:each) do load_raw_emails_data @@ -398,7 +393,6 @@ describe IncomingMessage, " when uudecoding bad messages" do end describe IncomingMessage, "when messages are attached to messages" do - fixtures :incoming_messages, :raw_emails, :public_bodies, :public_body_translations, :info_requests, :users, :foi_attachments before(:each) do load_raw_emails_data @@ -423,7 +417,6 @@ describe IncomingMessage, "when messages are attached to messages" do end describe IncomingMessage, "when Outlook messages are attached to messages" do - fixtures :incoming_messages, :raw_emails, :public_bodies, :public_body_translations, :info_requests, :users, :foi_attachments before(:each) do load_raw_emails_data @@ -446,7 +439,6 @@ describe IncomingMessage, "when Outlook messages are attached to messages" do end describe IncomingMessage, "when TNEF attachments are attached to messages" do - fixtures :incoming_messages, :raw_emails, :public_bodies, :public_body_translations, :info_requests, :users, :foi_attachments before(:each) do load_raw_emails_data diff --git a/spec/models/info_request_event_spec.rb b/spec/models/info_request_event_spec.rb index 9a340c125..7352f3be0 100644 --- a/spec/models/info_request_event_spec.rb +++ b/spec/models/info_request_event_spec.rb @@ -55,7 +55,6 @@ describe InfoRequestEvent do end describe "doing search/index stuff" 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 diff --git a/spec/models/info_request_spec.rb b/spec/models/info_request_spec.rb index 3c8860285..a18a4bd1d 100644 --- a/spec/models/info_request_spec.rb +++ b/spec/models/info_request_spec.rb @@ -3,7 +3,6 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe InfoRequest do describe "guessing a request from an email" 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 @im = incoming_messages(:useless_incoming_message) @@ -73,8 +72,6 @@ describe InfoRequest do end describe " when emailing" do - - fixtures :public_bodies, :public_body_translations, :public_body_versions, :users, :info_requests, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things before do @info_request = info_requests(:fancy_dog_request) @@ -154,7 +151,6 @@ describe InfoRequest do end describe "when calculating the status" do - fixtures :holidays, :public_bodies, :public_body_translations, :public_body_versions, :users, :info_requests, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things before do @ir = info_requests(:naughty_chicken_request) @@ -196,8 +192,6 @@ describe InfoRequest do describe "when using a plugin and calculating the status" do - fixtures :public_bodies, :public_body_translations, :public_body_versions, :users, :info_requests, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things - before do InfoRequest.send(:require, File.expand_path(File.dirname(__FILE__) + '/customstates')) InfoRequest.send(:include, InfoRequestCustomStates) @@ -231,7 +225,6 @@ describe InfoRequest do describe "when calculating the status for a school" do - fixtures :holidays, :public_bodies, :public_body_translations, :public_body_versions, :users, :info_requests, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things before do @ir = info_requests(:naughty_chicken_request) diff --git a/spec/models/outgoing_mailer_spec.rb b/spec/models/outgoing_mailer_spec.rb index 9b8fb5f98..5d1ea2dfb 100644 --- a/spec/models/outgoing_mailer_spec.rb +++ b/spec/models/outgoing_mailer_spec.rb @@ -4,7 +4,6 @@ describe OutgoingMailer, " when working out follow up addresses" do # This is done with fixtures as the code is a bit tangled with the way it # calls TMail. XXX untangle it and make these tests spread out and using # mocks. Put parts of the tests in spec/lib/tmail_extensions.rb - fixtures :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 end @@ -74,7 +73,6 @@ describe OutgoingMailer, " when working out follow up addresses" do end describe OutgoingMailer, "when working out follow up subjects" do - fixtures :info_requests, :raw_emails, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things before(:each) do load_raw_emails_data diff --git a/spec/models/outgoing_message_spec.rb b/spec/models/outgoing_message_spec.rb index 58d9f398e..51bb6fdf5 100644 --- a/spec/models/outgoing_message_spec.rb +++ b/spec/models/outgoing_message_spec.rb @@ -1,7 +1,6 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe OutgoingMessage, " when making an outgoing message" do - fixtures :public_bodies, :public_body_translations, :public_body_versions, :info_requests, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things before do @om = outgoing_messages(:useless_outgoing_message) @@ -38,7 +37,6 @@ end describe IncomingMessage, " when censoring data" do - fixtures :info_requests, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things before do @om = outgoing_messages(:useless_outgoing_message) diff --git a/spec/models/public_body_spec.rb b/spec/models/public_body_spec.rb index 8d667c395..db0de78b2 100644 --- a/spec/models/public_body_spec.rb +++ b/spec/models/public_body_spec.rb @@ -95,7 +95,6 @@ describe PublicBody, " using machine tags" do end describe PublicBody, "when finding_by_tags" do - fixtures :public_bodies, :public_body_translations, :public_body_versions, :info_requests, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things before do @geraldine = public_bodies(:geraldine_public_body) @@ -173,7 +172,6 @@ describe PublicBody, " when saving" do end describe PublicBody, "when searching" do - fixtures :public_bodies, :public_body_translations, :public_body_versions, :info_requests, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things it "should find by existing url name" do body = PublicBody.find_by_url_name_with_historic('dfh') @@ -239,7 +237,6 @@ describe PublicBody, " when dealing public body locales" do end describe PublicBody, " when loading CSV files" do - fixtures :public_bodies, :public_body_versions, :public_body_translations before(:each) do # InternalBody is created the first time it's accessed, which happens sometimes during imports, # depending on the tag used. By accessing it here before every test, it doesn't disturb our checks later on diff --git a/spec/models/request_mailer_spec.rb b/spec/models/request_mailer_spec.rb index 0dd0b749a..64ac35cf7 100644 --- a/spec/models/request_mailer_spec.rb +++ b/spec/models/request_mailer_spec.rb @@ -1,7 +1,6 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') 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 ActionMailer::Base.deliveries = [] diff --git a/spec/models/track_thing_spec.rb b/spec/models/track_thing_spec.rb index 7891bd229..bd122941a 100644 --- a/spec/models/track_thing_spec.rb +++ b/spec/models/track_thing_spec.rb @@ -1,7 +1,6 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe TrackThing, "when tracking changes" do - fixtures :users, :info_requests, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things before do @track_thing = track_things(:track_fancy_dog_search) diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index e0a6c649e..03b2f34f9 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -29,7 +29,7 @@ describe User, "showing the name" do it 'should show if user has been banned' do @user.ban_text = "Naughty user" - @user.name.should == 'Some Name (Banned)' + @user.name.should == 'Some Name (Account suspended)' end end @@ -193,7 +193,6 @@ describe User, "when reindexing referencing models" do end describe User, "when checking abilities" do - fixtures :users, :info_requests, :raw_emails, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things before do @user = users(:bob_smith_user) @@ -283,7 +282,6 @@ describe User, "when setting a profile photo" do end describe User, "when unconfirmed" do - fixtures :users, :info_requests, :raw_emails, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things before do @user = users(:unconfirmed_user) @@ -295,7 +293,6 @@ describe User, "when unconfirmed" do end describe User, "when emails have bounced" do - fixtures :users, :info_requests, :raw_emails, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things it "should record bounces" do User.record_bounce_for_email("bob@localhost", "The reason we think the email bounced (e.g. a bounce message)") diff --git a/spec/models/xapian_spec.rb b/spec/models/xapian_spec.rb index ba06f3eac..81c066184 100644 --- a/spec/models/xapian_spec.rb +++ b/spec/models/xapian_spec.rb @@ -1,7 +1,6 @@ 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 before(:each) do load_raw_emails_data @@ -37,7 +36,6 @@ describe User, " when indexing users with Xapian" do end 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 rebuild_xapian_index @@ -70,7 +68,6 @@ describe PublicBody, " when indexing public bodies with Xapian" do end describe PublicBody, " when indexing requests by body they are to" 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 @@ -127,7 +124,6 @@ describe PublicBody, " when indexing requests by body they are to" do end 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, :public_bodies, :public_body_versions, :public_body_translations before(:each) do load_raw_emails_data rebuild_xapian_index @@ -206,7 +202,6 @@ describe User, " when indexing requests by user they are from" do end 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 rebuild_xapian_index @@ -242,7 +237,6 @@ describe User, " when indexing comments by user they are by" do end 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 rebuild_xapian_index @@ -272,7 +266,6 @@ describe InfoRequest, " when indexing requests by their title" do end 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 rebuild_xapian_index @@ -294,7 +287,6 @@ describe InfoRequest, " when indexing requests by tag" do end 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 rebuild_xapian_index @@ -319,7 +311,6 @@ describe PublicBody, " when indexing authorities by tag" do end 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 rebuild_xapian_index diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index fbc115c38..c00da48bc 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -24,6 +24,7 @@ Spec::Runner.configure do |config| # fixture_path must end in a separator config.fixture_path = File.join(Rails.root, 'spec', 'fixtures') + File::SEPARATOR + config.global_fixtures = :users, :public_bodies, :public_body_translations, :public_body_versions, :info_requests, :raw_emails, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things, :foi_attachments, :has_tag_string_tags, :holidays, :track_things_sent_emails # == Fixtures # diff --git a/vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb b/vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb index ebb3b1cbd..d5c0e89c6 100644 --- a/vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb +++ b/vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb @@ -116,14 +116,17 @@ module ActsAsXapian raise NoXapianRubyBindingsError.new("Xapian Ruby bindings not installed") unless ActsAsXapian.bindings_available raise "acts_as_xapian hasn't been called in any models" if @@init_values.empty? - # if DB is not nil, then we're already initialised, so don't do it again - # XXX we need to reopen the database each time, so Xapian gets changes to it. - # Hopefully in later version of Xapian it will autodetect this, and this can - # be commented back in again. - # return unless @@db.nil? - prepare_environment + # We need to reopen the database each time, so Xapian gets changes to it. + # Calling reopen() does not always pick up changes for reasons that I can + # only speculate about at the moment. (It is easy to reproduce this by + # changing the code below to use reopen() rather than open() followed by + # close(), and running rake spec.) + if !@@db.nil? + @@db.close + end + # basic Xapian objects begin @@db = Xapian::Database.new(@@db_path) |