diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/factories.rb | 26 | ||||
-rw-r--r-- | spec/helpers/application_helper_spec.rb | 34 |
2 files changed, 54 insertions, 6 deletions
diff --git a/spec/factories.rb b/spec/factories.rb index 8efc53033..4ae99be5b 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -69,14 +69,22 @@ FactoryGirl.define do body 'Some information please' what_doing 'normal_sort' end - initialize_with { OutgoingMessage.new({ :status => status, - :message_type => message_type, - :body => body, - :what_doing => what_doing }) } - after_create do |outgoing_message| - outgoing_message.send_message + end + factory :internal_review_request do + ignore do + status 'ready' + message_type 'followup' + body 'I want a review' + what_doing 'internal_review' end end + initialize_with { OutgoingMessage.new({ :status => status, + :message_type => message_type, + :body => body, + :what_doing => what_doing }) } + after_create do |outgoing_message| + outgoing_message.send_message + end end factory :info_request do @@ -109,6 +117,12 @@ FactoryGirl.define do end end + factory :info_request_with_internal_review_request do + after_create do |info_request, evaluator| + outgoing_message = FactoryGirl.create(:internal_review_request, :info_request => info_request) + end + end + factory :external_request do user nil external_user_name 'External User' diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb new file mode 100644 index 000000000..6407eaf3a --- /dev/null +++ b/spec/helpers/application_helper_spec.rb @@ -0,0 +1,34 @@ +require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') + +describe ApplicationHelper do + + include ApplicationHelper + include LinkToHelper + + describe 'when creating an event description' do + + it 'should generate a description for a request' do + @info_request = FactoryGirl.create(:info_request) + @sent_event = @info_request.get_last_event + expected = "Request sent to #{public_body_link_absolute(@info_request.public_body)} by #{request_user_link_absolute(@info_request)}" + event_description(@sent_event).should match(expected) + + end + + it 'should generate a description for a response' do + @info_request_with_incoming = FactoryGirl.create(:info_request_with_incoming) + @response_event = @info_request_with_incoming.get_last_event + expected = "Response by #{public_body_link_absolute(@info_request_with_incoming.public_body)} to #{request_user_link_absolute(@info_request_with_incoming)}" + event_description(@response_event).should match(expected) + end + + it 'should generate a description for a request where an internal review has been requested' do + @info_request_with_internal_review_request = FactoryGirl.create(:info_request_with_internal_review_request) + @response_event = @info_request_with_internal_review_request.get_last_event + expected = "Internal review request sent to #{public_body_link_absolute(@info_request_with_internal_review_request.public_body)} by #{request_user_link_absolute(@info_request_with_internal_review_request)}" + event_description(@response_event).should match(expected) + end + + end + +end |