Sha256: 748e74f6ec6fc1b7a147af168f598ec578a5cdd9d7db48cf9285cba1ba8d90f8

Contents?: true

Size: 1.32 KB

Versions: 50

Compression:

Stored size: 1.32 KB

Contents

# frozen_string_literal: true

RSpec.describe Blacklight::HashAsHiddenFieldsHelperBehavior do
  around { |test| Deprecation.silence(described_class) { test.call } }

  let(:params) do
    { q: "query",
      search_field: "search_field",
      per_page: 10,
      page: 5,
      extra_arbitrary_key: "arbitrary_value",
      f: { field1: %w[a b], field2: ["z"] } }
  end
  let(:generated) { helper.render_hash_as_hidden_fields(params) }

  it "converts a hash with nested complex data to Rails-style hidden form fields" do
    allow(Deprecation).to receive(:warn)
    expect(generated).to have_selector("input[type='hidden'][name='q'][value='query']", visible: false)
    expect(generated).to have_selector("input[type='hidden'][name='per_page'][value='10']", visible: false)
    expect(generated).to have_selector("input[type='hidden'][name='page'][value='5']", visible: false)
    expect(generated).to have_selector("input[type='hidden'][name='extra_arbitrary_key'][value='arbitrary_value']", visible: false)
    expect(generated).to have_selector("input[type='hidden'][name='f[field2][]'][value='z']", visible: false)
    expect(generated).to have_selector("input[type='hidden'][name='f[field1][]'][value='a']", visible: false)
    expect(generated).to have_selector("input[type='hidden'][name='f[field1][]'][value='b']", visible: false)
  end
end

Version data entries

50 entries across 50 versions & 2 rubygems

Version Path
blacklight-7.26.0 spec/helpers/blacklight/hash_as_hidden_fields_behavior_spec.rb
blacklight-7.25.3 spec/helpers/blacklight/hash_as_hidden_fields_behavior_spec.rb
blacklight-7.25.2 spec/helpers/blacklight/hash_as_hidden_fields_behavior_spec.rb
blacklight-7.25.1 spec/helpers/blacklight/hash_as_hidden_fields_behavior_spec.rb
blacklight-7.25.0 spec/helpers/blacklight/hash_as_hidden_fields_behavior_spec.rb
blacklight-7.24.0 spec/helpers/blacklight/hash_as_hidden_fields_behavior_spec.rb
blacklight-7.23.0.1 spec/helpers/blacklight/hash_as_hidden_fields_behavior_spec.rb
blacklight-7.23.0 spec/helpers/blacklight/hash_as_hidden_fields_behavior_spec.rb
blacklight-7.22.2 spec/helpers/blacklight/hash_as_hidden_fields_behavior_spec.rb
blacklight-7.22.1 spec/helpers/blacklight/hash_as_hidden_fields_behavior_spec.rb
blacklight-7.22.0 spec/helpers/blacklight/hash_as_hidden_fields_behavior_spec.rb
blacklight-7.21.2 spec/helpers/blacklight/hash_as_hidden_fields_behavior_spec.rb
blacklight-7.21.1 spec/helpers/blacklight/hash_as_hidden_fields_behavior_spec.rb
blacklight-7.21.0 spec/helpers/blacklight/hash_as_hidden_fields_behavior_spec.rb
blacklight-7.20.1 spec/helpers/blacklight/hash_as_hidden_fields_behavior_spec.rb
blacklight-7.20.0 spec/helpers/blacklight/hash_as_hidden_fields_behavior_spec.rb
blacklight-7.19.2 spec/helpers/blacklight/hash_as_hidden_fields_behavior_spec.rb
blacklight-7.19.1 spec/helpers/blacklight/hash_as_hidden_fields_behavior_spec.rb
blacklight-7.19.0 spec/helpers/blacklight/hash_as_hidden_fields_behavior_spec.rb
blacklight-7.18.1 spec/helpers/blacklight/hash_as_hidden_fields_behavior_spec.rb