Sha256: 9544e49abad5a903b0cafa87e78bc01c34f97bb0a174027c0954a1b96d246a5e

Contents?: true

Size: 1.6 KB

Versions: 4

Compression:

Stored size: 1.6 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 "/campaigns/create" do
  before do
    login_and_assign
  end

  describe "create success" do
    before do
      assign(:campaign, @campaign = FactoryGirl.create(:campaign))
      assign(:campaigns, [@campaign].paginate)
      assign(:campaign_status_total, Hash.new(1))
      render
    end

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

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

    it "should update Campaigns sidebar filters" do
      expect(rendered).to include("#sidebar")
      expect(rendered).to have_text("Campaign Statuses")
      expect(rendered).to have_text("Recent Items")
    end
  end

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

      render

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

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
fat_free_crm-0.14.2 spec/views/campaigns/create.js.haml_spec.rb
fat_free_crm-0.14.1 spec/views/campaigns/create.js.haml_spec.rb
fat_free_crm-0.14.0 spec/views/campaigns/create.js.haml_spec.rb
reduced_fat_crm-0.14.0 spec/views/campaigns/create.js.haml_spec.rb