Sha256: e141c59b4847051b62dfb53904faa5d32ad086093ca35950325a633f53156bee

Contents?: true

Size: 875 Bytes

Versions: 4

Compression:

Stored size: 875 Bytes

Contents

require 'spec_helper'

describe ActiveAdmin::ResourceController::Collection do
  let(:params) do
    {}
  end

  let(:controller) do
    rc = Admin::PostsController.new
    rc.stub!(:params) do
      params
    end
    rc
  end

  describe ActiveAdmin::ResourceController::Collection::Search do
    let(:params){ {:q => {} }}
    it "should call the metasearch method" do
      chain = mock("ChainObj")
      chain.should_receive(:metasearch).with(params[:q]).once.and_return(Post.search)
      controller.send :search, chain
    end
  end

  describe ActiveAdmin::ResourceController::Collection::Sorting do
    let(:params){ {:order => "id_asc" }}
    it "should prepend the table name" do
      chain = mock("ChainObj")
      chain.should_receive(:order).with("\"posts\".\"id\" asc").once.and_return(Post.search)
      controller.send :sort_order, chain
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
activeadmin-0.4.4 spec/unit/resource_controller/collection_spec.rb
activeadmin-0.4.3 spec/unit/resource_controller/collection_spec.rb
activeadmin-0.4.2 spec/unit/resource_controller/collection_spec.rb
activeadmin-0.4.1 spec/unit/resource_controller/collection_spec.rb