forked from activescaffold/active_scaffold
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
529 additions
and
501 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,17 @@ | ||
require 'test_helper' | ||
|
||
class Config::BaseTest < Test::Unit::TestCase | ||
def setup | ||
@base = ActiveScaffold::Config::Base.new(ActiveScaffold::Config::Core.new(:model_stub)) | ||
end | ||
|
||
def test_formats | ||
assert_equal [], @base.formats | ||
@base.formats << :pdf | ||
assert_equal [:pdf], @base.formats | ||
@base.formats = [:html] | ||
assert_equal [:html], @base.formats | ||
module Config | ||
class BaseTest < Test::Unit::TestCase | ||
def setup | ||
@base = ActiveScaffold::Config::Base.new(ActiveScaffold::Config::Core.new(:model_stub)) | ||
end | ||
|
||
def test_formats | ||
assert_equal [], @base.formats | ||
@base.formats << :pdf | ||
assert_equal [:pdf], @base.formats | ||
@base.formats = [:html] | ||
assert_equal [:html], @base.formats | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,64 @@ | ||
require 'test_helper' | ||
|
||
class Config::CoreTest < Test::Unit::TestCase | ||
class ModelStubsController < ActionController::Base; end | ||
def setup | ||
@config = ActiveScaffold::Config::Core.new :model_stub | ||
ModelStubsController.instance_variable_set :@active_scaffold_config, @config | ||
end | ||
|
||
def test_default_options | ||
assert !@config.add_sti_create_links? | ||
assert !@config.sti_children | ||
assert_equal [:create, :list, :search, :update, :delete, :show, :nested, :subform], @config.actions.to_a | ||
assert_equal :default, @config.frontend | ||
assert_equal :default, @config.theme | ||
assert_equal 'Model stub', @config.label(:count => 1) | ||
assert_equal 'ModelStubs', @config.label | ||
end | ||
|
||
def test_add_sti_children | ||
@config.sti_create_links = true | ||
assert !@config.add_sti_create_links? | ||
@config.sti_children = [:a] | ||
assert @config.add_sti_create_links? | ||
end | ||
|
||
def test_sti_children | ||
@config.sti_children = [:a] | ||
assert_equal [:a], @config.sti_children | ||
end | ||
|
||
def test_actions | ||
assert @config.actions.include?(:create) | ||
@config.actions = [:list] | ||
assert !@config.actions.include?(:create) | ||
assert_equal [:list], @config.actions.to_a | ||
end | ||
|
||
def test_form_ui_in_sti | ||
@config.columns << :type | ||
module Config | ||
class CoreTest < Test::Unit::TestCase | ||
class ModelStubsController < ActionController::Base; end | ||
def setup | ||
@config = ActiveScaffold::Config::Core.new :model_stub | ||
ModelStubsController.instance_variable_set :@active_scaffold_config, @config | ||
end | ||
|
||
@config.sti_create_links = false | ||
@config.sti_children = [:model_stub] | ||
@config._configure_sti | ||
assert_equal :select, @config.columns[:type].form_ui | ||
assert_equal [['Model stub', 'ModelStub']], @config.columns[:type].options[:options] | ||
def test_default_options | ||
assert !@config.add_sti_create_links? | ||
assert !@config.sti_children | ||
assert_equal [:create, :list, :search, :update, :delete, :show, :nested, :subform], @config.actions.to_a | ||
assert_equal :default, @config.frontend | ||
assert_equal :default, @config.theme | ||
assert_equal 'Model stub', @config.label(:count => 1) | ||
assert_equal 'ModelStubs', @config.label | ||
end | ||
|
||
@config.columns[:type].form_ui = nil | ||
@config.sti_create_links = true | ||
@config._configure_sti | ||
assert_equal :hidden, @config.columns[:type].form_ui | ||
end | ||
|
||
def test_sti_children_links | ||
@config.sti_children = [:model_stub] | ||
@config.sti_create_links = true | ||
@config.action_links.add @config.create.link | ||
ModelStubsController.send(:_add_sti_create_links) | ||
assert_equal 'Create Model stub', @config.action_links[:new].label | ||
assert_equal 'config/core_test/model_stubs', @config.action_links[:new].parameters[:parent_sti] | ||
def test_add_sti_children | ||
@config.sti_create_links = true | ||
assert !@config.add_sti_create_links? | ||
@config.sti_children = [:a] | ||
assert @config.add_sti_create_links? | ||
end | ||
|
||
def test_sti_children | ||
@config.sti_children = [:a] | ||
assert_equal [:a], @config.sti_children | ||
end | ||
|
||
def test_actions | ||
assert @config.actions.include?(:create) | ||
@config.actions = [:list] | ||
assert !@config.actions.include?(:create) | ||
assert_equal [:list], @config.actions.to_a | ||
end | ||
|
||
def test_form_ui_in_sti | ||
@config.columns << :type | ||
|
||
@config.sti_create_links = false | ||
@config.sti_children = [:model_stub] | ||
@config._configure_sti | ||
assert_equal :select, @config.columns[:type].form_ui | ||
assert_equal [['Model stub', 'ModelStub']], @config.columns[:type].options[:options] | ||
|
||
@config.columns[:type].form_ui = nil | ||
@config.sti_create_links = true | ||
@config._configure_sti | ||
assert_equal :hidden, @config.columns[:type].form_ui | ||
end | ||
|
||
def test_sti_children_links | ||
@config.sti_children = [:model_stub] | ||
@config.sti_create_links = true | ||
@config.action_links.add @config.create.link | ||
ModelStubsController.send(:_add_sti_create_links) | ||
assert_equal 'Create Model stub', @config.action_links[:new].label | ||
assert_equal 'config/core_test/model_stubs', @config.action_links[:new].parameters[:parent_sti] | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,60 @@ | ||
require 'test_helper' | ||
|
||
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 Model stub', @config.create.label | ||
end | ||
module Config | ||
class 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 Model stub', @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 Model stub', @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 | ||
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 Model stub', @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 | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,35 @@ | ||
require 'test_helper' | ||
|
||
class Config::DeleteTest < Test::Unit::TestCase | ||
def setup | ||
@config = ActiveScaffold::Config::Core.new :model_stub | ||
@default_link = @config.delete.link | ||
end | ||
|
||
def teardown | ||
@config.delete.link = @default_link | ||
end | ||
module Config | ||
class DeleteTest < Test::Unit::TestCase | ||
def setup | ||
@config = ActiveScaffold::Config::Core.new :model_stub | ||
@default_link = @config.delete.link | ||
end | ||
|
||
def teardown | ||
@config.delete.link = @default_link | ||
end | ||
|
||
def test_link_defaults | ||
link = @config.delete.link | ||
assert !link.page? | ||
assert !link.popup? | ||
assert link.confirm? | ||
assert_equal "destroy", link.action | ||
assert_equal "Delete", link.label | ||
assert link.inline? | ||
blank = {} | ||
assert_equal blank, link.html_options | ||
assert_equal :delete, link.method | ||
assert_equal :member, link.type | ||
assert_equal :delete, link.crud_type | ||
assert_equal :delete_authorized?, link.security_method | ||
end | ||
|
||
def test_setting_link | ||
@config.delete.link = ActiveScaffold::DataStructures::ActionLink.new('update', :label => 'Monkeys') | ||
assert_not_equal(@default_link, @config.delete.link) | ||
def test_link_defaults | ||
link = @config.delete.link | ||
assert !link.page? | ||
assert !link.popup? | ||
assert link.confirm? | ||
assert_equal "destroy", link.action | ||
assert_equal "Delete", link.label | ||
assert link.inline? | ||
blank = {} | ||
assert_equal blank, link.html_options | ||
assert_equal :delete, link.method | ||
assert_equal :member, link.type | ||
assert_equal :delete, link.crud_type | ||
assert_equal :delete_authorized?, link.security_method | ||
end | ||
|
||
def test_setting_link | ||
@config.delete.link = ActiveScaffold::DataStructures::ActionLink.new('update', :label => 'Monkeys') | ||
assert_not_equal(@default_link, @config.delete.link) | ||
end | ||
end | ||
end |
Oops, something went wrong.