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.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
class Legislation::Proposals::VotesComponent < ApplicationComponent
|
||||
attr_reader :proposal
|
||||
delegate :css_classes_for_vote, :current_user, :link_to_verify_account, :votes_percentage, to: :helpers
|
||||
delegate :current_user, :link_to_verify_account, to: :helpers
|
||||
|
||||
def initialize(proposal)
|
||||
@proposal = proposal
|
||||
@@ -8,10 +8,6 @@ class Legislation::Proposals::VotesComponent < ApplicationComponent
|
||||
|
||||
private
|
||||
|
||||
def voted_classes
|
||||
@voted_classes ||= css_classes_for_vote(proposal)
|
||||
end
|
||||
|
||||
def can_vote?
|
||||
proposal.votable_by?(current_user)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user