Sha256: 634e930b093fd93a09c0f1cceb3943da3b543cb8b65d6a06361411991d7d6b8c

Contents?: true

Size: 1.23 KB

Versions: 1

Compression:

Stored size: 1.23 KB

Contents

require 'spec_helper'

describe Refinery::PageImages::Engine do
  before(:all) do
    class Refinery::PageImages::EnableForMock
      class Model; end
      class Tab; end
    end
  end

  after(:all) do
    Refinery::PageImages.instance_eval { remove_const(:EnableForMock) }
  end

  before(:each) do
    allow(Refinery::PageImages.config).to receive(:enable_for).and_return(enable_for_config)
  end

  def enable_for_config
    [{ :model => 'Refinery::PageImages::EnableForMock::Model',
       :tab => 'Refinery::PageImages::EnableForMock::Tab' }]
  end

  describe "attach initializer" do
    it "calls attach on all configured model" do
      allow(Refinery::PageImages.config).to receive(:enable_for).and_return(enable_for_config)

      expect(Refinery::PageImages::EnableForMock::Model).to receive(:has_many_page_images).once
      expect(Refinery::Page).not_to receive(:has_many_page_images)
      ActionDispatch::Reloader.prepare!
    end
  end

  describe "attach_initialize_tabs!" do
    it "registers tabs for all configured engine" do
      expect(Refinery::PageImages::EnableForMock::Tab).to receive(:register).once
      expect(Refinery::Pages::Tab).not_to receive(:register)
      Refinery::PageImages::Engine.initialize_tabs!
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
refinerycms-page-images-3.0.0 spec/lib/refinery/initializer_spec.rb