Sha256: 23b79fb1bdf2987b3a483e52dc3359218b3dd3b49c28e85786c4413eef35168e

Contents?: true

Size: 1.61 KB

Versions: 18

Compression:

Stored size: 1.61 KB

Contents

require 'rails_helper'

RSpec.describe ActiveAdmin::Views::IndexList do

  describe "#index_list_renderer" do

    let(:index_classes) { [ActiveAdmin::Views::IndexAsTable, ActiveAdmin::Views::IndexAsBlock] }

    let(:collection) {
      Post.create(title: 'First Post', starred: true)
      Post.where(nil)
    }

    let(:helpers) do
      helpers = mock_action_view
      allow(helpers).to receive(:url_for) { |url| "/?#{ url.to_query }" }
      allow(helpers.request).to receive(:query_parameters).and_return as: "table", q: { title_contains: "terms" }
      allow(helpers).to receive(:params).and_return(ActionController::Parameters.new(as: "table", q: { title_contains: "terms" }))
      allow(helpers).to receive(:collection).and_return(collection)
      helpers
    end

    subject do
      render_arbre_component({index_classes: index_classes}, helpers) do
        index_list_renderer(index_classes)
      end
    end

    describe '#tag_name' do
      subject { super().tag_name }
      it { is_expected.to eq 'ul'}
    end

    it "should contain the names of available indexes in links" do
      a_tags = subject.find_by_tag("a")
      expect(a_tags.size).to eq 2
      expect(a_tags.first.to_s).to include("Table")
      expect(a_tags.last.to_s).to include("List")
    end

    it "should maintain index filter parameters" do
      a_tags = subject.find_by_tag("a")
      expect(a_tags.first.attributes[:href])
        .to eq("/?#{ { as: "table", q: { title_contains: "terms" } }.to_query }")
      expect(a_tags.last.attributes[:href])
        .to eq("/?#{ { as: "block", q: { title_contains: "terms" } }.to_query }")
    end
  end
end

Version data entries

18 entries across 18 versions & 3 rubygems

Version Path
activeadmin-rb-1.6.0 spec/unit/views/components/index_list_spec.rb
activeadmin-rb-1.5.2 spec/unit/views/components/index_list_spec.rb
activeadmin-rb-1.5.1 spec/unit/views/components/index_list_spec.rb
activeadmin-rb-1.5.0 spec/unit/views/components/index_list_spec.rb
activeadmin_addons-1.7.1 vendor/bundle/ruby/2.3.0/bundler/gems/activeadmin-f71b375325eb/spec/unit/views/components/index_list_spec.rb
activeadmin-rb-1.4.0 spec/unit/views/components/index_list_spec.rb
activeadmin_addons-1.7.0 vendor/bundle/ruby/2.3.0/bundler/gems/activeadmin-f71b375325eb/spec/unit/views/components/index_list_spec.rb
activeadmin-1.3.1 spec/unit/views/components/index_list_spec.rb
activeadmin_addons-1.6.0 vendor/bundle/ruby/2.3.0/bundler/gems/activeadmin-f71b375325eb/spec/unit/views/components/index_list_spec.rb
activeadmin_addons-1.5.0 vendor/bundle/ruby/2.2.0/bundler/gems/activeadmin-f71b375325eb/spec/unit/views/components/index_list_spec.rb
activeadmin-1.3.0 spec/unit/views/components/index_list_spec.rb
activeadmin_addons-1.4.0 vendor/bundle/ruby/2.2.0/bundler/gems/activeadmin-f71b375325eb/spec/unit/views/components/index_list_spec.rb
activeadmin_addons-1.3.0 vendor/bundle/ruby/2.3.0/bundler/gems/activeadmin-f71b375325eb/spec/unit/views/components/index_list_spec.rb
activeadmin_addons-1.2.0 vendor/bundle/ruby/2.3.0/bundler/gems/activeadmin-f71b375325eb/spec/unit/views/components/index_list_spec.rb
activeadmin-1.2.1 spec/unit/views/components/index_list_spec.rb
activeadmin-1.2.0 spec/unit/views/components/index_list_spec.rb
activeadmin-1.1.0 spec/unit/views/components/index_list_spec.rb
activeadmin-1.0.0 spec/unit/views/components/index_list_spec.rb