|
205 | 205 | ) |
206 | 206 | end |
207 | 207 |
|
| 208 | + it "doesn't include the signatures by constituency data in rejected petitions" do |
| 209 | + petition = FactoryBot.create :rejected_petition |
| 210 | + |
| 211 | + FactoryBot.create :constituency, :coventry_north_east |
| 212 | + FactoryBot.create :constituency, :bethnal_green_and_bow |
| 213 | + |
| 214 | + FactoryBot.create :constituency_petition_journal, constituency_id: 3427, signature_count: 123, petition: petition |
| 215 | + FactoryBot.create :constituency_petition_journal, constituency_id: 3320, signature_count: 456, petition: petition |
| 216 | + |
| 217 | + get "/petitions/#{petition.id}.json" |
| 218 | + expect(response).to be_success |
| 219 | + |
| 220 | + expect(attributes.keys).not_to include("signatures_by_constituency") |
| 221 | + end |
| 222 | + |
208 | 223 | it "includes the signatures by country data" do |
209 | 224 | petition = FactoryBot.create :open_petition |
210 | 225 |
|
|
234 | 249 | ) |
235 | 250 | ) |
236 | 251 | end |
| 252 | + |
| 253 | + it "doesn't include the signatures by country data in rejected petitions" do |
| 254 | + petition = FactoryBot.create :rejected_petition |
| 255 | + |
| 256 | + gb = FactoryBot.create :location, name: "United Kingdom", code: "gb" |
| 257 | + fr = FactoryBot.create :location, name: "France", code: "fr" |
| 258 | + |
| 259 | + FactoryBot.create :country_petition_journal, location: gb, signature_count: 123456, petition: petition |
| 260 | + FactoryBot.create :country_petition_journal, location: fr, signature_count: 789, petition: petition |
| 261 | + |
| 262 | + get "/petitions/#{petition.id}.json" |
| 263 | + expect(response).to be_success |
| 264 | + |
| 265 | + expect(attributes.keys).not_to include("signatures_by_country") |
| 266 | + end |
237 | 267 | end |
238 | 268 | end |
0 commit comments