Test filter chips controller
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
module FiltersHelper
|
||||
def filter_chip_id(value, name)
|
||||
def filter_chip_id(name, value)
|
||||
"#{name}__filter--#{value}"
|
||||
end
|
||||
|
||||
def filter_chip_tag(text, name:, value:, **options)
|
||||
tag.button id: filter_chip_id(value, name), class: [ "btn txt-small btn--remove", options.delete(:class) ],
|
||||
tag.button id: filter_chip_id(name, value), class: [ "btn txt-small btn--remove", options.delete(:class) ],
|
||||
data: { action: "filter-form#removeFilter form#submit", filter_form_target: "button" } do
|
||||
concat hidden_field_tag(name, value, id: nil)
|
||||
concat tag.span(text)
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
require "test_helper"
|
||||
|
||||
class FilterChipsControllerTest < ActionDispatch::IntegrationTest
|
||||
setup do
|
||||
sign_in_as :kevin
|
||||
end
|
||||
|
||||
test "create" do
|
||||
post filter_chips_url(format: :turbo_stream), params: { text: "for David", name: "assignee_ids[]", value: users(:david).id, frame: "assignee_chips" }
|
||||
assert_response :success
|
||||
|
||||
assert_turbo_stream action: :remove, target: "assignee_ids[]__filter--#{users(:david).id}"
|
||||
assert_turbo_stream action: :append, target: "assignee_chips"
|
||||
assert_select "button", text: "for David"
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user