displays summary for districts

This commit is contained in:
rgarcia
2016-02-19 18:15:18 +01:00
parent bbeb02e9a9
commit 6fde504e67
4 changed files with 59 additions and 10 deletions

View File

@@ -1188,6 +1188,27 @@ feature 'Proposals' do
end
end
scenario "Displays proposals grouped by district" do
california = create(:geozone, name: 'California')
new_york = create(:geozone, name: 'New York')
3.times { create(:proposal, geozone: california) }
3.times { create(:proposal, geozone: new_york) }
visit proposals_path
click_link "The most supported proposals by category"
within("#california") do
expect(page).to have_content("California")
expect(page).to have_css(".proposal", count: 3)
end
within("#new-york") do
expect(page).to have_content("New York")
expect(page).to have_css(".proposal", count: 3)
end
end
scenario "Displays a maximum of 3 proposals per category" do
create(:tag, kind: 'category', name: 'culture')
4.times { create(:proposal, tag_list: 'culture') }

View File

@@ -643,18 +643,39 @@ describe Proposal do
end
describe "for_summary" do
it "should return proposals tagged with a category" do
create(:tag, kind: 'category', name: 'culture')
proposal = create(:proposal, tag_list: 'culture')
expect(Proposal.for_summary.values.flatten).to include(proposal)
context "categories" do
it "should return proposals tagged with a category" do
create(:tag, kind: 'category', name: 'culture')
proposal = create(:proposal, tag_list: 'culture')
expect(Proposal.for_summary.values.flatten).to include(proposal)
end
it "should not return proposals tagged without a category" do
create(:tag, kind: 'category', name: 'culture')
proposal = create(:proposal, tag_list: 'parks')
expect(Proposal.for_summary.values.flatten).to_not include(proposal)
end
end
it "should not return proposals tagged without a category" do
create(:tag, kind: 'category', name: 'culture')
proposal = create(:proposal, tag_list: 'parks')
context "districts" do
expect(Proposal.for_summary.values.flatten).to_not include(proposal)
it "should return proposals with a geozone" do
california = create(:geozone, name: 'california')
proposal = create(:proposal, geozone: california)
expect(Proposal.for_summary.values.flatten).to include(proposal)
end
it "should not return proposals without a geozone" do
create(:geozone, name: 'california')
proposal = create(:proposal)
expect(Proposal.for_summary.values.flatten).to_not include(proposal)
end
end
it "should return proposals created this week" do