Add type to budget index table
Co-Authored-By: decabeza <alberto@decabeza.es>
This commit is contained in:
committed by
Javi Martín
parent
51bca66533
commit
17b4fb58c9
@@ -7,21 +7,54 @@ describe Admin::Budgets::IndexComponent, type: :component do
|
||||
allow_any_instance_of(Admin::BudgetsController).to receive(:current_filter).and_return("all")
|
||||
end
|
||||
|
||||
it "displays current phase zero for budgets with no current phase" do
|
||||
budget = create(:budget, :accepting, name: "Not enabled phase")
|
||||
budget.phases.accepting.update!(enabled: false)
|
||||
describe "#phase_progress_text" do
|
||||
it "displays current phase zero for budgets with no current phase" do
|
||||
budget = create(:budget, :accepting, name: "Not enabled phase")
|
||||
budget.phases.accepting.update!(enabled: false)
|
||||
|
||||
render_inline Admin::Budgets::IndexComponent.new(Budget.page(1))
|
||||
render_inline Admin::Budgets::IndexComponent.new(Budget.page(1))
|
||||
|
||||
expect(page.find("tr", text: "Not enabled phase")).to have_content "0/8"
|
||||
expect(page.find("tr", text: "Not enabled phase")).to have_content "0/8"
|
||||
end
|
||||
|
||||
it "displays phase zero out of zero for budgets with no enabled phases" do
|
||||
budget = create(:budget, name: "Without phases")
|
||||
budget.phases.each { |phase| phase.update!(enabled: false) }
|
||||
|
||||
render_inline Admin::Budgets::IndexComponent.new(Budget.page(1))
|
||||
|
||||
expect(page.find("tr", text: "Without phases")).to have_content "0/0"
|
||||
end
|
||||
end
|
||||
|
||||
it "displays phase zero out of zero for budgets with no enabled phases" do
|
||||
budget = create(:budget, name: "Without phases")
|
||||
budget.phases.each { |phase| phase.update!(enabled: false) }
|
||||
describe "#type" do
|
||||
let(:budget) { create(:budget, name: "With type") }
|
||||
|
||||
render_inline Admin::Budgets::IndexComponent.new(Budget.page(1))
|
||||
it "displays 'single heading' for budgets with one heading" do
|
||||
create(:budget_heading, budget: budget)
|
||||
|
||||
expect(page.find("tr", text: "Without phases")).to have_content "0/0"
|
||||
render_inline Admin::Budgets::IndexComponent.new(Budget.page(1))
|
||||
|
||||
expect(page.find("thead")).to have_content "Type"
|
||||
expect(page.find("tr", text: "With type")).to have_content "Single heading"
|
||||
end
|
||||
|
||||
it "displays 'multiple headings' for budgets with multiple headings" do
|
||||
2.times { create(:budget_heading, budget: budget) }
|
||||
|
||||
render_inline Admin::Budgets::IndexComponent.new(Budget.page(1))
|
||||
|
||||
expect(page.find("thead")).to have_content "Type"
|
||||
expect(page.find("tr", text: "With type")).to have_content "Multiple headings"
|
||||
end
|
||||
|
||||
it "displays 'pending: no headings yet' for budgets without headings" do
|
||||
create(:budget, name: "Without headings")
|
||||
|
||||
render_inline Admin::Budgets::IndexComponent.new(Budget.page(1))
|
||||
|
||||
expect(page.find("thead")).to have_content "Type"
|
||||
expect(page.find("tr", text: "Without headings")).to have_content "Pending: No headings yet"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -447,4 +447,43 @@ describe Budget do
|
||||
expect(Valuator.count).to be 1
|
||||
end
|
||||
end
|
||||
|
||||
describe "#single_heading?" do
|
||||
it "returns false for budgets with no groups nor headings" do
|
||||
expect(create(:budget).single_heading?).to be false
|
||||
end
|
||||
|
||||
it "returns false for budgets with one group and no headings" do
|
||||
create(:budget_group, budget: budget)
|
||||
|
||||
expect(budget.single_heading?).to be false
|
||||
end
|
||||
|
||||
it "returns false for budgets with multiple groups and one heading" do
|
||||
2.times { create(:budget_group, budget: budget) }
|
||||
create(:budget_heading, group: budget.groups.last)
|
||||
|
||||
expect(budget.single_heading?).to be false
|
||||
end
|
||||
|
||||
it "returns false for budgets with one group and multiple headings" do
|
||||
group = create(:budget_group, budget: budget)
|
||||
2.times { create(:budget_heading, group: group) }
|
||||
|
||||
expect(budget.single_heading?).to be false
|
||||
end
|
||||
|
||||
it "returns false for budgets with one group and multiple headings" do
|
||||
2.times { create(:budget_group, budget: budget) }
|
||||
2.times { create(:budget_heading, group: budget.groups.sample) }
|
||||
|
||||
expect(budget.single_heading?).to be false
|
||||
end
|
||||
|
||||
it "returns true for budgets with one group and one heading" do
|
||||
create(:budget_heading, group: create(:budget_group, budget: budget))
|
||||
|
||||
expect(budget.single_heading?).to be true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -30,8 +30,10 @@ describe "Admin budgets", :admin do
|
||||
budget = create(:budget, :accepting)
|
||||
visit admin_budgets_path
|
||||
|
||||
expect(page).to have_content budget.name
|
||||
expect(page).to have_content "Accepting projects"
|
||||
within "tr", text: budget.name do
|
||||
expect(page).to have_content "Accepting projects"
|
||||
expect(page).to have_content "Pending: No headings yet"
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Filters by phase" do
|
||||
|
||||
Reference in New Issue
Block a user