Files
grecia/spec/system/budgets/stats_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

35 lines
821 B
Ruby

require "rails_helper"
describe "Stats" do
let(:budget) { create(:budget, :finished) }
let(:heading) { create(:budget_heading, budget: budget, price: 1000) }
context "Load" do
before { budget.update(slug: "budget_slug") }
scenario "finds budget by slug" do
visit budget_stats_path("budget_slug")
expect(page).to have_content budget.name
end
end
describe "Show" do
describe "advanced stats" do
scenario "advanced stats enabled" do
budget.update!(advanced_stats_enabled: true)
visit budget_stats_path(budget)
expect(page).to have_content "Advanced statistics"
end
scenario "advanced stats disabled" do
visit budget_stats_path(budget)
expect(page).not_to have_content "Advanced statistics"
end
end
end
end