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.40.0 spec/helpers/blacklight/hash_as_hidden_fields_behavior_spec.rb
blacklight-7.39.0 spec/helpers/blacklight/hash_as_hidden_fields_behavior_spec.rb
blacklight-7.38.0 spec/helpers/blacklight/hash_as_hidden_fields_behavior_spec.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/blacklight-7.37.0/spec/helpers/blacklight/hash_as_hidden_fields_behavior_spec.rb
blacklight-7.37.0 spec/helpers/blacklight/hash_as_hidden_fields_behavior_spec.rb
blacklight-7.36.2 spec/helpers/blacklight/hash_as_hidden_fields_behavior_spec.rb
blacklight-7.36.1 spec/helpers/blacklight/hash_as_hidden_fields_behavior_spec.rb
blacklight-7.36.0 spec/helpers/blacklight/hash_as_hidden_fields_behavior_spec.rb
blacklight-7.35.0 spec/helpers/blacklight/hash_as_hidden_fields_behavior_spec.rb
blacklight-7.34.0 spec/helpers/blacklight/hash_as_hidden_fields_behavior_spec.rb
blacklight-7.33.1 spec/helpers/blacklight/hash_as_hidden_fields_behavior_spec.rb
blacklight-7.33.0 spec/helpers/blacklight/hash_as_hidden_fields_behavior_spec.rb
blacklight-7.32.0 spec/helpers/blacklight/hash_as_hidden_fields_behavior_spec.rb
blacklight-7.31.0 spec/helpers/blacklight/hash_as_hidden_fields_behavior_spec.rb
blacklight-7.30.0 spec/helpers/blacklight/hash_as_hidden_fields_behavior_spec.rb
blacklight-7.29.0 spec/helpers/blacklight/hash_as_hidden_fields_behavior_spec.rb
blacklight-7.28.0 spec/helpers/blacklight/hash_as_hidden_fields_behavior_spec.rb
blacklight-7.27.1 spec/helpers/blacklight/hash_as_hidden_fields_behavior_spec.rb
blacklight-7.27.0 spec/helpers/blacklight/hash_as_hidden_fields_behavior_spec.rb
blacklight-7.26.1 spec/helpers/blacklight/hash_as_hidden_fields_behavior_spec.rb