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