Sha256: 2b70313e05ffba5ff6d0e143680766c0ea79d06f7cced5238cf85a789f5a1e31

Contents?: true

Size: 1.95 KB

Versions: 3

Compression:

Stored size: 1.95 KB

Contents

require 'spec_helper'

module Alchemy
  describe Tinymce do

    describe '.init' do
      subject { Tinymce.init }

      it "returns the default config" do
        should eq(Tinymce.class_variable_get('@@init'))
      end
    end

    describe '.init=' do
      let(:another_config) { {theme_advanced_buttons3: 'table'} }

      it "merges the default config with given config" do
        Tinymce.init = another_config
        Tinymce.init.should include(another_config)
      end
    end

    context 'Methods for contents with custom tinymce config.' do
      let(:content_definition) { {'name' => 'text', 'settings' => {'tinymce' => {'foo' => 'bar'}}} }
      let(:element_definition) { {'name' => 'article', 'contents' => [content_definition]} }

      describe '.custom_config_contents' do
        subject { Tinymce.custom_config_contents }

        before do
          Element.stub(:definitions).and_return([element_definition])
          # Preventing memoization
          Tinymce.class_variable_set('@@custom_config_contents', nil)
        end

        it "returns an array of content definitions that contain custom tinymce config and element name" do
          should be_an(Array)
          should include({'element' => element_definition['name']}.merge(content_definition))
        end

        context 'with no contents having custom tinymce config' do
          let(:content_definition) { {'name' => 'text'} }
          it { should eq([]) }
        end
      end

      describe '.page_custom_config_contents' do
        let(:page) { FactoryGirl.build_stubbed(:page) }
        subject { Tinymce.page_custom_config_contents(page) }

        before { page.stub(:element_definitions).and_return([element_definition]) }

        it "returns an array of content definitions that contain custom tinymce config for page" do
          should be_an(Array)
          should include({'element' => element_definition['name']}.merge(content_definition))
        end
      end
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
alchemy_cms-2.7.2 spec/libraries/tinymce_spec.rb
alchemy_cms-2.7.1 spec/libraries/tinymce_spec.rb
alchemy_cms-2.7.0 spec/libraries/tinymce_spec.rb