test/govspeak_contacts_test.rb in govspeak-4.0.0 vs test/govspeak_contacts_test.rb in govspeak-5.0.0
- old
+ new
@@ -1,15 +1,13 @@
# encoding: UTF-8
require 'test_helper'
-require 'ostruct'
class GovspeakContactsTest < Minitest::Test
def build_contact(attrs={})
- OpenStruct.new(
- has_postal_address?: attrs.fetch(:has_postal_address?, true),
+ {
id: attrs.fetch(:id, 123456),
content_id: attrs.fetch(:content_id, "4f3383e4-48a2-4461-a41d-f85ea8b89ba0"),
title: attrs.fetch(:title, "Government Digital Service"),
recipient: attrs.fetch(:recipient, ""),
street_address: attrs.fetch(:street_address, "125 Kingsway"),
@@ -18,14 +16,14 @@
region: attrs.fetch(:region, "London"),
country_code: attrs.fetch(:country_code, "gb"),
email: attrs.fetch(:email, "people@digital.cabinet-office.gov.uk"),
contact_form_url: attrs.fetch(:contact_form_url, ""),
contact_numbers: attrs.fetch(:contact_numbers,
- [OpenStruct.new(label: "helpdesk", number: "+4412345 67890")]),
+ [{ label: "helpdesk", number: "+4412345 67890" }]),
comments: attrs.fetch(:comments, ""),
worldwide_organisation_path: attrs.fetch(:worldwide_organisation_path, nil),
- )
+ }
end
def compress_html(html)
html.gsub(/[\n\r]+[\s]*/,'')
end
@@ -75,10 +73,16 @@
rendered = Govspeak::Document.new("[Contact:4f3383e4-48a2-4461-a41d-f85ea8b89ba0]").to_html
assert_match("", rendered)
end
test "contact with no postal address omits the address info" do
- contact = build_contact(has_postal_address?: false)
+ contact = build_contact(
+ recipient: nil,
+ street_address: nil,
+ locality: nil,
+ region: nil,
+ postal_code: nil,
+ )
govspeak = "[Contact:4f3383e4-48a2-4461-a41d-f85ea8b89ba0]"
rendered = Govspeak::Document.new(govspeak, { contacts: [contact] }).to_html
expected_html_output = %{
<div id="contact_123456" class="contact">
<div class="content">