Sha256: 6d3c471809a163bd414b493dd465bcfd65d371e1fee06ec17f4cfc4edf7f804f

Contents?: true

Size: 1.08 KB

Versions: 18

Compression:

Stored size: 1.08 KB

Contents

require 'test_helper'

module Rails3JQueryAutocomplete
  class Rails3JQueryAutocompleteTest < ActionController::TestCase
    ActorsController = Class.new(ActionController::Base)
    ActorsController.autocomplete(:movie, :name)

    class ::Movie ; end

    context '#autocomplete_object_method' do
      setup do
        @controller = ActorsController.new
        @items = {}
        @options = { :display_value => :name }
      end

      should 'respond to the action' do
        assert_respond_to @controller, :autocomplete_movie_name
      end

      should 'render the JSON items' do
        mock(@controller).get_autocomplete_items({
          :model => Movie, :method => :name, :options => @options, :term => "query"
        }) { @items }

        mock(@controller).json_for_autocomplete(@items, :name, nil)
        get :autocomplete_movie_name, :term => 'query'
      end

      context 'no term is specified' do
        should "render an empty hash" do
          mock(@controller).json_for_autocomplete({}, :name, nil)
          get :autocomplete_movie_name
        end
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
rails3-jquery-autocomplete-1.0.15 test/lib/rails3-jquery-autocomplete_test.rb
rails3-jquery-autocomplete-1.0.14 test/lib/rails3-jquery-autocomplete_test.rb
rails3-jquery-autocomplete-1.0.13 test/lib/rails3-jquery-autocomplete_test.rb
rails3-jquery-autocomplete-1.0.12 test/lib/rails3-jquery-autocomplete_test.rb
rails3-jquery-autocomplete-1.0.11 test/lib/rails3-jquery-autocomplete_test.rb
rails3-jquery-autocomplete-1.0.10 test/lib/rails3-jquery-autocomplete_test.rb
rails3-jquery-autocomplete-1.0.9 test/lib/rails3-jquery-autocomplete_test.rb
rails3-jquery-autocomplete-1.0.8 test/lib/rails3-jquery-autocomplete_test.rb
rails3-jquery-autocomplete-1.0.7 test/lib/rails3-jquery-autocomplete_test.rb
rails3-jquery-autocomplete-1.0.6 test/lib/rails3-jquery-autocomplete_test.rb
rails3-jquery-autocomplete-1.0.5 test/lib/rails3-jquery-autocomplete_test.rb
rails3-jquery-autocomplete-1.0.4 test/lib/rails3-jquery-autocomplete_test.rb
rails3-jquery-autocomplete-1.0.3 test/lib/rails3-jquery-autocomplete_test.rb
rails3-jquery-autocomplete-1.0.2 test/lib/rails3-jquery-autocomplete_test.rb
rails3-jquery-autocomplete-1.0.1 test/lib/rails3-jquery-autocomplete_test.rb
rails3-jquery-autocomplete-1.0.0 test/lib/rails3-jquery-autocomplete_test.rb
rails3-jquery-autocomplete-0.9.1 test/lib/rails3-jquery-autocomplete_test.rb
rails3-jquery-autocomplete-0.9.0 test/lib/rails3-jquery-autocomplete_test.rb