Flatten tags list, cast to array and remove blank elements
This commit is contained in:
parent
b60805a54c
commit
ea5248dde1
3 changed files with 16 additions and 1 deletions
|
@ -26,6 +26,7 @@ class SupportController < ApplicationController
|
|||
|
||||
def setup_context
|
||||
@dossier_id = dossier&.id
|
||||
@tags = tags
|
||||
@options = Helpscout::FormAdapter::OPTIONS
|
||||
end
|
||||
|
||||
|
@ -51,6 +52,9 @@ class SupportController < ApplicationController
|
|||
|
||||
def tags
|
||||
[params[:tags], params[:type]].flatten.compact
|
||||
.map { |tag| tag.split(',') }
|
||||
.flatten
|
||||
.reject(&:blank?).uniq
|
||||
end
|
||||
|
||||
def browser_name
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
= label_tag :text, 'Pièce jointe'
|
||||
= file_field_tag :file
|
||||
|
||||
= hidden_field_tag :tags, params[:tags]
|
||||
= hidden_field_tag :tags, @tags&.join(',')
|
||||
|
||||
.send-wrapper
|
||||
= button_tag 'Envoyer le message', type: :submit, class: 'button send primary'
|
||||
|
|
|
@ -38,6 +38,17 @@ describe SupportController, type: :controller do
|
|||
expect(response.body).to include(tag)
|
||||
end
|
||||
end
|
||||
|
||||
describe "with multiple tags" do
|
||||
let(:tags) { ['yolo', 'toto'] }
|
||||
|
||||
it 'should fill tags' do
|
||||
get :index, params: { tags: tags }
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(response.body).to include(tags.join(','))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'signed out' do
|
||||
|
|
Loading…
Reference in a new issue