Files
nairobi/spec/system/budgets/groups_spec.rb
Javi Martín 02981324ab Move exception tests to controller specs
System tests are used to test the application from the user's point of
view. To test for specific exceptions, particularly regarding
authorization permissions, controller tests fit better.

Another option would be to test the page displayed shows a certain text,
like "Internal server error". I'm choosing controller tests because
they're faster and we're basically testing the same scenario many times
and we've already got a test checking what happens when users access a
page raising an exception.
2021-03-31 14:42:20 +02:00

57 lines
1.8 KiB
Ruby

require "rails_helper"
describe "Budget Groups" do
let(:budget) { create(:budget, slug: "budget_slug") }
let!(:group) { create(:budget_group, slug: "group_slug", budget: budget) }
context "Load" do
scenario "finds group using budget slug and group slug" do
visit budget_group_path("budget_slug", "group_slug")
expect(page).to have_content "Select an option"
end
scenario "finds group using budget id and group id" do
visit budget_group_path(budget, group)
expect(page).to have_content "Select an option"
end
end
context "Show" do
scenario "Headings are sorted by name" do
last_heading = create(:budget_heading, group: group, name: "BBB")
first_heading = create(:budget_heading, group: group, name: "AAA")
visit budget_group_path(budget, group)
expect(first_heading.name).to appear_before(last_heading.name)
end
scenario "Links to investment filters", :js do
create(:budget_heading, group: group, name: "Southwest")
budget.update!(phase: "finished")
visit budget_group_path(budget, group)
click_link "See unfeasible investments"
expect(page).to have_css "h3", exact_text: "Unfeasible investments"
expect(page).to have_link "Southwest"
expect(page).not_to have_link "See unfeasible investments"
click_link "See investments not selected for balloting phase"
expect(page).to have_css "h3", exact_text: "Investments not selected for balloting phase"
expect(page).to have_link "Southwest"
expect(page).not_to have_link "See investments not selected for balloting phase unfeasible investments"
end
scenario "Back link", :js do
visit budget_group_path(budget, group)
click_link "Go back"
expect(page).to have_current_path budget_path(budget)
end
end
end