Files
nairobi/app/components/debates/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
338 B
Ruby

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