This way we can remove duplication and simplify the code in the view. Note we're not using the "within" method in the tests to access a row, because it doesn't seem to work in components tests when passing the `text:` option.
19 lines
369 B
Ruby
19 lines
369 B
Ruby
class Admin::Poll::Officers::OfficersComponent < ApplicationComponent
|
|
attr_reader :officers, :options
|
|
|
|
def initialize(officers, **options)
|
|
@officers = officers
|
|
@options = options
|
|
end
|
|
|
|
private
|
|
|
|
def add_user_path(officer)
|
|
{
|
|
controller: "admin/poll/officers",
|
|
action: :create,
|
|
user_id: officer.user_id
|
|
}
|
|
end
|
|
end
|