Sha256: 16c111618da198537455738de6a335c533f011cea425203fc04bf052a1d150f6

Contents?: true

Size: 1.71 KB

Versions: 11

Compression:

Stored size: 1.71 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 'spec_helper'

describe "/accounts/create" do
  include AccountsHelper

  before do
    login_and_assign
  end

  # Note: [Create Account] is only called from Accounts index. Unlike other
  # core object Account partial is not embedded.
  describe "create success" do
    before do
      assign(:account, @account = FactoryGirl.build_stubbed(:account))
      assign(:accounts, [@account].paginate)
      assign(:account_category_total, Hash.new(1))
      render
    end

    it "should hide [Create Account] form and insert account partial" do
      expect(rendered).to include("$('#accounts').prepend('<li class=\\'account highlight\\' id=\\'account_#{@account.id}\\'")
      expect(rendered).to include(%/$('#account_#{@account.id}').effect("highlight"/)
    end

    it "should update pagination" do
      expect(rendered).to include("#paginate")
    end

    it "should refresh accounts sidebar" do
      expect(rendered).to include("#sidebar")
      expect(rendered).to have_text("Account Categories")
      expect(rendered).to have_text("Recent Items")
    end
  end

  describe "create failure" do
    it "should re-render [create] template in :create_account div" do
      assign(:account, FactoryGirl.build(:account, name: nil)) # make it invalid
      assign(:users, [current_user])
      render

      expect(rendered).to include("#create_account")
      expect(rendered).to include(%/$('#create_account').effect("shake"/)
    end
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
fat_free_crm-0.15.2 spec/views/accounts/create.js.haml_spec.rb
fat_free_crm-0.16.4 spec/views/accounts/create.js.haml_spec.rb
fat_free_crm-0.15.1 spec/views/accounts/create.js.haml_spec.rb
fat_free_crm-0.16.3 spec/views/accounts/create.js.haml_spec.rb
fat_free_crm-0.16.2 spec/views/accounts/create.js.haml_spec.rb
fat_free_crm-0.16.1 spec/views/accounts/create.js.haml_spec.rb
fat_free_crm-0.16.0 spec/views/accounts/create.js.haml_spec.rb
fat_free_crm-0.15.0 spec/views/accounts/create.js.haml_spec.rb
fat_free_crm-0.15.0.beta.2 spec/views/accounts/create.js.haml_spec.rb
fat_free_crm-0.15.0.beta spec/views/accounts/create.js.haml_spec.rb
reduced_fat_crm-0.15.0.beta spec/views/accounts/create.js.haml_spec.rb