Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Those with the relevant permissions can override a government associated with a particular item of content - see https://docs.publishing.service.gov.uk/repos/whitehall/history_mode.html#overrides. The implementation was buggy insofar as Publishing API (and thus Content Store, and the frontend) would always be one version behind. 1. Document is associated with Government A. 2. You edit via the UI, to associate with Government B instead. 3. In the UI, the government shows as Government B, but the draft preview continues to show Government A. (This is the case even if you go on to publish the content). 4. You edit via the UI, to associate with Government C instead. 5. In the UI, the government shows as Government C, but the draft preview now shows Government B. This appears to be down to unexpected caching within `PublishingApi::PayloadBuilder::Links`, whereby calling `item.government` returns the old government association. Calling `item.reload.government` did not help, but fetching the government ID and using that to instantiate a new `Government` object seemed to work. This was established by adding a `byebug` within the method and prying the `news_article_presenter` locally. ``` $ news_article.government <Government id: 19, slug: "1935-to-1945-national-government", name: "1935 to 1945 National government", start_date: "1935-11-15", end_date: "1945-07-26", created_at: "2015-03-02 15:33:46.000000000 +0000", updated_at: "2019-11-25 11:05:27.000000000 +0000", content_id: "a05c2130-60c3-4d92-9f30-1cd3fb9d4a00"> $ news_article.government_id 25 ``` This led me to narrow it down to the `@government` inline caching in the Edition model. Fetchign the government 'fresh' on each call eliminates this kind of bug. Trello: https://trello.com/c/dGAmUBKc/2833-investigate-republishing-docs-reassociated-with-different-government Stop caching `government` - see previous commits
- Loading branch information