Show assigned heading on investment show
This commit is contained in:
@@ -1,12 +1,11 @@
|
||||
class Budgets::Investments::BallotComponent < ApplicationComponent
|
||||
attr_reader :investment, :investment_ids, :ballot, :assigned_heading
|
||||
attr_reader :investment, :investment_ids, :ballot
|
||||
delegate :current_user, :heading_link, :link_to_verify_account, to: :helpers
|
||||
|
||||
def initialize(investment:, investment_ids:, ballot:, assigned_heading:)
|
||||
def initialize(investment:, investment_ids:, ballot:)
|
||||
@investment = investment
|
||||
@investment_ids = investment_ids
|
||||
@ballot = ballot
|
||||
@assigned_heading = assigned_heading
|
||||
end
|
||||
|
||||
private
|
||||
@@ -42,6 +41,10 @@ class Budgets::Investments::BallotComponent < ApplicationComponent
|
||||
budget_ballot_path(budget))
|
||||
end
|
||||
|
||||
def assigned_heading
|
||||
ballot.heading_for_group(investment.group)
|
||||
end
|
||||
|
||||
def cannot_vote_text
|
||||
if reason.present? && !voted?
|
||||
t("budgets.ballots.reasons_for_not_balloting.#{reason}",
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<%= render Budgets::Investments::BallotComponent.new(
|
||||
investment: investment,
|
||||
investment_ids: investment_ids,
|
||||
ballot: ballot,
|
||||
assigned_heading: @assigned_heading
|
||||
ballot: ballot
|
||||
) %>
|
||||
|
||||
@@ -8,8 +8,7 @@ describe Budgets::Investments::BallotComponent do
|
||||
Budgets::Investments::BallotComponent.new(
|
||||
investment: investment,
|
||||
investment_ids: [],
|
||||
ballot: Budget::Ballot.where(budget: budget, user: controller.current_user).first_or_create!,
|
||||
assigned_heading: nil
|
||||
ballot: Budget::Ballot.where(budget: budget, user: controller.current_user).first_or_create!
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
@@ -1389,6 +1389,22 @@ describe "Budget Investments" do
|
||||
expect(page).to have_content "€10,000"
|
||||
end
|
||||
|
||||
scenario "Show message if user already voted in other heading" do
|
||||
group = create(:budget_group, budget: budget, name: "Global Group")
|
||||
heading = create(:budget_heading, group: group, name: "Heading 1")
|
||||
investment = create(:budget_investment, :selected, heading: heading)
|
||||
heading2 = create(:budget_heading, group: group, name: "Heading 2")
|
||||
investment2 = create(:budget_investment, :selected, heading: heading2)
|
||||
user = create(:user, :level_two, ballot_lines: [investment])
|
||||
|
||||
login_as(user)
|
||||
visit budget_investment_path(budget, investment2)
|
||||
|
||||
expect(page).to have_selector(".participation-not-allowed",
|
||||
text: "You have already voted a different heading: Heading 1",
|
||||
visible: :hidden)
|
||||
end
|
||||
|
||||
scenario "Sidebar in show should display vote text" do
|
||||
investment = create(:budget_investment, :selected, budget: budget)
|
||||
visit budget_investment_path(budget, investment)
|
||||
|
||||
Reference in New Issue
Block a user