Sha256: 9c5d53c618b90ad9f2bc362325a12653c6c1ba847ec9604b0aee353136e4acfc

Contents?: true

Size: 1014 Bytes

Versions: 6

Compression:

Stored size: 1014 Bytes

Contents

require 'spec_helper'

module Ransack
  module Helpers
    describe FormHelper do

      router = ActionDispatch::Routing::RouteSet.new
      router.draw do
        resources :people
        match ':controller(/:action(/:id(.:format)))'
      end

      include router.url_helpers

      # FIXME: figure out a cleaner way to get this behavior
      before do
        @controller = ActionView::TestCase::TestController.new
        @controller.instance_variable_set(:@_routes, router)
        @controller.class_eval do
          include router.url_helpers
        end

        @controller.view_context_class.class_eval do
          include router.url_helpers
        end
      end

      describe '#sort_link' do
        subject { @controller.view_context.sort_link(Person.search(:sorts => ['name desc']), :name, :controller => 'people') }

        it { should match /people\?q%5Bs%5D=name\+asc/}
        it { should match /sort_link desc/}
        it { should match /Full Name ▼/}
      end

    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
ransack_ffcrm-0.6.0 spec/ransack/helpers/form_helper_spec.rb
ransack-0.6.0 spec/ransack/helpers/form_helper_spec.rb
ransack-0.5.8 spec/ransack/helpers/form_helper_spec.rb
ransack-0.5.7 spec/ransack/helpers/form_helper_spec.rb
ransack-0.5.6 spec/ransack/helpers/form_helper_spec.rb
ransack-0.5.5 spec/ransack/helpers/form_helper_spec.rb