Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move case studies routes #4372

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open

Move case studies routes #4372

wants to merge 13 commits into from

Conversation

georges1996
Copy link
Contributor

@georges1996 georges1996 commented Nov 4, 2024

⚠️ This repo is Continuously Deployed: make sure you follow the guidance ⚠️

This PR #4379 needs to be merged in and this will need to be rebased to fix the case studies which have translations e.g https://www.gov.uk/government/case-studies/doing-business-in-spain

What

Handle Case Studies documents in Frontend, in preparation for them being taken out of Government Frontend

Why

Ticket: https://trello.com/c/ybpXwp34/368-move-document-type-casestudy-from-government-frontend-to-frontend

How

By moving the routes and necessary code to get the pages rendering in the frontend application

Screenshots?

Frontend

Screenshot 2024-11-06 at 08 22 40 Screenshot 2024-11-06 at 08 23 02

Gov-Frontend

Screenshot 2024-11-06 at 08 22 34 Screenshot 2024-11-06 at 08 22 54

@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4372 November 4, 2024 20:26 Inactive
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4372 November 4, 2024 20:28 Inactive
@georges1996 georges1996 changed the title Move case studies documents Move case studies routes Nov 4, 2024
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4372 November 4, 2024 20:38 Inactive
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4372 November 4, 2024 20:42 Inactive
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4372 November 4, 2024 20:54 Inactive
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4372 November 4, 2024 20:59 Inactive
@georges1996 georges1996 force-pushed the move-case-studies-pages branch from 4b79f76 to 5736b90 Compare November 4, 2024 21:01
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4372 November 4, 2024 21:01 Inactive
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4372 November 4, 2024 21:10 Inactive
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4372 November 4, 2024 21:13 Inactive
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4372 November 4, 2024 21:19 Inactive
@georges1996 georges1996 force-pushed the move-case-studies-pages branch from dbc0da6 to f4d9f5d Compare November 4, 2024 21:27
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4372 November 4, 2024 21:28 Inactive
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4372 November 5, 2024 07:11 Inactive
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4372 November 5, 2024 07:16 Inactive
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4372 November 5, 2024 07:23 Inactive
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4372 November 5, 2024 12:27 Inactive
@georges1996 georges1996 force-pushed the move-case-studies-pages branch from aee5af8 to 6d4592f Compare November 5, 2024 12:50
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4372 November 5, 2024 12:51 Inactive
@georges1996 georges1996 force-pushed the move-case-studies-pages branch from 6d4592f to 40db71b Compare November 5, 2024 13:03
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4372 November 5, 2024 13:04 Inactive
@georges1996 georges1996 force-pushed the move-case-studies-pages branch from 40db71b to a368c2c Compare November 5, 2024 13:15
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4372 November 5, 2024 13:15 Inactive
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4372 November 6, 2024 08:30 Inactive
@govuk-ci govuk-ci had a problem deploying to govuk-frontend-app-pr-4372 November 6, 2024 08:36 Failure
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4372 November 6, 2024 08:46 Inactive
@georges1996 georges1996 force-pushed the move-case-studies-pages branch from e8d36b1 to 0d5579a Compare November 6, 2024 14:36
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4372 November 6, 2024 14:36 Inactive
@georges1996 georges1996 force-pushed the move-case-studies-pages branch from 0d5579a to dc0a31b Compare November 6, 2024 14:55
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4372 January 15, 2025 12:22 Inactive
@georges1996 georges1996 force-pushed the move-case-studies-pages branch from 734330f to 2a2bb7b Compare January 15, 2025 12:40
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4372 January 15, 2025 12:41 Inactive
@georges1996 georges1996 force-pushed the move-case-studies-pages branch from 2a2bb7b to 578bdf2 Compare January 16, 2025 08:10
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4372 January 16, 2025 08:10 Inactive
@georges1996 georges1996 force-pushed the move-case-studies-pages branch from 578bdf2 to 2b2548d Compare January 16, 2025 11:14
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4372 January 16, 2025 11:14 Inactive
@georges1996 georges1996 force-pushed the move-case-studies-pages branch from 2b2548d to 3dbe69a Compare January 16, 2025 11:20
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4372 January 16, 2025 11:20 Inactive
@georges1996 georges1996 force-pushed the move-case-studies-pages branch from 3dbe69a to cd1dceb Compare January 16, 2025 11:21
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4372 January 16, 2025 11:21 Inactive
Copy link
Contributor

@leenagupte leenagupte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank for making the changes requested in the previous reviews.

There are only 3 inline comments this time, all of them related to tests. The most important one is that there are no tests for the contributors method in the case study the model.

spec/helpers/link_helper_spec.rb Outdated Show resolved Hide resolved
@@ -0,0 +1,8 @@
RSpec.describe CaseStudy do
it_behaves_like "it has updates", "case_study", "has-updates"
it_behaves_like "it has updates", "case_study", "only-has-first-published-at"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "only-has-first-published-at" example is bogus because the "first_published_at" is later than the "public_updated_at". It shouldn't be possible for that scenario to occur.

include WorldwideOrganisations
include Organisations

def contributors
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be tests for this method.

@georges1996 georges1996 force-pushed the move-case-studies-pages branch from cd1dceb to ea1daab Compare January 20, 2025 15:21
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4372 January 20, 2025 15:21 Inactive
- https://github.com/alphagov/government-frontend/blob/2e602630db112fe0594653cebbeb313396e67a02/app/presenters/content_item/linkable.rb

As part of this commit I needed to change the govuk_styled_link method as
it was causing tests to fail in CI. This was due to some of the link titles
containing an &. This change fixes this issue and all tests pass

This is creating a helper method to allow us to move some of the presentation logic
into a helper to avoid us from either needing to recreate the presenter, or creating a model concern.
Due to the complexity of the Linkable presenter, we have decided to split the
Organisations and WorldwideOrganisations collections into their own concerns
this makes it easier to manage as the logic in the Linkable presenter in government-frontend
was very hard to understand and unpick.

In addition to this the Metadata presenter from government-frontend was consuming the organisations
array from the Linkable presenter, which seemed odd as a child concern should not be consuming
another child concerns methods.

This change is in preparation for allowing the ContentItem model to have a parent method to return just
organisations, we will then add an overriding method in the document type model to override this,
in this case the Case Study model will consume from both the Organisations and WorldwideOrganisations concern.

- https://github.com/alphagov/government-frontend/blob/2e602630db112fe0594653cebbeb313396e67a02/app/presenters/content_item/linkable.rb
- https://github.com/alphagov/government-frontend/blob/2e602630db112fe0594653cebbeb313396e67a02/app/presenters/content_item/metadata.rb
- To expose first_public_at and first_published_at attributes
- Add Organisations concern
- Add contributors method which calls the organisations function from Organisations concern
to allow us to have a default value for all document_types

We need both first_public_at and first_published_at as these both need
to be checked otherwise updates won't be picked up for the other document types
that use this concern.

We have added a contributors function which returns the list of contributors,
these are then rendered in the "from" section of the publisher_metadata partial.
The contributors function will default to return just organisations for all document_types
however this function will be overriden depending on what each document_type needs.
Using govuk-docker-run rake "consolidation:copy_translation[content_item.schema_name.case_study]"
we port over the case_study translations and change it to be under our new yaml structure

Audit trail:
- https://github.com/alphagov/government-frontend/tree/0aee348d51cebacd5344115f2ca02bdb17095249/config/locales
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants