Sha256: 790e3c4e31239b2efb1091dc56c341dc3878464bd2f2a8a7652d8c24a04d8fd8

Contents?: true

Size: 1.7 KB

Versions: 56

Compression:

Stored size: 1.7 KB

Contents

require File.join(File.dirname(__FILE__), '../test_helper.rb')

class Config::CreateTest < Test::Unit::TestCase
  def setup
    @config = ActiveScaffold::Config::Core.new :model_stub
    @default_link = @config.create.link
  end
  
  def teardown
    @config.create.link = @default_link
  end
  
  def test_default_options
    assert !@config.create.persistent
    assert @config.create.action_after_create.nil?
    assert_equal 'Create ModelStub', @config.create.label
  end

  def test_link_defaults
    link = @config.create.link
    assert !link.page?
    assert !link.popup?
    assert !link.confirm?
    assert_equal "new", link.action
    assert_equal "Create New", link.label
    assert link.inline?
    blank = {}
    assert_equal blank, link.html_options
    assert_equal :get, link.method
    assert_equal :collection, link.type
    assert_equal :create, link.crud_type
    assert_equal :create_authorized?, link.security_method
  end
  
  def test_setting_link
    @config.create.link = ActiveScaffold::DataStructures::ActionLink.new('update', :label => 'Monkeys')
    assert_not_equal(@default_link, @config.create.link)
  end
  
  def test_label
    label = 'create new monkeys'
    @config.create.label = label
    assert_equal label, @config.create.label
    I18n.backend.store_translations :en, :active_scaffold => {:create_new_model => 'Create new %{model}'}
    @config.create.label = :create_new_model
    assert_equal 'Create new ModelStub', @config.create.label
  end
  
  def test_persistent
    @config.create.persistent = true
    assert @config.create.persistent
  end
 
  def test_action_after_create
    @config.create.action_after_create = :edit
    assert_equal :edit, @config.create.action_after_create
  end
end

Version data entries

56 entries across 56 versions & 3 rubygems

Version Path
active_scaffold-3.2.14 test/config/create_test.rb
active_scaffold-3.2.13 test/config/create_test.rb
active_scaffold-3.2.12 test/config/create_test.rb
active_scaffold-3.2.11 test/config/create_test.rb
active_scaffold-3.2.10 test/config/create_test.rb
active_scaffold-3.2.9 test/config/create_test.rb
active_scaffold-3.2.8 test/config/create_test.rb
active_scaffold-3.2.7 test/config/create_test.rb
active_scaffold-3.2.6 test/config/create_test.rb
active_scaffold-3.2.5 test/config/create_test.rb
active_scaffold-3.2.4 test/config/create_test.rb
active_scaffold-3.2.3 test/config/create_test.rb
active_scaffold-sequel-0.5.1 test/config/create_test.rb
active_scaffold-sequel-0.5.0 test/config/create_test.rb
active_scaffold-3.2.2 test/config/create_test.rb
active_scaffold-3.2.1 test/config/create_test.rb
active_scaffold-sequel-0.4.0 test/config/create_test.rb
active_scaffold-sequel-0.3.0 test/config/create_test.rb
active_scaffold-3.2.0 test/config/create_test.rb
active_scaffold-3.1.20 test/config/create_test.rb