Skip to content

Commit 1215db0

Browse files
authored
Merge pull request #581 from alphagov/fix-local-api-when-dissolved
Check for presence of an MP in local JSON data
2 parents 2f9f89c + e2d4a6f commit 1215db0

2 files changed

Lines changed: 49 additions & 3 deletions

File tree

app/views/local_petitions/_petitions.json.jbuilder

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
json.constituency constituency.name
22

3-
json.mp do
4-
json.name constituency.mp_name
5-
json.url constituency.mp_url
3+
if constituency.sitting_mp?
4+
json.mp do
5+
json.name constituency.mp_name
6+
json.url constituency.mp_url
7+
end
68
end
79

810
json.petitions petitions do |petition|

features/freya_searches_for_petitions_by_constituency.feature

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,47 @@ Feature: Freya searches petitions by constituency
100100
And I search for petitions local to me in "S4 8AA"
101101
Then the markup should be valid
102102
And I should not see a link to the MP for my constituency
103+
104+
Scenario: Downloading the JSON data for open local petitions when the mp has passed away
105+
Given a constituency "Sheffield, Brightside and Hillsborough" with MP "Harry Harpham" is found by postcode "S4 8AA"
106+
And the MP has passed away
107+
When I am on the home page
108+
And I search for petitions local to me in "S4 8AA"
109+
Then the markup should be valid
110+
When I click the JSON link
111+
Then I should be on the local petitions JSON page
112+
And the JSON should be valid
113+
114+
Scenario: Downloading the JSON data for all local petitions when the mp has passed away
115+
Given a constituency "Sheffield, Brightside and Hillsborough" with MP "Harry Harpham" is found by postcode "S4 8AA"
116+
And the MP has passed away
117+
When I am on the home page
118+
And I search for petitions local to me in "S4 8AA"
119+
Then the markup should be valid
120+
When I click the view all local petitions
121+
Then I should be on the all local petitions results page
122+
And the markup should be valid
123+
When I click the JSON link
124+
Then I should be on the all local petitions JSON page
125+
And the JSON should be valid
126+
127+
Scenario: Downloading the CSV data for local petitions when the mp has passed away
128+
Given a constituency "Sheffield, Brightside and Hillsborough" with MP "Harry Harpham" is found by postcode "S4 8AA"
129+
And the MP has passed away
130+
When I am on the home page
131+
And I search for petitions local to me in "S4 8AA"
132+
Then the markup should be valid
133+
When I click the CSV link
134+
Then I should get a download with the filename "open-popular-petitions-in-sheffield-brightside-and-hillsborough.csv"
135+
136+
Scenario: Downloading the CSV data for local petitions when the mp has passed away
137+
Given a constituency "Sheffield, Brightside and Hillsborough" with MP "Harry Harpham" is found by postcode "S4 8AA"
138+
And the MP has passed away
139+
When I am on the home page
140+
And I search for petitions local to me in "S4 8AA"
141+
Then the markup should be valid
142+
When I click the view all local petitions
143+
Then I should be on the all local petitions results page
144+
And the markup should be valid
145+
When I click the CSV link
146+
Then I should get a download with the filename "all-popular-petitions-in-sheffield-brightside-and-hillsborough.csv"

0 commit comments

Comments
 (0)