diff options
author | Louise Crow <louise.crow@gmail.com> | 2013-10-28 13:33:08 +0000 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2013-12-04 09:32:43 +0000 |
commit | 90fd2c06e48c17909b9a7d2aae6d01c41047b4de (patch) | |
tree | 3e30ab49e09f8d33fd61ceec2bfeb166808c354d /spec/models/info_request_batch_spec.rb | |
parent | 97b7bc835eaa59da76c50db2c3105e4adcf89a8d (diff) |
Add the specific salutations to each request.
Also, wrap model creation in a transaction and do the message sending
separately - we may ultimately want to do this outside the request
cycle.
Diffstat (limited to 'spec/models/info_request_batch_spec.rb')
-rw-r--r-- | spec/models/info_request_batch_spec.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/spec/models/info_request_batch_spec.rb b/spec/models/info_request_batch_spec.rb index 787b812cf..ba4bcd181 100644 --- a/spec/models/info_request_batch_spec.rb +++ b/spec/models/info_request_batch_spec.rb @@ -64,3 +64,25 @@ describe InfoRequestBatch, "when finding an existing batch" do [@first_request.public_body_id]).should be_nil end end + +describe InfoRequestBatch, "when creating a batch", :focus => true do + + it 'should substitute authority name for the placeholder in each request' do + info_request_params = {:title => 'A test title'} + outgoing_message_params = {:body => "Dear [Authority name],\nA message\nYours faithfully,\nRequester", + } + first_public_body = FactoryGirl.create(:public_body) + second_public_body = FactoryGirl.create(:public_body) + user = FactoryGirl.create(:user) + results = InfoRequestBatch.create_batch!(info_request_params, + outgoing_message_params, + [first_public_body.id, second_public_body.id], + user) + info_requests = results[:batch].info_requests + [first_public_body, second_public_body].each do |public_body| + request = info_requests.detect{|info_request| info_request.public_body == public_body} + request.outgoing_messages.first.body.should == "Dear #{public_body.name},\nA message\nYours faithfully,\nRequester" + end + end + +end |