Skip to content

Commit

Permalink
Refactoring and polishing tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
weppos committed Jun 9, 2009
1 parent 667cb5c commit 78e8c31
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 47 deletions.
5 changes: 3 additions & 2 deletions test/controller_mixin_helpers_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def checkpoint

def tab_for(tab, name, *args)
end

end

class NilBoundariesBuilder < TabsOnRails::Tabs::Builder
Expand All @@ -35,10 +36,10 @@ def open_tabs


class ControllerMixinHelpersTest < ActionView::TestCase
tests TabsOnRails::ControllerMixin::HelperMethods
include ActionView::Helpers::TagHelper
include ActionView::Helpers::UrlHelper
include TabsOnRails::ControllerMixin::HelperMethods



def test_tabs_tag_should_raise_local_jump_error_without_block
assert_raise(LocalJumpError) { tabs_tag }
Expand Down
8 changes: 3 additions & 5 deletions test/controller_mixin_test.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
require 'test_helper'

class MixinController < ActionController::Base
end
class ControllerMixinTest < ActiveSupport::TestCase

class MixinController < ActionController::Base; end

class ControllerMixinTest < ActiveSupport::TestCase

def setup
@controller = MixinController.new
@request = ActionController::TestRequest.new
Expand Down Expand Up @@ -95,4 +93,4 @@ def test_deprecated_current_tab_setter
end
end

end
end
Original file line number Diff line number Diff line change
@@ -1,40 +1,38 @@
require 'test_helper'

class MixinController < ActionController::Base
def self.controller_name; "mixin"; end
def self.controller_path; "mixin"; end
class ControllerMixinWithControllerTest < ActiveSupport::TestCase

layout false

set_tab :dashboard
set_tab :welcome, :only => %w(action_welcome)
set_tab :dashboard, :only => %w(action_namespace)
set_tab :homepage, :namespace, :only => %w(action_namespace)
class MixinController < ActionController::Base
def self.controller_name; "mixin"; end
def self.controller_path; "mixin"; end

# Deprecated.
current_tab :deprecated, :only => %w(action_current_tab)

layout false

def method_missing(method, *args)
if method =~ /^action_(.*)/
render :action => (params[:template] || 'standard')
end
end
set_tab :dashboard
set_tab :welcome, :only => %w(action_welcome)
set_tab :dashboard, :only => %w(action_namespace)
set_tab :homepage, :namespace, :only => %w(action_namespace)
# Deprecated.
current_tab :deprecated, :only => %w(action_current_tab)

def rescue_action(e) raise end
end
def method_missing(method, *args)
if method =~ /^action_(.*)/
render :action => (params[:template] || 'standard')
end
end

MixinController.view_paths = [ File.dirname(__FILE__) + "/fixtures/" ]
def rescue_action(e) raise end
end

MixinController.view_paths = [ File.dirname(__FILE__) + "/fixtures/" ]

class ControllerMixinTest < ActiveSupport::TestCase

def setup
@controller = MixinController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
end



def test_set_tab
get :action_dashboard
assert_equal(:dashboard, @controller.current_tab)
Expand All @@ -44,7 +42,7 @@ def test_set_tab
<li><a href="/w">Welcome</a></li>
</ul>}, @response.body)
end

def test_set_tab_with_only_option
get :action_welcome
assert_equal(:welcome, @controller.current_tab)
Expand Down
31 changes: 15 additions & 16 deletions test/tabs_builder_test.rb
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
require 'test_helper'

class TabsBuilderTemplate
include ActionView::Helpers::TagHelper
include ActionView::Helpers::UrlHelper

def current_tab(namespace)
case namespace
when nil, :default
:dashboard
when :foospace
:footab
else
:elsetab
class TabsBuilderTest < ActiveSupport::TestCase

class TabsBuilderTemplate
include ActionView::Helpers::TagHelper
include ActionView::Helpers::UrlHelper

def current_tab(namespace)
case namespace
when nil, :default
:dashboard
when :foospace
:footab
else
:elsetab
end
end
end
end


class TabsBuilderTest < ActiveSupport::TestCase

def setup
@template = TabsBuilderTemplate.new
@builder = TabsOnRails::Tabs::TabsBuilder.new(@template)
Expand Down

0 comments on commit 78e8c31

Please sign in to comment.