Files
nairobi/spec/features/admin/legislation/proposals_spec.rb
Javi Martín db97f9d08c Add and apply rubocop rules for empty lines
We were very inconsistent regarding these rules.

Personally I prefer no empty lines around blocks, clases, etc... as
recommended by the Ruby style guide [1], and they're the default values
in rubocop, so those are the settings I'm applying.

The exception is the `private` access modifier, since we were leaving
empty lines around it most of the time. That's the default rubocop rule
as well. Personally I don't have a strong preference about this one.


[1] https://rubystyle.guide/#empty-lines-around-bodies
2019-10-24 17:11:47 +02:00

83 lines
3.5 KiB
Ruby

require "rails_helper"
describe "Admin collaborative legislation" do
before do
admin = create(:administrator)
login_as(admin.user)
end
context "Index" do
scenario "Displaying legislation proposals" do
proposal = create(:legislation_proposal, cached_votes_score: 10)
visit admin_legislation_process_proposals_path(proposal.legislation_process_id)
within "#legislation_proposal_#{proposal.id}" do
expect(page).to have_content(proposal.title)
expect(page).to have_content(proposal.id)
expect(page).to have_content(proposal.cached_votes_score)
expect(page).to have_content("Select")
end
end
scenario "Selecting legislation proposals", :js do
proposal = create(:legislation_proposal, cached_votes_score: 10)
visit admin_legislation_process_proposals_path(proposal.legislation_process_id)
click_link "Select"
within "#legislation_proposal_#{proposal.id}" do
expect(page).to have_content("Selected")
end
end
scenario "Sorting legislation proposals by title", js: true do
process = create(:legislation_process)
create(:legislation_proposal, title: "bbbb", legislation_process_id: process.id)
create(:legislation_proposal, title: "aaaa", legislation_process_id: process.id)
create(:legislation_proposal, title: "cccc", legislation_process_id: process.id)
visit admin_legislation_process_proposals_path(process.id)
select "Title", from: "order-selector-participation"
within("#legislation_proposals_list") do
within all(".legislation_proposal")[0] { expect(page).to have_content("aaaa") }
within all(".legislation_proposal")[1] { expect(page).to have_content("bbbb") }
within all(".legislation_proposal")[2] { expect(page).to have_content("cccc") }
end
end
scenario "Sorting legislation proposals by supports", js: true do
process = create(:legislation_process)
create(:legislation_proposal, cached_votes_score: 10, legislation_process_id: process.id)
create(:legislation_proposal, cached_votes_score: 30, legislation_process_id: process.id)
create(:legislation_proposal, cached_votes_score: 20, legislation_process_id: process.id)
visit admin_legislation_process_proposals_path(process.id)
select "Total supports", from: "order-selector-participation"
within("#legislation_proposals_list") do
within all(".legislation_proposal")[0] { expect(page).to have_content("30") }
within all(".legislation_proposal")[1] { expect(page).to have_content("20") }
within all(".legislation_proposal")[2] { expect(page).to have_content("10") }
end
end
scenario "Sorting legislation proposals by Id", js: true do
process = create(:legislation_process)
proposal1 = create(:legislation_proposal, title: "bbbb", legislation_process_id: process.id)
proposal2 = create(:legislation_proposal, title: "aaaa", legislation_process_id: process.id)
proposal3 = create(:legislation_proposal, title: "cccc", legislation_process_id: process.id)
visit admin_legislation_process_proposals_path(process.id, order: :title)
select "Id", from: "order-selector-participation"
within("#legislation_proposals_list") do
within all(".legislation_proposal")[0] { expect(page).to have_content(proposal1.id) }
within all(".legislation_proposal")[1] { expect(page).to have_content(proposal2.id) }
within all(".legislation_proposal")[2] { expect(page).to have_content(proposal3.id) }
end
end
end
end