Sha256: f18008943a40bc1aefde59dc042e8d9b7ed5e6a6e2c0fb973c099ea4168d3f1e

Contents?: true

Size: 1.65 KB

Versions: 11

Compression:

Stored size: 1.65 KB

Contents

# Copyright (c) 2008-2013 Michael Dvorkin and contributors.
#
# Fat Free CRM is freely distributable under the terms of MIT license.
# See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
#------------------------------------------------------------------------------
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')

describe "/application/_auto_complete" do
  include AccountsHelper

  before do
    login_and_assign
  end

  [ :account, :campaign, :contact, :lead, :opportunity ].each do |model|
    it "should render autocomplete list if #{model} matches found" do
      @auto_complete = if model == :lead
        FactoryGirl.create(:lead, :first_name => "Billy", :last_name => "Bones", :company => "Hello, World!")
      elsif model == :contact
        FactoryGirl.create(:contact, :first_name => "Billy", :last_name => "Bones")
      else
        FactoryGirl.create(model, :name => "Hello, World!")
      end
      assign(:auto_complete, [ @auto_complete ])

      render
      rendered.should have_tag("ul", :count => 1) do |list|
        unless model == :lead
          list.should have_tag("li", :id => @auto_complete.id.to_s, :text => @auto_complete.name)
        else
          list.should have_tag("li", :id => @auto_complete.id.to_s, :text => "#{@auto_complete.name} (#{@auto_complete.company})")
        end
      end
    end

    it "should render a message if #{model} doesn't match the query" do
      assign(:query, "Hello")
      assign(:auto_complete, [])

      render
      rendered.should have_tag("ul", :count => 1) do |list|
        with_tag("li", :id => nil, :count => 1, :text => /^No/)
      end
    end

  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
fat_free_crm-0.13.6 spec/views/application/auto_complete.haml_spec.rb
fat_free_crm-0.13.5 spec/views/application/auto_complete.haml_spec.rb
fat_free_crm-0.13.4 spec/views/application/auto_complete.haml_spec.rb
fat_free_crm-0.13.3 spec/views/application/auto_complete.haml_spec.rb
fat_free_crm-0.13.2 spec/views/application/auto_complete.haml_spec.rb
fat_free_crm-0.12.3 spec/views/application/auto_complete.haml_spec.rb
fat_free_crm-0.12.2 spec/views/application/auto_complete.haml_spec.rb
fat_free_crm-0.13.1 spec/views/application/auto_complete.haml_spec.rb
fat_free_crm-0.12.1 spec/views/application/auto_complete.haml_spec.rb
fat_free_crm-0.13.0 spec/views/application/auto_complete.haml_spec.rb
fat_free_crm-0.12.0 spec/views/application/auto_complete.haml_spec.rb