|
2 | 2 | include_context "PutContent call"
|
3 | 3 |
|
4 | 4 | context "with embedded content as a string" do
|
5 |
| - let(:first_contact) { create(:edition, state: "published", content_store: "live", document_type: "contact") } |
| 5 | + let(:first_contact) { create(:edition, state: "published", content_store: "live", document_type: "contact", details: { email: "[email protected]", phone: "123456" }) } |
6 | 6 | let(:second_contact) { create(:edition, state: "published", content_store: "live", document_type: "contact") }
|
7 | 7 | let(:document) { create(:document, content_id:) }
|
8 | 8 | let(:first_embed_code) { "{{embed:contact:#{first_contact.document.content_id}}}" }
|
|
26 | 26 |
|
27 | 27 | expect_content_store_to_have_received_details_including({ "body" => "#{presented_details_for(first_contact, first_embed_code)} #{presented_details_for(second_contact, second_embed_code)}" })
|
28 | 28 | end
|
| 29 | + |
| 30 | + context "when fields are referenced" do |
| 31 | + let(:first_embed_code) { "{{embed:contact:#{first_contact.document.content_id}/email}}" } |
| 32 | + let(:second_embed_code) { "{{embed:contact:#{first_contact.document.content_id}/phone}}" } |
| 33 | + |
| 34 | + let(:body) do |
| 35 | + " |
| 36 | + Hello, here is some an email: |
| 37 | +
|
| 38 | + #{first_embed_code} |
| 39 | +
|
| 40 | + And here is a phone number: |
| 41 | +
|
| 42 | + #{second_embed_code} |
| 43 | + " |
| 44 | + end |
| 45 | + |
| 46 | + let(:expected_body) do |
| 47 | + " |
| 48 | + Hello, here is some an email: |
| 49 | +
|
| 50 | + #{presented_details_for(first_contact, first_embed_code)} |
| 51 | +
|
| 52 | + And here is a phone number: |
| 53 | +
|
| 54 | + #{presented_details_for(first_contact, second_embed_code)} |
| 55 | + " |
| 56 | + end |
| 57 | + |
| 58 | + before do |
| 59 | + payload.merge!(details: { body: }) |
| 60 | + end |
| 61 | + |
| 62 | + it "should send transformed content to the content store" do |
| 63 | + put "/v2/content/#{content_id}", params: payload.to_json |
| 64 | + |
| 65 | + expect_content_store_to_have_received_details_including({ "body" => expected_body }) |
| 66 | + end |
| 67 | + end |
29 | 68 | end
|
30 | 69 |
|
31 | 70 | context "when embedded content is in a details field other than body" do
|
|
0 commit comments