Sha256: e8b9e46074879ff78852257e83f4af49f92e85775cdd61c3ad332c19eada7c1d

Contents?: true

Size: 1.66 KB

Versions: 23

Compression:

Stored size: 1.66 KB

Contents

require 'test_helper'

module Config
  class NestedTest < MiniTest::Test
    class ModelStubsController < ActionController::Base
      include ActiveScaffold::Core
      active_scaffold
    end

    def setup
      @config = ActiveScaffold::Config::Core.new(:model_stub)
    end

    def test_default_options
      assert @config.nested.shallow_delete
      assert_equal 'Add Existing Model stub', @config.nested.label
    end

    def test_label
      label = 'nested monkeys'
      @config.nested.label = label
      assert_equal label, @config.nested.label
      I18n.backend.store_translations :en, :active_scaffold => {:test_create_model => 'Add new %<model>s'}
      @config.nested.label = :test_create_model
      assert_equal 'Add new Model stub', @config.nested.label
    end

    def test_shallow_delete
      @config.nested.shallow_delete = true
      assert @config.nested.shallow_delete
    end

    def test_add_link
      assert_raises(ArgumentError) { @config.nested.add_link :assoc_1 }
      config = @config
      ModelStubsController.class_eval do
        config.configure { nested.add_link :other_models }
      end
      link = @config.action_links['index']
      assert_equal 'ModelStubs', link.label
      assert_equal 'index', link.action
      assert_equal :after, link.position
      refute link.page?
      refute link.popup?
      refute link.confirm?
      assert link.inline?
      assert link.refresh_on_close
      assert_equal :other_models, link.parameters[:association]
      assert_equal :get, link.method
      assert_equal :member, link.type
      assert_equal :read, link.crud_type
      assert_equal :nested_authorized?, link.security_method
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

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