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
47 lines
1.2 KiB
Ruby
47 lines
1.2 KiB
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
|
|
|
|
scenario "raises an error if budget slug is not found" do
|
|
expect do
|
|
visit budget_stats_path("wrong_budget")
|
|
end.to raise_error ActiveRecord::RecordNotFound
|
|
end
|
|
|
|
scenario "raises an error if budget id is not found" do
|
|
expect do
|
|
visit budget_stats_path(0)
|
|
end.to raise_error ActiveRecord::RecordNotFound
|
|
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
|