Sha256: 7c2170ce080a753395b648df191370e505b608b9d537b1e6fca133f904034c0d

Contents?: true

Size: 1.71 KB

Versions: 25

Compression:

Stored size: 1.71 KB

Contents

require 'rails_helper'

describe ActiveAdmin::ViewHelpers::FormHelper do

  describe '.active_admin_form_for' do
    let(:view) { action_view }
    let(:resource) { double 'resource' }
    let(:default_options) { { builder: ActiveAdmin::FormBuilder } }

    it 'calls semantic_form_for with the ActiveAdmin form builder' do
      expect(view).to receive(:semantic_form_for).with(resource, builder: ActiveAdmin::FormBuilder)
      view.active_admin_form_for(resource)
    end

    it 'allows the form builder to be customized' do
      # We can't use a stub here because options gets marshalled, and a new
      # instance built. Any constant will work.
      custom_builder = Object
      expect(view).to receive(:semantic_form_for).with(resource, builder: custom_builder)
      view.active_admin_form_for(resource, builder: custom_builder)
    end
  end

  describe ".hidden_field_tags_for" do
    let(:view) { action_view }

    it "should render hidden field tags for params" do
      html = Capybara.string view.hidden_field_tags_for(scope: "All", filter: "None")
      expect(html).to have_selector("input#hidden_active_admin_scope[name=scope][type=hidden][value=All]")
      expect(html).to have_selector("input#hidden_active_admin_filter[name=filter][type=hidden][value=None]")
    end

    it "should generate not default id for hidden input" do
      expect(view.hidden_field_tags_for(scope: "All")[/id="([^"]+)"/, 1]).to_not eq "scope"
    end

    it "should filter out the field passed via the option :except" do
      html = Capybara.string view.hidden_field_tags_for({scope: "All", filter: "None"}, except: :filter)
      expect(html).to have_selector("input#hidden_active_admin_scope[name=scope][type=hidden][value=All]")
    end
  end
end

Version data entries

25 entries across 25 versions & 4 rubygems

Version Path
activeadmin_addons-1.1.2 vendor/bundle/ruby/2.3.0/bundler/gems/activeadmin-a5a53c3f2b8f/spec/unit/view_helpers/form_helper_spec.rb
activeadmin_addons-1.1.1 vendor/bundle/ruby/2.2.0/bundler/gems/activeadmin-a5a53c3f2b8f/spec/unit/view_helpers/form_helper_spec.rb
yousty-activeadmin-1.0.17.pre spec/unit/view_helpers/form_helper_spec.rb
yousty-activeadmin-1.0.16.pre spec/unit/view_helpers/form_helper_spec.rb
activeadmin_addons-1.1.0 vendor/bundle/ruby/2.2.0/bundler/gems/activeadmin-a5a53c3f2b8f/spec/unit/view_helpers/form_helper_spec.rb
activeadmin_addons-1.0.1 vendor/bundle/ruby/2.2.0/bundler/gems/activeadmin-a5a53c3f2b8f/spec/unit/view_helpers/form_helper_spec.rb
activeadmin_addons-1.0.0 vendor/bundle/ruby/2.2.0/bundler/gems/activeadmin-a5a53c3f2b8f/spec/unit/view_helpers/form_helper_spec.rb
yousty-activeadmin-1.0.15.pre spec/unit/view_helpers/form_helper_spec.rb
activeadmin-orac-1.0.0.pre4 spec/unit/view_helpers/form_helper_spec.rb
activeadmin-orac-1.0.0 spec/unit/view_helpers/form_helper_spec.rb
activeadmin-orac-1.0.0.pre.orac spec/unit/view_helpers/form_helper_spec.rb
yousty-activeadmin-1.0.14.pre spec/unit/view_helpers/form_helper_spec.rb
yousty-activeadmin-1.0.13.pre spec/unit/view_helpers/form_helper_spec.rb
yousty-activeadmin-1.0.12.pre spec/unit/view_helpers/form_helper_spec.rb
yousty-activeadmin-1.0.11.pre spec/unit/view_helpers/form_helper_spec.rb
yousty-activeadmin-1.0.10.pre spec/unit/view_helpers/form_helper_spec.rb
yousty-activeadmin-1.0.9.pre spec/unit/view_helpers/form_helper_spec.rb
yousty-activeadmin-1.0.8.pre spec/unit/view_helpers/form_helper_spec.rb
activeadmin-1.0.0.pre4 spec/unit/view_helpers/form_helper_spec.rb
activeadmin-1.0.0.pre3 spec/unit/view_helpers/form_helper_spec.rb