diff options
author | Seb Bacon <seb.bacon@gmail.com> | 2011-07-12 10:51:30 +0100 |
---|---|---|
committer | Seb Bacon <seb.bacon@gmail.com> | 2011-07-12 10:51:30 +0100 |
commit | 438367a13ae31fb7ebcc30bf4a9e82ec7e9f78a7 (patch) | |
tree | 6515b918c55db3079a7c0ae3a17a9025a5602c80 /app/controllers/request_controller.rb | |
parent | 5132e9aa7e161aad91544340703e8e3ba6aea8f3 (diff) |
Improve factoring out of custom states code (refactor a little, add tests)
Diffstat (limited to 'app/controllers/request_controller.rb')
-rw-r--r-- | app/controllers/request_controller.rb | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index 103349311..9fc0a4e26 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -12,6 +12,21 @@ 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 + 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 + + def initialize + self.load_custom_states + end + def show @locale = self.locale_from_params() PublicBody.with_locale(@locale) do @@ -369,6 +384,7 @@ class RequestController < ApplicationController end return end + # Display advice for requester on what to do next, as appropriate if @info_request.calculate_status == 'waiting_response' flash[:notice] = _("<p>Thank you! Hopefully your wait isn't too long.</p> <p>By law, you should get a response promptly, and normally before the end of <strong> @@ -420,9 +436,9 @@ class RequestController < ApplicationController flash[:notice] = _("If you have not done so already, please write a message below telling the authority that you have withdrawn your request. Otherwise they will not know it has been withdrawn.") redirect_to respond_to_last_url(@info_request) else - begin - return theme_describe_state(@info_request) - rescue NoMethodError + if @@custom_states_loaded + return self.theme_describe_state(@info_request) + else raise "unknown calculate_status " + @info_request.calculate_status end end |