Check for attribute values in current budget tests
Assigning a variable to each budget we declare results in useless assignments. We could just delete the three useless assignments and leave the fourth one, but I find the code easier to read if we use the name of the budgets to differenciate between them. This way we also keep the code vertically aligned.
This commit is contained in:
@@ -5,13 +5,13 @@ describe ApplicationController do
|
||||
describe "#current_budget" do
|
||||
|
||||
it "returns the last budget that is not in draft phase" do
|
||||
old_budget = create(:budget, :finished, created_at: 2.years.ago)
|
||||
previous_budget = create(:budget, :accepting, created_at: 1.year.ago)
|
||||
current_budget = create(:budget, :accepting, created_at: 1.month.ago)
|
||||
next_budget = create(:budget, :drafting, created_at: 1.week.ago)
|
||||
create(:budget, :finished, created_at: 2.years.ago, name: "Old")
|
||||
create(:budget, :accepting, created_at: 1.year.ago, name: "Previous")
|
||||
create(:budget, :accepting, created_at: 1.month.ago, name: "Current")
|
||||
create(:budget, :drafting, created_at: 1.week.ago, name: "Next")
|
||||
|
||||
budget = subject.instance_eval { current_budget }
|
||||
expect(budget).to eq(current_budget)
|
||||
expect(budget.name).to eq("Current")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user