Manage the render of the price field on public budget headings

This commit is contained in:
decabeza
2022-02-02 13:20:39 +01:00
committed by taitus
parent 9fb5019f0f
commit 2c16bac5f8
4 changed files with 31 additions and 3 deletions

View File

@@ -8,6 +8,6 @@ class Budgets::GroupsAndHeadingsComponent < ApplicationComponent
private private
def price(heading) def price(heading)
tag.span(budget.formatted_heading_price(heading)) tag.span(budget.formatted_heading_price(heading)) if budget.show_money?
end end
end end

View File

@@ -1,4 +1,4 @@
<div class="single-heading"> <div class="single-heading">
<h2><%= title %></h2> <h2><%= title %></h2>
<p><%= price %></p> <%= price %>
</div> </div>

View File

@@ -16,6 +16,6 @@ class Budgets::SingleHeadingComponent < ApplicationComponent
end end
def price def price
budget.formatted_heading_price(heading) tag.p budget.formatted_heading_price(heading) if budget.show_money?
end end
end end

View File

@@ -119,6 +119,34 @@ describe "Budgets" do
end end
end end
scenario "Hide money on single heading budget" do
budget = create(:budget, :finished, :hide_money)
heading = create(:budget_heading, budget: budget)
visit budgets_path
within("#budget_info") do
expect(page).to have_content heading.name
expect(page).not_to have_content ""
end
end
scenario "Hide money on multiple headings budget" do
budget = create(:budget, :finished, :hide_money)
heading1 = create(:budget_heading, budget: budget)
heading2 = create(:budget_heading, budget: budget)
heading3 = create(:budget_heading, budget: budget)
visit budgets_path
within("#budget_info") do
expect(page).to have_content heading1.name
expect(page).to have_content heading2.name
expect(page).to have_content heading3.name
expect(page).not_to have_content ""
end
end
scenario "No budgets" do scenario "No budgets" do
Budget.destroy_all Budget.destroy_all