diff options
author | Louise Crow <louise.crow@gmail.com> | 2013-08-15 17:43:53 +0100 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2013-09-16 12:41:45 +0100 |
commit | 991ddf91f00c879a4a76b40aac4e82217060b600 (patch) | |
tree | af391094fd1d80b02508e53ef25d08c5a444ea7d | |
parent | a9363f6c3926d5a8cba8db79176c1b76bc4118e7 (diff) |
Give incoming message factory a body text.
Also, store an event for the incoming message.
-rw-r--r-- | spec/factories.rb | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/spec/factories.rb b/spec/factories.rb index 36f89037a..2a7ac6e5a 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -3,31 +3,41 @@ FactoryGirl.define do sequence(:email) { |n| "person#{n}@example.com" } factory :foi_attachment do - content_type 'application/pdf' - filename 'interesting.pdf' - body { load_file_fixture('interesting.pdf') } + factory :body_text do + content_type 'text/plain' + body { 'hereisthetext' } + end + factory :pdf_attachment do + content_type 'application/pdf' + filename 'interesting.pdf' + body { load_file_fixture('interesting.pdf') } + end end factory :incoming_message do info_request raw_email last_parsed { 1.week.ago } - + sent_at { 1.week.ago } + mail_from 'A Public Body' factory :incoming_message_with_attachments do # foi_attachments_count is declared as an ignored attribute and available in # attributes on the factory, as well as the callback via the evaluator ignore do - foi_attachments_count 5 + foi_attachments_count 2 end # the after(:create) yields two values; the incoming_message instance itself and the # evaluator, which stores all values from the factory, including ignored # attributes; after(:create) do |incoming_message, evaluator| + FactoryGirl.create(:body_text, + incoming_message: incoming_message, + url_part_number: 1) evaluator.foi_attachments_count.times do |count| - FactoryGirl.create(:foi_attachment, + FactoryGirl.create(:pdf_attachment, incoming_message: incoming_message, - url_part_number: count+1) + url_part_number: count+2) end end end @@ -59,13 +69,15 @@ FactoryGirl.define do factory :info_request_with_incoming do after(:create) do |info_request, evaluator| - FactoryGirl.create(:incoming_message, info_request: info_request) + incoming_message = FactoryGirl.create(:incoming_message, info_request: info_request) + info_request.log_event("response", {:incoming_message_id => incoming_message.id}) end end factory :info_request_with_incoming_attachments do after(:create) do |info_request, evaluator| - FactoryGirl.create(:incoming_message_with_attachments, info_request: info_request) + incoming_message = FactoryGirl.create(:incoming_message_with_attachments, info_request: info_request) + info_request.log_event("response", {:incoming_message_id => incoming_message.id}) end end |