Use readable texts in admin budgets test

Particularly the line with `within "tr", text: "Finished budget" do` is
now easier to read.

This way we avoid a potential pitfall. Imagine that the factory which
creates a finished budget generated a budget with the name "COMPLETED
Budget 1". Then the test:

```
within "#budget_#{finished_budget.id}" do
  expect(page).to have_content("COMPLETED")
end
```

Would pass even if we didn't add the text "COMPLETED" anywhere else,
because it would be included in the name of the budget.
This commit is contained in:
Javi Martín
2021-04-21 14:06:09 +02:00
parent c50e04e9cb
commit 0eedc7b6ab

View File

@@ -27,36 +27,38 @@ describe "Admin budgets", :admin do
end end
scenario "Filters by phase" do scenario "Filters by phase" do
drafting_budget = create(:budget, :drafting) create(:budget, :drafting, name: "Drafting budget")
accepting_budget = create(:budget, :accepting) create(:budget, :accepting, name: "Accepting budget")
selecting_budget = create(:budget, :selecting) create(:budget, :selecting, name: "Selecting budget")
balloting_budget = create(:budget, :balloting) create(:budget, :balloting, name: "Balloting budget")
finished_budget = create(:budget, :finished) create(:budget, :finished, name: "Finished budget")
visit admin_budgets_path visit admin_budgets_path
expect(page).to have_content(drafting_budget.name)
expect(page).to have_content(accepting_budget.name)
expect(page).to have_content(selecting_budget.name)
expect(page).to have_content(balloting_budget.name)
expect(page).to have_content(finished_budget.name)
within "#budget_#{finished_budget.id}" do expect(page).to have_content "Drafting budget"
expect(page).to have_content("COMPLETED") expect(page).to have_content "Accepting budget"
expect(page).to have_content "Selecting budget"
expect(page).to have_content "Balloting budget"
within "tr", text: "Finished budget" do
expect(page).to have_content "COMPLETED"
end end
click_link "Finished" click_link "Finished"
expect(page).not_to have_content(drafting_budget.name)
expect(page).not_to have_content(accepting_budget.name) expect(page).not_to have_content "Drafting budget"
expect(page).not_to have_content(selecting_budget.name) expect(page).not_to have_content "Accepting budget"
expect(page).not_to have_content(balloting_budget.name) expect(page).not_to have_content "Selecting budget"
expect(page).to have_content(finished_budget.name) expect(page).not_to have_content "Balloting budget"
expect(page).to have_content "Finished budget"
click_link "Open" click_link "Open"
expect(page).to have_content(drafting_budget.name)
expect(page).to have_content(accepting_budget.name) expect(page).to have_content "Drafting budget"
expect(page).to have_content(selecting_budget.name) expect(page).to have_content "Accepting budget"
expect(page).to have_content(balloting_budget.name) expect(page).to have_content "Selecting budget"
expect(page).not_to have_content(finished_budget.name) expect(page).to have_content "Balloting budget"
expect(page).not_to have_content "Finished budget"
end end
scenario "Filters are properly highlighted" do scenario "Filters are properly highlighted" do