Sha256: 113a1cf3b806b7ac0b0cf8e7f246c4aaca2389b4f7ab0802871751e86e26eefc

Contents?: true

Size: 1.23 KB

Versions: 16

Compression:

Stored size: 1.23 KB

Contents

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

describe Qbrick::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 Qbrick::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(Qbrick::PlaceholderBrick).to receive(:touch)
      DummyModel.create
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
qbrick-2.7.1 spec/lib/touch_placeholders_spec.rb
qbrick-2.7 spec/lib/touch_placeholders_spec.rb
qbrick-2.6.10 spec/lib/touch_placeholders_spec.rb
qbrick-2.6.9 spec/lib/touch_placeholders_spec.rb
qbrick-2.6.8 spec/lib/touch_placeholders_spec.rb
qbrick-2.6.7 spec/lib/touch_placeholders_spec.rb
qbrick-2.6.6 spec/lib/touch_placeholders_spec.rb
qbrick-2.6.5 spec/lib/touch_placeholders_spec.rb
qbrick-2.6.4 spec/lib/touch_placeholders_spec.rb
qbrick-2.6.3 spec/lib/touch_placeholders_spec.rb
qbrick-2.6.2 spec/lib/touch_placeholders_spec.rb
qbrick-2.6.1 spec/lib/touch_placeholders_spec.rb
qbrick-2.6.0 spec/lib/touch_placeholders_spec.rb
qbrick-2.5.2 spec/lib/touch_placeholders_spec.rb
qbrick-2.5.1 spec/lib/touch_placeholders_spec.rb
qbrick-2.5.0 spec/lib/touch_placeholders_spec.rb