diff options
author | Louise Crow <louise.crow@gmail.com> | 2013-11-27 12:03:28 +0000 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2013-12-04 09:32:44 +0000 |
commit | 51c80db7a35a41fbbab9b28e86a5d60166791b4c (patch) | |
tree | bd2cdf0c16fa6907e4cc06c41c335c630386d375 /spec/models/info_request_batch_spec.rb | |
parent | abc1b8069da09d3ef8523ed64c60b2790a41bf01 (diff) |
Split the creation of a batch and the associated requests.
We're going to want to actually create and send the requests later.
Diffstat (limited to 'spec/models/info_request_batch_spec.rb')
-rw-r--r-- | spec/models/info_request_batch_spec.rb | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/spec/models/info_request_batch_spec.rb b/spec/models/info_request_batch_spec.rb index ba4bcd181..7f6905c8e 100644 --- a/spec/models/info_request_batch_spec.rb +++ b/spec/models/info_request_batch_spec.rb @@ -61,26 +61,25 @@ describe InfoRequestBatch, "when finding an existing batch" do InfoRequestBatch.find_existing(FactoryGirl.create(:user), @info_request_batch.title, @info_request_batch.body, - [@first_request.public_body_id]).should be_nil + [@first_body]).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", - } + 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 + info_request_batch = InfoRequestBatch.create!({:title => 'A test title', + :body => body, + :public_bodies => [first_public_body, + second_public_body], + :user => user}) + results = info_request_batch.create_batch! [first_public_body, second_public_body].each do |public_body| - request = info_requests.detect{|info_request| info_request.public_body == public_body} + request = info_request_batch.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 |