aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/models/info_request_batch_spec.rb22
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