Skip to content

Commit

Permalink
Merge pull request #581 from alphagov/fix-local-api-when-dissolved
Browse files Browse the repository at this point in the history
Check for presence of an MP in local JSON data
  • Loading branch information
pixeltrix authored May 3, 2017
2 parents 2f9f89c + e2d4a6f commit 1215db0
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 3 deletions.
8 changes: 5 additions & 3 deletions app/views/local_petitions/_petitions.json.jbuilder
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
json.constituency constituency.name

json.mp do
json.name constituency.mp_name
json.url constituency.mp_url
if constituency.sitting_mp?
json.mp do
json.name constituency.mp_name
json.url constituency.mp_url
end
end

json.petitions petitions do |petition|
Expand Down
44 changes: 44 additions & 0 deletions features/freya_searches_for_petitions_by_constituency.feature
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,47 @@ Feature: Freya searches petitions by constituency
And I search for petitions local to me in "S4 8AA"
Then the markup should be valid
And I should not see a link to the MP for my constituency

Scenario: Downloading the JSON data for open local petitions when the mp has passed away
Given a constituency "Sheffield, Brightside and Hillsborough" with MP "Harry Harpham" is found by postcode "S4 8AA"
And the MP has passed away
When I am on the home page
And I search for petitions local to me in "S4 8AA"
Then the markup should be valid
When I click the JSON link
Then I should be on the local petitions JSON page
And the JSON should be valid

Scenario: Downloading the JSON data for all local petitions when the mp has passed away
Given a constituency "Sheffield, Brightside and Hillsborough" with MP "Harry Harpham" is found by postcode "S4 8AA"
And the MP has passed away
When I am on the home page
And I search for petitions local to me in "S4 8AA"
Then the markup should be valid
When I click the view all local petitions
Then I should be on the all local petitions results page
And the markup should be valid
When I click the JSON link
Then I should be on the all local petitions JSON page
And the JSON should be valid

Scenario: Downloading the CSV data for local petitions when the mp has passed away
Given a constituency "Sheffield, Brightside and Hillsborough" with MP "Harry Harpham" is found by postcode "S4 8AA"
And the MP has passed away
When I am on the home page
And I search for petitions local to me in "S4 8AA"
Then the markup should be valid
When I click the CSV link
Then I should get a download with the filename "open-popular-petitions-in-sheffield-brightside-and-hillsborough.csv"

Scenario: Downloading the CSV data for local petitions when the mp has passed away
Given a constituency "Sheffield, Brightside and Hillsborough" with MP "Harry Harpham" is found by postcode "S4 8AA"
And the MP has passed away
When I am on the home page
And I search for petitions local to me in "S4 8AA"
Then the markup should be valid
When I click the view all local petitions
Then I should be on the all local petitions results page
And the markup should be valid
When I click the CSV link
Then I should get a download with the filename "all-popular-petitions-in-sheffield-brightside-and-hillsborough.csv"

0 comments on commit 1215db0

Please sign in to comment.