diff options
author | Seb Bacon <seb.bacon@gmail.com> | 2011-07-12 13:39:06 +0100 |
---|---|---|
committer | Seb Bacon <seb.bacon@gmail.com> | 2011-07-12 13:39:06 +0100 |
commit | 3dfc53f6b82b3c5da79a4c710d45b859f61f4f5f (patch) | |
tree | 468b732da39d4b4f8af1c5755835ef9cf065e7df | |
parent | b05260cd94d8ef210c02d96401b7df7dc03ec437 (diff) |
ensure we don't load custom states from plugins when running tests
-rw-r--r-- | app/controllers/request_controller.rb | 8 | ||||
-rw-r--r-- | app/models/info_request.rb | 8 | ||||
-rw-r--r-- | spec/models/info_request_spec.rb | 2 |
3 files changed, 15 insertions, 3 deletions
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index 9fc0a4e26..b339134eb 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -13,13 +13,19 @@ class RequestController < ApplicationController protect_from_forgery :only => [ :new, :show_response, :describe_state, :upload_response ] # See ActionController::RequestForgeryProtection for details def load_custom_states + @@custom_states_loaded = false + if !ENV["RAILS_ENV"] == "test" + load_custom_states! + end + end + + def load_custom_states! begin # InfoRequestCustomStates may be `require`d in a theme # plugin, or by a test RequestController.send(:include, RequestControllerCustomStates) @@custom_states_loaded = true rescue NameError - @@custom_states_loaded = false end end diff --git a/app/models/info_request.rb b/app/models/info_request.rb index 16e66c44a..c51e0c546 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -132,13 +132,19 @@ class InfoRequest < ActiveRecord::Base end def load_custom_states + @@custom_states_loaded = false + if !ENV["RAILS_ENV"] == "test" + load_custom_states! + end + end + + def load_custom_states! begin # InfoRequestCustomStates may be `require`d in a theme # plugin, or by a test InfoRequest.send(:include, InfoRequestCustomStates) @@custom_states_loaded = true rescue NameError - @@custom_states_loaded = false end end diff --git a/spec/models/info_request_spec.rb b/spec/models/info_request_spec.rb index 91b1b0876..c13eda8cb 100644 --- a/spec/models/info_request_spec.rb +++ b/spec/models/info_request_spec.rb @@ -167,7 +167,7 @@ describe InfoRequest do before do InfoRequest.send(:require, File.expand_path(File.dirname(__FILE__) + '/customstates')) @ir = info_requests(:naughty_chicken_request) - @ir.load_custom_states + @ir.load_custom_states! end it "rejects invalid states" do |