do not display alert when supporting for whole city
This commit is contained in:
@@ -90,4 +90,10 @@ module BudgetsHelper
|
||||
t("admin.budgets.winners.recalculate")
|
||||
end
|
||||
end
|
||||
|
||||
def display_support_alert?(investment)
|
||||
current_user &&
|
||||
!current_user.voted_in_group?(investment.group) &&
|
||||
investment.group.headings.count > 1
|
||||
end
|
||||
end
|
||||
|
||||
@@ -18,8 +18,9 @@
|
||||
class: "button button-support small expanded",
|
||||
title: t('budgets.investments.investment.support_title'),
|
||||
method: "post",
|
||||
remote: (current_user && current_user.voted_in_group?(investment.group) ? true : false),
|
||||
data: (current_user && current_user.voted_in_group?(investment.group) ? nil : { confirm: t('budgets.investments.investment.confirm_group', count: investment.group.max_votable_headings)} ),
|
||||
remote: (display_support_alert?(investment) ? false: true ),
|
||||
data: (display_support_alert?(investment) ? {
|
||||
confirm: t("budgets.investments.investment.confirm_group")} : nil),
|
||||
"aria-hidden" => css_for_aria_hidden(reason) do %>
|
||||
<%= t("budgets.investments.investment.give_support") %>
|
||||
<% end %>
|
||||
|
||||
@@ -1307,6 +1307,7 @@ feature 'Budget Investments' do
|
||||
carabanchel_investment = create(:budget_investment, :selected, heading: carabanchel)
|
||||
salamanca_investment = create(:budget_investment, :selected, heading: salamanca)
|
||||
|
||||
login_as(author)
|
||||
visit budget_investments_path(budget, heading_id: carabanchel.id)
|
||||
|
||||
within("#budget_investment_#{carabanchel_investment.id}") do
|
||||
@@ -1332,21 +1333,35 @@ feature 'Budget Investments' do
|
||||
end
|
||||
|
||||
scenario "When supporting in another group", :js do
|
||||
carabanchel = create(:budget_heading, group: group)
|
||||
another_heading = create(:budget_heading, group: create(:budget_group, budget: budget))
|
||||
heading = create(:budget_heading, group: group)
|
||||
|
||||
carabanchel_investment = create(:budget_investment, heading: carabanchel)
|
||||
another_group_investment = create(:budget_investment, heading: another_heading)
|
||||
group2 = create(:budget_group, budget: budget)
|
||||
another_heading1 = create(:budget_heading, group: group2)
|
||||
another_heading2 = create(:budget_heading, group: group2)
|
||||
|
||||
create(:vote, votable: carabanchel_investment, voter: author)
|
||||
heading_investment = create(:budget_investment, heading: heading)
|
||||
another_group_investment = create(:budget_investment, heading: another_heading1)
|
||||
|
||||
create(:vote, votable: heading_investment, voter: author)
|
||||
|
||||
login_as(author)
|
||||
visit budget_investments_path(budget, heading_id: another_heading.id)
|
||||
visit budget_investments_path(budget, heading_id: another_heading1.id)
|
||||
|
||||
within("#budget_investment_#{another_group_investment.id}") do
|
||||
expect(page).to have_css(".in-favor a[data-confirm]")
|
||||
end
|
||||
end
|
||||
|
||||
scenario "When supporting in a group with a single heading", :js do
|
||||
all_city_investment = create(:budget_investment, heading: heading)
|
||||
|
||||
login_as(author)
|
||||
visit budget_investments_path(budget, heading_id: heading.id)
|
||||
|
||||
within("#budget_investment_#{all_city_investment.id}") do
|
||||
expect(page).not_to have_css(".in-favor a[data-confirm]")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Sidebar in show should display support text" do
|
||||
|
||||
Reference in New Issue
Block a user