Files
grecia/app/components/legislation/proposals/votes_component.rb
Javi Martín 86ad2df46d Unify code in debates/legislation vote links
We were using the same code to render links to agree and disagree, so we
can extract a new component for this code.

We're also adding component tests to make it easier to test whether
we're breaking anything while refactoring, although the code is probably
already covered by system tests.

Since the votes mixin was only used in one place, we're removing it and
moving most of its code to a new CSS file for the shared component.
2022-02-21 18:47:13 +01:00

19 lines
363 B
Ruby

class Legislation::Proposals::VotesComponent < ApplicationComponent
attr_reader :proposal
delegate :current_user, :link_to_verify_account, to: :helpers
def initialize(proposal)
@proposal = proposal
end
private
def can_vote?
proposal.votable_by?(current_user)
end
def organization?
current_user&.organization?
end
end