From 553435c765096ccc548d3935d5d1281ea1b242f8 Mon Sep 17 00:00:00 2001 From: Allan Wazacz Date: Fri, 2 Nov 2018 16:46:53 +0000 Subject: [PATCH 1/2] [WEBDEV-938] Remove date and create Layings card for Group show page --- .../groups_show_page_serializer.rb | 24 ++-- .../groups_controller/show/fixture.yml | 22 +++- .../groups_show_page_serializer/fixture.yml | 22 +++- .../group_not_laying_body.yml | 12 +- .../group_with_end_date.yml | 114 ------------------ .../group_with_no_date.yml | 114 ------------------ .../group_with_no_name.yml | 22 +++- .../group_with_no_name_or_dates.yml | 22 +++- .../groups_show_page_serializer_spec.rb | 26 ---- 9 files changed, 85 insertions(+), 293 deletions(-) delete mode 100644 spec/fixtures/serializers/page_serializer/groups_show_page_serializer/group_with_end_date.yml delete mode 100644 spec/fixtures/serializers/page_serializer/groups_show_page_serializer/group_with_no_date.yml diff --git a/app/serializers/page_serializer/groups_show_page_serializer.rb b/app/serializers/page_serializer/groups_show_page_serializer.rb index 8249076d..24bfecf1 100644 --- a/app/serializers/page_serializer/groups_show_page_serializer.rb +++ b/app/serializers/page_serializer/groups_show_page_serializer.rb @@ -23,7 +23,7 @@ def title def content [].tap do |components| components << ComponentSerializer::SectionComponentSerializer.new(components: section_primary_components, type: 'primary').to_h - components << ComponentSerializer::SectionComponentSerializer.new(components: section_literals, type: 'section').to_h + components << ComponentSerializer::SectionComponentSerializer.new(components: section_components, type: 'section').to_h end end @@ -38,21 +38,21 @@ def heading_content hash[:subheading_content] = 'groups.groups' hash[:subheading_data] = { link: groups_path } hash[:heading_content] = title - hash[:context_content] = @group.date_range end end - def section_literals - [].tap do |component| - component << if @group.is_a?(Parliament::Grom::Decorator::LayingBody) - ComponentSerializer::ParagraphComponentSerializer.new( - content: [{ - content: 'groups.subsidiary-resources.layings', - link: group_made_available_availability_types_layings_path(@group.try(:graph_id)) - }] - ).to_h - end + def list_components + section_components = [] + + if @group.is_a?(Parliament::Grom::Decorator::LayingBody) + section_components << CardFactory.new(heading_text: 'groups.subsidiary-resources.layings-title', heading_url: group_made_available_availability_types_layings_path(@group.try(:graph_id))).build_card end + + section_components + end + + def section_components + [ComponentSerializer::ListComponentSerializer.new(display: 'generic', display_data: [display_data(component: 'list', variant: 'block')], components: list_components).to_h] end end end diff --git a/spec/fixtures/controllers/groups_controller/show/fixture.yml b/spec/fixtures/controllers/groups_controller/show/fixture.yml index c279fbc5..d0011b32 100644 --- a/spec/fixtures/controllers/groups_controller/show/fixture.yml +++ b/spec/fixtures/controllers/groups_controller/show/fixture.yml @@ -99,16 +99,26 @@ main-components: link: "/groups" heading: content: groupName - 1 - context: - content: 12 May 2010 to present - name: section__section data: components: - - name: paragraph + - name: list__generic data: - - content: groups.subsidiary-resources.layings - data: - link: "/groups/7dSvuueH/made-available/availability-types/layings" + type: ol + display: + name: partials__display + data: + - component: list + variant: block + components: + - name: card__generic + data: + heading: + name: heading + data: + content: groups.subsidiary-resources.layings-title + size: 2 + link: "/groups/7dSvuueH/made-available/availability-types/layings" footer-components: - name: footer data: diff --git a/spec/fixtures/serializers/page_serializer/groups_show_page_serializer/fixture.yml b/spec/fixtures/serializers/page_serializer/groups_show_page_serializer/fixture.yml index f5709c5f..aa2648b0 100644 --- a/spec/fixtures/serializers/page_serializer/groups_show_page_serializer/fixture.yml +++ b/spec/fixtures/serializers/page_serializer/groups_show_page_serializer/fixture.yml @@ -84,16 +84,26 @@ main-components: link: "/groups" heading: content: groupName - 1 - context: - content: 12 May 2010 to present - name: section__section data: components: - - name: paragraph + - name: list__generic data: - - content: groups.subsidiary-resources.layings - data: - link: "/groups/7dSvuueH/made-available/availability-types/layings" + type: ol + display: + name: partials__display + data: + - component: list + variant: block + components: + - name: card__generic + data: + heading: + name: heading + data: + content: groups.subsidiary-resources.layings-title + size: 2 + link: "/groups/7dSvuueH/made-available/availability-types/layings" footer-components: - name: footer data: diff --git a/spec/fixtures/serializers/page_serializer/groups_show_page_serializer/group_not_laying_body.yml b/spec/fixtures/serializers/page_serializer/groups_show_page_serializer/group_not_laying_body.yml index 044859fd..881b62ca 100644 --- a/spec/fixtures/serializers/page_serializer/groups_show_page_serializer/group_not_laying_body.yml +++ b/spec/fixtures/serializers/page_serializer/groups_show_page_serializer/group_not_laying_body.yml @@ -84,12 +84,18 @@ main-components: link: "/groups" heading: content: groupName - 1 - context: - content: 12 May 2010 to present - name: section__section data: components: - - + - name: list__generic + data: + type: ol + display: + name: partials__display + data: + - component: list + variant: block + components: [] footer-components: - name: footer data: diff --git a/spec/fixtures/serializers/page_serializer/groups_show_page_serializer/group_with_end_date.yml b/spec/fixtures/serializers/page_serializer/groups_show_page_serializer/group_with_end_date.yml deleted file mode 100644 index 2e132882..00000000 --- a/spec/fixtures/serializers/page_serializer/groups_show_page_serializer/group_with_end_date.yml +++ /dev/null @@ -1,114 +0,0 @@ ---- -layout: - template: layout -meta: - title: groupName - 1 - UK Parliament - request-id: 123456 - open-graph: - title: groupName - 1 - UK Parliament - original-url: https://example.com/ - image-url: https://static.parliament.uk/assets-public/opengraph-oblong.png - image-width: '1200' - image-height: '630' - twitter-card: summary_large_image - opensearch-description-url: https://example.com/search/opensearch -header-components: -- name: link - data: - link: "#content" - display: - name: partials__display - data: - - component: skip-to-content - selector: skiplink - content: shared.header.skip-to-content -- name: status__banner - data: - display: - name: partials__display - data: - - component: status - variant: banner - - component: theme - variant: caution - - component: cookie - selector: cookie - components: - - name: paragraph - data: - - content: shared.header.cookie-banner-text - data: - link: "/meta/cookie-policy" -- name: status__banner - data: - display: - name: partials__display - data: - - component: status - variant: banner - components: - - name: paragraph - data: - - content: shared.header.beta-status -- name: header - data: - components: - - name: link - data: - link: "/" - display: - name: partials__display - data: - - component: uk_parliament - label: shared.header.label - components: - - name: icon__uk-parliament - data: shared.header.label - - name: form__search - data: - global: true - label: search.label - components: - - name: icon__search - data: search.search-icon - search-action: "/search" -main-components: -- name: section__primary - data: - components: - - name: heading1 - data: - subheading: - content: groups.groups - data: - link: "/groups" - heading: - content: groupName - 1 - context: - content: 12 May 2010 to 12 May 2011 -- name: section__section - data: - components: - - name: paragraph - data: - - content: groups.subsidiary-resources.layings - data: - link: "/groups/7dSvuueH/made-available/availability-types/layings" -footer-components: -- name: footer - data: - uk-parliament: shared.footer.uk-parliament - components: - - name: list__generic - data: - type: ul - display: - name: partials__display - data: - - component: list - contents: - - content: shared.footer.current-website - - content: shared.footer.cookie-policy - data: - link: "/meta/cookie-policy" - - content: shared.footer.data-protection-privacy diff --git a/spec/fixtures/serializers/page_serializer/groups_show_page_serializer/group_with_no_date.yml b/spec/fixtures/serializers/page_serializer/groups_show_page_serializer/group_with_no_date.yml deleted file mode 100644 index cef98b75..00000000 --- a/spec/fixtures/serializers/page_serializer/groups_show_page_serializer/group_with_no_date.yml +++ /dev/null @@ -1,114 +0,0 @@ ---- -layout: - template: layout -meta: - title: groupName - 1 - UK Parliament - request-id: 123456 - open-graph: - title: groupName - 1 - UK Parliament - original-url: https://example.com/ - image-url: https://static.parliament.uk/assets-public/opengraph-oblong.png - image-width: '1200' - image-height: '630' - twitter-card: summary_large_image - opensearch-description-url: https://example.com/search/opensearch -header-components: -- name: link - data: - link: "#content" - display: - name: partials__display - data: - - component: skip-to-content - selector: skiplink - content: shared.header.skip-to-content -- name: status__banner - data: - display: - name: partials__display - data: - - component: status - variant: banner - - component: theme - variant: caution - - component: cookie - selector: cookie - components: - - name: paragraph - data: - - content: shared.header.cookie-banner-text - data: - link: "/meta/cookie-policy" -- name: status__banner - data: - display: - name: partials__display - data: - - component: status - variant: banner - components: - - name: paragraph - data: - - content: shared.header.beta-status -- name: header - data: - components: - - name: link - data: - link: "/" - display: - name: partials__display - data: - - component: uk_parliament - label: shared.header.label - components: - - name: icon__uk-parliament - data: shared.header.label - - name: form__search - data: - global: true - label: search.label - components: - - name: icon__search - data: search.search-icon - search-action: "/search" -main-components: -- name: section__primary - data: - components: - - name: heading1 - data: - subheading: - content: groups.groups - data: - link: "/groups" - heading: - content: groupName - 1 - context: - content: "[Date unavailable]" -- name: section__section - data: - components: - - name: paragraph - data: - - content: groups.subsidiary-resources.layings - data: - link: "/groups/7dSvuueH/made-available/availability-types/layings" -footer-components: -- name: footer - data: - uk-parliament: shared.footer.uk-parliament - components: - - name: list__generic - data: - type: ul - display: - name: partials__display - data: - - component: list - contents: - - content: shared.footer.current-website - - content: shared.footer.cookie-policy - data: - link: "/meta/cookie-policy" - - content: shared.footer.data-protection-privacy diff --git a/spec/fixtures/serializers/page_serializer/groups_show_page_serializer/group_with_no_name.yml b/spec/fixtures/serializers/page_serializer/groups_show_page_serializer/group_with_no_name.yml index 17fa9420..fe9e18f9 100644 --- a/spec/fixtures/serializers/page_serializer/groups_show_page_serializer/group_with_no_name.yml +++ b/spec/fixtures/serializers/page_serializer/groups_show_page_serializer/group_with_no_name.yml @@ -84,16 +84,26 @@ main-components: link: "/groups" heading: content: "[Name unavailable]" - context: - content: 12 May 2010 to present - name: section__section data: components: - - name: paragraph + - name: list__generic data: - - content: groups.subsidiary-resources.layings - data: - link: "/groups/7dSvuueH/made-available/availability-types/layings" + type: ol + display: + name: partials__display + data: + - component: list + variant: block + components: + - name: card__generic + data: + heading: + name: heading + data: + content: groups.subsidiary-resources.layings-title + size: 2 + link: "/groups/7dSvuueH/made-available/availability-types/layings" footer-components: - name: footer data: diff --git a/spec/fixtures/serializers/page_serializer/groups_show_page_serializer/group_with_no_name_or_dates.yml b/spec/fixtures/serializers/page_serializer/groups_show_page_serializer/group_with_no_name_or_dates.yml index dd46a427..fe9e18f9 100644 --- a/spec/fixtures/serializers/page_serializer/groups_show_page_serializer/group_with_no_name_or_dates.yml +++ b/spec/fixtures/serializers/page_serializer/groups_show_page_serializer/group_with_no_name_or_dates.yml @@ -84,16 +84,26 @@ main-components: link: "/groups" heading: content: "[Name unavailable]" - context: - content: "[Date unavailable]" - name: section__section data: components: - - name: paragraph + - name: list__generic data: - - content: groups.subsidiary-resources.layings - data: - link: "/groups/7dSvuueH/made-available/availability-types/layings" + type: ol + display: + name: partials__display + data: + - component: list + variant: block + components: + - name: card__generic + data: + heading: + name: heading + data: + content: groups.subsidiary-resources.layings-title + size: 2 + link: "/groups/7dSvuueH/made-available/availability-types/layings" footer-components: - name: footer data: diff --git a/spec/serializers/page_serializer/groups_show_page_serializer_spec.rb b/spec/serializers/page_serializer/groups_show_page_serializer_spec.rb index 540aead0..3d6eedc8 100644 --- a/spec/serializers/page_serializer/groups_show_page_serializer_spec.rb +++ b/spec/serializers/page_serializer/groups_show_page_serializer_spec.rb @@ -13,7 +13,6 @@ context '#to_h' do it 'produces the expected JSON hash' do - expected = get_fixture('fixture') expect(subject.to_yaml).to eq expected @@ -22,37 +21,14 @@ context 'group not laying body' do it 'produces the expected JSON hash without layings' do - expected = get_fixture('group_not_laying_body') expect(subject.to_yaml).to eq expected end end - context 'with end date' do - - it 'produces the expected JSON hash with an end date' do - - expected = get_fixture('group_with_end_date') - - expect(subject.to_yaml).to eq expected - end - end - - context 'with no start or end date' do - - it 'produces the expected JSON hash with no start or end date' do - - expected = get_fixture('group_with_no_date') - - expect(subject.to_yaml).to eq expected - end - end - context 'with no name' do - it 'produces the expected JSON hash with no name' do - expected = get_fixture('group_with_no_name') expect(subject.to_yaml).to eq expected @@ -60,9 +36,7 @@ end context 'with no name or dates' do - it 'produces the expected JSON hash with no name or dates' do - expected = get_fixture('group_with_no_name_or_dates') expect(subject.to_yaml).to eq expected From 296814b91742f11a8c29dec86b7f41abfc830993 Mon Sep 17 00:00:00 2001 From: Allan Wazacz Date: Fri, 2 Nov 2018 17:07:12 +0000 Subject: [PATCH 2/2] Generate new commit hash for Travis --- .../page_serializer/groups_show_page_serializer_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/serializers/page_serializer/groups_show_page_serializer_spec.rb b/spec/serializers/page_serializer/groups_show_page_serializer_spec.rb index 3d6eedc8..7f7b13ba 100644 --- a/spec/serializers/page_serializer/groups_show_page_serializer_spec.rb +++ b/spec/serializers/page_serializer/groups_show_page_serializer_spec.rb @@ -1,7 +1,7 @@ require_relative '../../rails_helper' RSpec.describe PageSerializer::GroupsShowPageSerializer, vcr: true do - include_context "sample request", include_shared: true + include_context 'sample request', include_shared: true let(:response) { Parliament::Request::UrlRequest.new( base_url: ENV['PARLIAMENT_BASE_URL'],