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

Fix a bug where specialist sectors wouldn't stick #4662

Merged
merged 1 commit into from Mar 5, 2019

Conversation

elliotcm
Copy link
Contributor

@elliotcm elliotcm commented Mar 5, 2019

Because this code was using defined? to check for the presence of the specialist_sectors method on the edition, and the edition is wrapped in a LocalisedModel which technically doesn't have that method defined, the code was replacing existing specialist sectors with recommended ones.

Using respond_to? provides the correct behaviour since it accounts for method_missing in LocalisedModel and therefore uses duck typing to figure out whether it's safe to call specialist_sectors on the object.

https://trello.com/c/9OARj5Uf/813-topics-not-making-it-to-the-publishing-api-from-whitehall

Because this code was using `defined?` to check for the presence of the `specialist_sectors` method on the edition, and the edition is wrapped in a `LocalisedModel` which technically doesn't have that method defined, the code was replacing existing specialist sectors with recommended ones.

Using `respond_to?` provides the correct behaviour since it accounts for `method_missing` in `LocalisedModel` and therefore uses duck typing to figure out whether it's safe to call `specialist_sectors` on the object.
@elliotcm elliotcm merged commit 92ea5c1 into master Mar 5, 2019
@elliotcm elliotcm deleted the fix-specialist-sectors branch March 5, 2019 14:04
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.

None yet

2 participants