Sha256: d15c9b4503e01eaf0608573d0c9bd7bf52497ed50427d03e534b53c35c0d7b2b

Contents?: true

Size: 1.99 KB

Versions: 29

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-jquery')
    end
  end

  def test_form_ui
    config = ActiveScaffold::Config::Core.new(:company)
    record = Company.new

    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], :name => 'record[name]', :id => 'record_name', :class => 'name-input', :object => record)
  end

  def test_form_ui_alternate
    config = ActiveScaffold::Config::Core.new(:company)
    record = Company.new
    config.columns[:name].options[:tinymce_config] = :alternate

    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], :name => 'record[name]', :id => 'record_name', :class => 'name-input', :object => record)
  end

  protected

  def include_tiny_mce_if_needed; end

  def tiny_mce_js; end

  def using_tiny_mce?
    true
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
active_scaffold-3.6.20 test/bridges/tiny_mce_test.rb
active_scaffold-3.6.19 test/bridges/tiny_mce_test.rb
active_scaffold-3.6.17 test/bridges/tiny_mce_test.rb
active_scaffold-3.6.15 test/bridges/tiny_mce_test.rb
active_scaffold-3.6.14 test/bridges/tiny_mce_test.rb
active_scaffold-3.6.13 test/bridges/tiny_mce_test.rb
active_scaffold-3.6.12 test/bridges/tiny_mce_test.rb
active_scaffold-3.6.11.1 test/bridges/tiny_mce_test.rb
active_scaffold-3.6.11 test/bridges/tiny_mce_test.rb
active_scaffold-3.6.10 test/bridges/tiny_mce_test.rb
active_scaffold-3.6.9 test/bridges/tiny_mce_test.rb
active_scaffold-3.6.8 test/bridges/tiny_mce_test.rb
active_scaffold-3.6.6 test/bridges/tiny_mce_test.rb
active_scaffold-3.6.5 test/bridges/tiny_mce_test.rb
active_scaffold-3.6.4.1 test/bridges/tiny_mce_test.rb
active_scaffold-3.6.4 test/bridges/tiny_mce_test.rb
active_scaffold-3.6.3 test/bridges/tiny_mce_test.rb
active_scaffold-3.6.2 test/bridges/tiny_mce_test.rb
active_scaffold-3.6.1 test/bridges/tiny_mce_test.rb
active_scaffold-3.6.0 test/bridges/tiny_mce_test.rb