-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add cabinet memberships to term table #15615
base: master
Are you sure you want to change the base?
Conversation
This documents the new (and currently unimplemented) `PersonCard#cabinet_memberships` method. This method will be used to return the cabinet memberships for the current person card.
These docs were originally put here when we thought we'd be adding some bits that would be more useful for external people. As it turns out we've ended up adding the logic to mostly internal classes for now, so we're documenting that in the classes themselves.
We're about to start making another request for the unstable positions CSV on the term table, so I'm adding this method so we've got one place to update what needs stubbing for a term table request.
This means that we can update the stubs needed for the term table without having to update the individual term table tests.
This method uses the unstable positions CSV to get a list of cabinet memberships for the legislature that the method is called on.
This methods uses the Legislature#cabinet_memberships method to get a list of cabinet positions for the whole legislature, then filters that list to only include positions relevant to the current LegislativePeriod instance.
We want to make a request for unstable/positions.csv on each term table page, so we need to stub those requests correctly in the stub_term_table method and add the relevant data for that.
This method was previously just returning an empty array. This commit adds an actual implementation which filters the term memberships to just those for the person that the instance represents.
This loops through the list of cabinet positions that a person has held in the term being viewed and outputs the label along with start and end dates where available.
One of the advantages of testing against fixed data is that you can write concrete tests, rather than abstract ones — i.e. pick a few people with long, complex membership history, and make sure they have the correct memberships in each of a few terms.
I think that's a misreading of that comment. That's saying that the UK
Yep, you definitely are :) Things like changing how the stubbing in tests works could go through separately in advance, as could the docs, and probably the library extensions. |
What does this do?
Outputs cabinet memberships on term table page.
Why was this needed?
We want to output cabinet memberships a member has held in order to finish #24.
Relevant Issue(s)
Fixes #24
Implementation notes
This adds some methods to the
lib/everypolitician_extensions.rb
file which augments the everypolitician-ruby and everypolitician-popolo gems. Currently the logic for connecting a person to a cabinet membership is in thePersonCard
class, as it doesn't really make sense trying to shoehorn it into the Popolo classes.Screenshots
Notes to Reviewer
countries.json
, so it's testing against an older format of CSVstart_date
, it doesn't do anything about thetype
column. I don't think this is an issue becausepositions.csv
now only holds cabinet data (as per Add README for unstable position data interface #15609 (review)).