From 8ca2f1fca08b8d645040bba2d83b77a889067b23 Mon Sep 17 00:00:00 2001 From: Seb Bacon Date: Tue, 12 Jul 2011 14:36:55 +0100 Subject: Refactor custom states loading (use class methods where appropriate, simplify main code at the cost (small) of test legibility) --- app/controllers/request_controller.rb | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) (limited to 'app/controllers/request_controller.rb') diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index b339134eb..44e4880c2 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -12,25 +12,13 @@ class RequestController < ApplicationController before_filter :check_read_only, :only => [ :new, :show_response, :describe_state, :upload_response ] protect_from_forgery :only => [ :new, :show_response, :describe_state, :upload_response ] # See ActionController::RequestForgeryProtection for details - def load_custom_states - @@custom_states_loaded = false + @@custom_states_loaded = false + begin 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) + include RequestControllerCustomStates @@custom_states_loaded = true - rescue NameError end - end - - def initialize - self.load_custom_states + rescue NameError end def show -- cgit v1.2.3