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:
Javi Martín
2019-09-21 23:53:42 +02:00
parent e2b536e8f8
commit bd795be80e
2 changed files with 10 additions and 10 deletions

View File

@@ -5,13 +5,13 @@ describe ApplicationController do
describe "#current_budget" do describe "#current_budget" do
it "returns the last budget that is not in draft phase" do it "returns the last budget that is not in draft phase" do
old_budget = create(:budget, :finished, created_at: 2.years.ago) create(:budget, :finished, created_at: 2.years.ago, name: "Old")
previous_budget = create(:budget, :accepting, created_at: 1.year.ago) create(:budget, :accepting, created_at: 1.year.ago, name: "Previous")
current_budget = create(:budget, :accepting, created_at: 1.month.ago) create(:budget, :accepting, created_at: 1.month.ago, name: "Current")
next_budget = create(:budget, :drafting, created_at: 1.week.ago) create(:budget, :drafting, created_at: 1.week.ago, name: "Next")
budget = subject.instance_eval { current_budget } budget = subject.instance_eval { current_budget }
expect(budget).to eq(current_budget) expect(budget.name).to eq("Current")
end end
end end

View File

@@ -166,12 +166,12 @@ describe Budget do
end end
it "returns the last budget created that is not in drafting phase" do it "returns the last budget created that is not in drafting phase" do
old_budget = create(:budget, :finished, created_at: 2.years.ago) create(:budget, :finished, created_at: 2.years.ago, name: "Old")
previous_budget = create(:budget, :accepting, created_at: 1.year.ago) create(:budget, :accepting, created_at: 1.year.ago, name: "Previous")
current_budget = create(:budget, :accepting, created_at: 1.month.ago) create(:budget, :accepting, created_at: 1.month.ago, name: "Current")
next_budget = create(:budget, :drafting, created_at: 1.week.ago) create(:budget, :drafting, created_at: 1.week.ago, name: "Next")
expect(Budget.current).to eq(current_budget) expect(Budget.current.name).to eq "Current"
end end
end end