Sha256: 54f1823d0ebe82e3232d5a00cbd077d241cb7d259b86d70ef8f27f403d454989

Contents?: true

Size: 1.13 KB

Versions: 43

Compression:

Stored size: 1.13 KB

Contents

# -*- encoding : utf-8 -*-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe HashAsHiddenFieldsHelper do
  include HashAsHiddenFieldsHelper
  before(:each) do
    @hash = {:q => "query", :search_field => "search_field", :per_page=>10, :page=>5, :extra_arbitrary_key=>"arbitrary_value", :f=> {:field1 => ["a", "b"], :field2=> ["z"]}}
  end

  it "should convert a hash with nested complex data to Rails-style hidden form fields" do

    generated = hash_as_hidden_fields(@hash)

    generated.should have_selector("input[type='hidden'][name='q'][value='query']")
    generated.should have_selector("input[type='hidden'][name='per_page'][value='10']")
    generated.should have_selector("input[type='hidden'][name='page'][value='5']")
    generated.should have_selector("input[type='hidden'][name='extra_arbitrary_key'][value='arbitrary_value']")
    generated.should have_selector("input[type='hidden'][name='f[field2][]'][value='z']")
    generated.should have_selector("input[type='hidden'][name='f[field1][]'][value='a']")
    generated.should have_selector("input[type='hidden'][name='f[field1][]'][value='b']")
    
  end

end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
blacklight-3.2.0pre1 test_support/spec/helpers/hash_as_hidden_fields_spec.rb
blacklight-3.1.2 test_support/spec/helpers/hash_as_hidden_fields_spec.rb
blacklight-3.1.1 test_support/spec/helpers/hash_as_hidden_fields_spec.rb