Manage the render of the price field on public budget headings
This commit is contained in:
@@ -8,6 +8,6 @@ class Budgets::GroupsAndHeadingsComponent < ApplicationComponent
|
||||
private
|
||||
|
||||
def price(heading)
|
||||
tag.span(budget.formatted_heading_price(heading))
|
||||
tag.span(budget.formatted_heading_price(heading)) if budget.show_money?
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<div class="single-heading">
|
||||
<h2><%= title %></h2>
|
||||
<p><%= price %></p>
|
||||
<%= price %>
|
||||
</div>
|
||||
|
||||
@@ -16,6 +16,6 @@ class Budgets::SingleHeadingComponent < ApplicationComponent
|
||||
end
|
||||
|
||||
def price
|
||||
budget.formatted_heading_price(heading)
|
||||
tag.p budget.formatted_heading_price(heading) if budget.show_money?
|
||||
end
|
||||
end
|
||||
|
||||
@@ -119,6 +119,34 @@ describe "Budgets" do
|
||||
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
|
||||
Budget.destroy_all
|
||||
|
||||
|
||||
Reference in New Issue
Block a user