Sha256: 38f02d138cdfd0887ad247b967fbd5d37d367b47b1b65d2745da2ead30ff1f3f

Contents?: true

Size: 1.23 KB

Versions: 18

Compression:

Stored size: 1.23 KB

Contents

require 'spec_helper'
require_relative '../../lib/kuhsaft/touch_placeholders'

describe Kuhsaft::TouchPlaceholders do

  before :all do
    m = ActiveRecord::Migration.new
    m.verbose = false
    m.create_table :dummy_models do |t|
      t.timestamps
    end

    class DummyModel < ActiveRecord::Base
      include Kuhsaft::TouchPlaceholders
    end

    @page = FactoryGirl.create(:page)
    @placeholder = FactoryGirl.create(:placeholder_brick, brick_list: @page, template_name: 'foo')
  end

  after :all do
    m = ActiveRecord::Migration.new
    m.verbose = false
    m.drop_table :dummy_models

    @page.destroy
    @placeholder.destroy
  end

  describe 'placeholder_templates class method' do
    it 'returns the attribute names defined with class macro' do
      DummyModel.class_eval { placeholder_templates 'key_benefit_slider', 'key_benefit_grid' }
      expect(DummyModel.placeholder_templates).to eq %w(key_benefit_slider key_benefit_grid)
    end
  end

  describe 'after_save_callback' do
    it 'looks for the bricks with affected templates and touches them' do
      DummyModel.class_eval { placeholder_templates 'foo' }
      expect_any_instance_of(Kuhsaft::PlaceholderBrick).to receive(:touch)
      DummyModel.create
    end
  end
end

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
kuhsaft-2.6.3 spec/lib/touch_placeholders_spec.rb
kuhsaft-2.6.2 spec/lib/touch_placeholders_spec.rb
kuhsaft-2.6.1 spec/lib/touch_placeholders_spec.rb
kuhsaft-2.5.2 spec/lib/touch_placeholders_spec.rb
kuhsaft-2.6.0 spec/lib/touch_placeholders_spec.rb
kuhsaft-2.5.1 spec/lib/touch_placeholders_spec.rb
kuhsaft-2.5.0 spec/lib/touch_placeholders_spec.rb
qbrick-2.5.0.pre spec/lib/touch_placeholders_spec.rb
kuhsaft-2.4.3 spec/lib/touch_placeholders_spec.rb
kuhsaft-2.4.2 spec/lib/touch_placeholders_spec.rb
kuhsaft-2.4.1 spec/lib/touch_placeholders_spec.rb
kuhsaft-2.4.0 spec/lib/touch_placeholders_spec.rb
kuhsaft-2.3.6 spec/lib/touch_placeholders_spec.rb
kuhsaft-2.3.5 spec/lib/touch_placeholders_spec.rb
kuhsaft-2.3.4 spec/lib/touch_placeholders_spec.rb
kuhsaft-2.3.3 spec/lib/touch_placeholders_spec.rb
kuhsaft-2.3.2 spec/lib/touch_placeholders_spec.rb
kuhsaft-2.3.1 spec/lib/touch_placeholders_spec.rb