aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/request_controller_spec.rb3
-rw-r--r--spec/models/customstates.rb17
-rw-r--r--spec/models/info_request_spec.rb3
3 files changed, 15 insertions, 8 deletions
diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb
index 64f3f8061..4943e4a6c 100644
--- a/spec/controllers/request_controller_spec.rb
+++ b/spec/controllers/request_controller_spec.rb
@@ -719,7 +719,8 @@ describe RequestController, "when classifying an information request" do
describe "when using custom statuses from the theme" do
InfoRequest.send(:require, File.expand_path(File.join(File.dirname(__FILE__), '..', 'models', 'customstates')))
-
+ InfoRequest.send(:include, InfoRequestCustomStates)
+ InfoRequest.class_eval('@@custom_states_loaded = true')
it "knows about extended states" do
Time.stub!(:now).and_return(Time.utc(2007, 11, 10, 00, 01))
post_status('deadline_extended')
diff --git a/spec/models/customstates.rb b/spec/models/customstates.rb
index de8d04ffb..406d4ead9 100644
--- a/spec/models/customstates.rb
+++ b/spec/models/customstates.rb
@@ -1,4 +1,9 @@
module InfoRequestCustomStates
+
+ def self.included(base)
+ base.extend(ClassMethods)
+ end
+
# Mixin methods for InfoRequest
def theme_display_status(status)
if status == 'deadline_extended'
@@ -10,12 +15,6 @@ module InfoRequestCustomStates
end
end
- def theme_extra_states
- return ['deadline_extended',
- 'wrong_response']
- end
-
-
def theme_calculate_status
return 'waiting_classification' if self.awaiting_description
waiting_response = self.described_state == "waiting_response" || self.described_state == "deadline_extended"
@@ -41,6 +40,12 @@ module InfoRequestCustomStates
return Holiday.due_date_from(self.date_response_required_by, 15)
end
+ module ClassMethods
+ def theme_extra_states
+ return ['deadline_extended',
+ 'wrong_response']
+ end
+ end
end
module RequestControllerCustomStates
diff --git a/spec/models/info_request_spec.rb b/spec/models/info_request_spec.rb
index c13eda8cb..ab1ef1ce0 100644
--- a/spec/models/info_request_spec.rb
+++ b/spec/models/info_request_spec.rb
@@ -166,8 +166,9 @@ describe InfoRequest do
before do
InfoRequest.send(:require, File.expand_path(File.dirname(__FILE__) + '/customstates'))
+ InfoRequest.send(:include, InfoRequestCustomStates)
+ InfoRequest.class_eval('@@custom_states_loaded = true')
@ir = info_requests(:naughty_chicken_request)
- @ir.load_custom_states!
end
it "rejects invalid states" do