Sha256: 8a3767866abd0fae0da238410e73da84c9f68d80e0faf894e4ee5e93c3068d9f

Contents?: true

Size: 1.64 KB

Versions: 58

Compression:

Stored size: 1.64 KB

Contents

require 'active_admin/view_helpers/fields_for'

describe ActiveAdmin::ViewHelpers::FormHelper, ".fields_for" do
  include ActiveAdmin::ViewHelpers::FormHelper

  it "should skip :action, :controller and :commit" do
    fields_for_params(
      :scope => "All", :action => "index", :controller => "PostController", :commit => "Filter", :utf8 => "Yes!").
      should == [ { :scope => "All" } ]
  end

  it "should skip the except" do
    fields_for_params({:scope => "All", :name => "Greg"}, :except => :name).
      should == [ { :scope => "All" } ]
  end

  it "should allow an array for the except" do
    fields_for_params({:scope => "All", :name => "Greg", :age => "12"}, :except => [:name, :age]).
      should == [ { :scope => "All" } ]
  end

  it "should work with hashes" do
    params = fields_for_params(:filters => { :name => "John", :age => "12" })

    params.size.should == 2
    params.should include({"filters[name]" => "John" })
    params.should include({ "filters[age]" => "12" })
  end

  it "should work with nested hashes" do
    fields_for_params(:filters => { :user => { :name => "John" }}).
      should == [ { "filters[user][name]" => "John" } ]
  end

  it "should work with arrays" do
    fields_for_params(:people => ["greg", "emily", "philippe"]).
      should == [ { "people[]" => "greg" },
                  { "people[]" => "emily" },
                  { "people[]" => "philippe" } ]
  end

  it "should work with symbols" do
    fields_for_params(:filter => :id).
      should == [ { :filter => "id" } ]
  end

  it "should work with booleans" do
    fields_for_params(:booleantest => false).should == [ { :booleantest => false } ]
  end
end

Version data entries

58 entries across 58 versions & 4 rubygems

Version Path
activeadmin-0.6.6 spec/unit/view_helpers/fields_for_spec.rb
activeadmin-0.6.5 spec/unit/view_helpers/fields_for_spec.rb
activeadmin-0.6.4 spec/unit/view_helpers/fields_for_spec.rb
yousty-activeadmin-1.0.4.pre spec/unit/view_helpers/fields_for_spec.rb
yousty-activeadmin-1.0.3.pre spec/unit/view_helpers/fields_for_spec.rb
yousty-activeadmin-1.0.2.pre spec/unit/view_helpers/fields_for_spec.rb
activeadmin-0.6.3 spec/unit/view_helpers/fields_for_spec.rb
yousty-activeadmin-1.0.1.pre spec/unit/view_helpers/fields_for_spec.rb
yousty-activeadmin-1.0.0.pre spec/unit/view_helpers/fields_for_spec.rb
activeadmin-0.6.2 spec/unit/view_helpers/fields_for_spec.rb
activeadmin-0.6.1 spec/unit/view_helpers/fields_for_spec.rb
aa-rails4-0.6.0 spec/unit/view_helpers/fields_for_spec.rb
lalala-4.0.0.dev.141 vendor/deps/active_admin/spec/unit/view_helpers/fields_for_spec.rb
lalala-4.0.0.dev.136 vendor/deps/active_admin/spec/unit/view_helpers/fields_for_spec.rb
lalala-4.0.0.dev.135 vendor/deps/active_admin/spec/unit/view_helpers/fields_for_spec.rb
lalala-4.0.0.dev.134 vendor/deps/active_admin/spec/unit/view_helpers/fields_for_spec.rb
lalala-4.0.0.dev.133 vendor/deps/active_admin/spec/unit/view_helpers/fields_for_spec.rb
lalala-4.0.0.dev.132 vendor/deps/active_admin/spec/unit/view_helpers/fields_for_spec.rb
lalala-4.0.0.dev.131 vendor/deps/active_admin/spec/unit/view_helpers/fields_for_spec.rb
lalala-4.0.0.dev.129 vendor/deps/active_admin/spec/unit/view_helpers/fields_for_spec.rb