Sha256: 86c9dc1837f4d3c2581bf328743b99ed700ab5e095505527a9d55a11e5d1355b

Contents?: true

Size: 1.08 KB

Versions: 6

Compression:

Stored size: 1.08 KB

Contents

require 'test_helper'

module RailsJQueryAutocomplete
  class RailsJQueryAutocompleteTest < 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

6 entries across 6 versions & 2 rubygems

Version Path
rails-jquery-autocomplete-1.0.5 test/lib/rails-jquery-autocomplete_test.rb
rails-jquery-autocomplete-1.0.4 test/lib/rails-jquery-autocomplete_test.rb
rails-autocomplete-1.1.0 test/lib/rails-jquery-autocomplete_test.rb
rails-jquery-autocomplete-1.0.3 test/lib/rails-jquery-autocomplete_test.rb
rails-jquery-autocomplete-1.0.2 test/lib/rails-jquery-autocomplete_test.rb
rails-jquery-autocomplete-1.0.1 test/lib/rails-jquery-autocomplete_test.rb