Sha256: c52a36c2ea183847460f1180e168b14193cf0a355330e313d605d5847204a6a2

Contents?: true

Size: 1.99 KB

Versions: 10

Compression:

Stored size: 1.99 KB

Contents

require 'test_helper'

class TinyMceTest < ActionView::TestCase
  include ActiveScaffold::Helpers::ViewHelpers
  include ActiveScaffold::Bridges::TinyMce::Helpers

  # Mimic the behaviour of the tinymce-rails plugin function[1] to get
  # configuration options from tinymce.yml
  #
  # [1]: https://github.com/spohlenz/tinymce-rails/blob/master/lib/tinymce/rails/helper.rb#L37
  def tinymce_configuration(config = :default)
    case config
    when :default
      Class.new do
        def options
          {theme: 'modern'}
        end
      end.new
    when :alternate
      Class.new do
        def options
          {theme: 'alternate', toolbar: 'undo redo | format'}
        end
      end.new
    end
  end

  def test_includes
    ActiveScaffold::Bridges::TinyMce.expects(:install?).returns(true)
    with_js_framework :jquery do
      assert ActiveScaffold::Bridges.all_javascripts.include?('tinymce')
    end
  end

  def test_form_ui
    config = ActiveScaffold::Config::Core.new(:company)
    record = Company.new
    opts = {name: 'record[name]', id: 'record_name', class: 'name-input', object: record}

    assert_dom_equal %(<textarea name=\"record[name]\" class=\"name-input mceEditor\" id=\"record_name\" data-tinymce=\"{&quot;theme&quot;:&quot;modern&quot;}\">\n</textarea>), active_scaffold_input_text_editor(config.columns[:name], opts)
  end

  def test_form_ui_alternate
    config = ActiveScaffold::Config::Core.new(:company)
    record = Company.new
    config.columns[:name].options[:tinymce_config] = :alternate
    opts = {name: 'record[name]', id: 'record_name', class: 'name-input', object: record}

    assert_dom_equal %(<textarea name=\"record[name]\" class=\"name-input mceEditor\" id=\"record_name\" data-tinymce=\"{&quot;theme&quot;:&quot;alternate&quot;,&quot;toolbar&quot;:&quot;undo redo | format&quot;}\">\n</textarea>), active_scaffold_input_tinymce(config.columns[:name], opts)
  end

  protected

  def include_tiny_mce_if_needed; end

  def tiny_mce_js; end

  def using_tiny_mce?
    true
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
active_scaffold-3.7.12 test/bridges/tiny_mce_test.rb
active_scaffold-3.7.11.1 test/bridges/tiny_mce_test.rb
active_scaffold-3.7.11 test/bridges/tiny_mce_test.rb
active_scaffold-3.7.10 test/bridges/tiny_mce_test.rb
active_scaffold-3.7.8 test/bridges/tiny_mce_test.rb
active_scaffold-3.7.7 test/bridges/tiny_mce_test.rb
active_scaffold-3.7.6 test/bridges/tiny_mce_test.rb
active_scaffold-3.7.5 test/bridges/tiny_mce_test.rb
active_scaffold-3.7.2 test/bridges/tiny_mce_test.rb
active_scaffold-3.7.1 test/bridges/tiny_mce_test.rb