Keep DB clean after running budget stats spec
This spec was leaving the DB "dirty" because it was creating records in a before(:all) hook. These records are not cleaned up automatically when using the :transaction strategy for DatabaseCleaner. Using before(:each), however, causes another problem. Some of the code depends on the heading id being 1 (see app/models/budget/ballot/line.rb#L48). Because of SQL auto-increment, this is only the case the first time the hook is run, as different id's are assigned on subsequent runs. This is fixed by forcing the id to always be 1.
This commit is contained in:
@@ -2,7 +2,7 @@ require "rails_helper"
|
||||
|
||||
describe Budget::Stats do
|
||||
|
||||
before(:all) do
|
||||
before(:each) do
|
||||
@budget = create(:budget)
|
||||
@group = create(:budget_group, budget: @budget)
|
||||
@heading = create(:budget_heading, group: @group, price: 1000)
|
||||
|
||||
Reference in New Issue
Block a user