tabs_on_rails 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +50 -0
- data/LICENSE.rdoc +20 -0
- data/Manifest +23 -0
- data/README.rdoc +270 -0
- data/Rakefile +52 -0
- data/init.rb +1 -0
- data/install.rb +1 -0
- data/lib/tabs_on_rails/controller_mixin.rb +132 -0
- data/lib/tabs_on_rails/tabs.rb +136 -0
- data/lib/tabs_on_rails/version.rb +31 -0
- data/lib/tabs_on_rails.rb +28 -0
- data/rails/init.rb +5 -0
- data/tabs_on_rails.gemspec +37 -0
- data/tasks/tabs_on_rails_tasks.rake +4 -0
- data/test/builder_test.rb +85 -0
- data/test/controller_mixin_helpers_test.rb +86 -0
- data/test/controller_mixin_test.rb +90 -0
- data/test/controller_mixin_with_controller_test.rb +81 -0
- data/test/fixtures/mixin/standard.html.erb +4 -0
- data/test/tabs_builder_test.rb +40 -0
- data/test/tabs_on_rails_test.rb +9 -0
- data/test/test_helper.rb +54 -0
- data/uninstall.rb +1 -0
- metadata +113 -0
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ControllerMixinWithControllerTest < ActionController::TestCase
|
4
|
+
include ControllerTestHelpers
|
5
|
+
|
6
|
+
class MixinController < ActionController::Base
|
7
|
+
def self.controller_name; "mixin"; end
|
8
|
+
def self.controller_path; "mixin"; end
|
9
|
+
|
10
|
+
layout false
|
11
|
+
|
12
|
+
set_tab :dashboard
|
13
|
+
set_tab :welcome, :only => %w(action_welcome)
|
14
|
+
set_tab :dashboard, :only => %w(action_namespace)
|
15
|
+
set_tab :homepage, :namespace, :only => %w(action_namespace)
|
16
|
+
|
17
|
+
def method_missing(method, *args)
|
18
|
+
if method =~ /^action_(.*)/
|
19
|
+
render :action => (params[:template] || 'standard')
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def rescue_action(e) raise end
|
24
|
+
end
|
25
|
+
|
26
|
+
MixinController.view_paths = [ File.dirname(__FILE__) + "/fixtures/" ]
|
27
|
+
|
28
|
+
def setup
|
29
|
+
@controller = MixinController.new
|
30
|
+
@controller_proxy = ControllerProxy.new(@controller)
|
31
|
+
@request = ActionController::TestRequest.new
|
32
|
+
@response = ActionController::TestResponse.new
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
def test_set_tab
|
37
|
+
get :action_dashboard
|
38
|
+
assert_equal(:dashboard, controller.current_tab)
|
39
|
+
assert_equal(:dashboard, controller.current_tab(:default))
|
40
|
+
assert_equal(%Q{<ul>
|
41
|
+
<li><span>Dashboard</span></li>
|
42
|
+
<li><a href="/w">Welcome</a></li>
|
43
|
+
</ul>}, @response.body)
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_set_tab_with_only_option
|
47
|
+
get :action_welcome
|
48
|
+
assert_equal(:welcome, controller.current_tab)
|
49
|
+
assert_equal(:welcome, controller.current_tab(:default))
|
50
|
+
assert_equal(%Q{<ul>
|
51
|
+
<li><a href="/d">Dashboard</a></li>
|
52
|
+
<li><span>Welcome</span></li>
|
53
|
+
</ul>}, @response.body)
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_set_tab_with_namespace
|
57
|
+
get :action_namespace
|
58
|
+
assert_equal(:dashboard, controller.current_tab)
|
59
|
+
assert_equal(:dashboard, controller.current_tab(:default))
|
60
|
+
assert_equal(:homepage, controller.current_tab(:namespace))
|
61
|
+
assert_equal(%Q{<ul>
|
62
|
+
<li><span>Dashboard</span></li>
|
63
|
+
<li><a href="/w">Welcome</a></li>
|
64
|
+
</ul>}, @response.body)
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_current_tab
|
68
|
+
get :action_dashboard
|
69
|
+
assert_equal :dashboard, controller.current_tab
|
70
|
+
assert_equal :dashboard, controller.current_tab(:default)
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_current_tab_question
|
74
|
+
get :action_dashboard
|
75
|
+
assert controller.current_tab?(:dashboard)
|
76
|
+
assert controller.current_tab?(:dashboard, :default)
|
77
|
+
assert !controller.current_tab?(:foobar)
|
78
|
+
assert !controller.current_tab?(:foobar, :default)
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class TabsBuilderTest < ActionView::TestCase
|
4
|
+
|
5
|
+
class TabsBuilderTemplate
|
6
|
+
include ActionView::Helpers::TagHelper
|
7
|
+
include ActionView::Helpers::UrlHelper
|
8
|
+
|
9
|
+
def current_tab(namespace)
|
10
|
+
case namespace
|
11
|
+
when nil, :default
|
12
|
+
:dashboard
|
13
|
+
when :foospace
|
14
|
+
:footab
|
15
|
+
else
|
16
|
+
:elsetab
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def setup
|
22
|
+
@template = TabsBuilderTemplate.new
|
23
|
+
@builder = TabsOnRails::Tabs::TabsBuilder.new(@template)
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_should_implement_builder
|
27
|
+
assert_equal(TabsOnRails::Tabs::Builder, TabsOnRails::Tabs::TabsBuilder.superclass)
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_tab_for_should_return_link_to_unless_current_tab
|
31
|
+
assert_dom_equal('<li><a href="#">Welcome</a></li>', @builder.tab_for(:welcome, 'Welcome', '#'))
|
32
|
+
assert_dom_equal('<li><a href="http://foobar.com/">Foo Bar</a></li>', @builder.tab_for(:welcome, 'Foo Bar', 'http://foobar.com/'))
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_tab_for_should_return_span_if_current_tab
|
36
|
+
assert_dom_equal('<li><span>Dashboard</span></li>', @builder.tab_for(:dashboard, 'Dashboard', '#'))
|
37
|
+
assert_dom_equal('<li><span>Foo Bar</span></li>', @builder.tab_for(:dashboard, 'Foo Bar', '#'))
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
gem 'rails', '~>2.3.0'
|
5
|
+
gem 'mocha', '0.9.7'
|
6
|
+
|
7
|
+
# Remember! Due to some Mocha internal changes,
|
8
|
+
# Rails 2.2.x requires Mocha 0.9.5 and
|
9
|
+
# Rails 2.3.x requires Mocha 0.9.7
|
10
|
+
# gem 'rails', '2.2.2'
|
11
|
+
# gem 'mocha', '0.9.5'
|
12
|
+
|
13
|
+
require 'mocha'
|
14
|
+
require 'test/unit'
|
15
|
+
require 'active_support'
|
16
|
+
require 'action_controller'
|
17
|
+
require 'action_controller/cgi_ext'
|
18
|
+
require 'action_controller/test_process'
|
19
|
+
require 'action_view/test_case'
|
20
|
+
|
21
|
+
$:.unshift File.dirname(__FILE__) + '/../lib'
|
22
|
+
require File.dirname(__FILE__) + '/../init.rb'
|
23
|
+
|
24
|
+
RAILS_ROOT = '.' unless defined? RAILS_ROOT
|
25
|
+
RAILS_ENV = 'test' unless defined? RAILS_ENV
|
26
|
+
|
27
|
+
ActionController::Base.logger = nil
|
28
|
+
ActionController::Routing::Routes.reload rescue nil
|
29
|
+
|
30
|
+
|
31
|
+
# Unit tests for Helpers are based on unit tests created and developed by Rails core team.
|
32
|
+
# See action_pack/test/abstract_unit for more details.
|
33
|
+
|
34
|
+
|
35
|
+
module ControllerTestHelpers
|
36
|
+
private
|
37
|
+
|
38
|
+
def controller
|
39
|
+
@controller_proxy
|
40
|
+
end
|
41
|
+
|
42
|
+
class ControllerProxy
|
43
|
+
def initialize(controller)
|
44
|
+
@controller = controller
|
45
|
+
end
|
46
|
+
def method_missing(method, *args)
|
47
|
+
@controller.instance_eval do
|
48
|
+
m = method(method)
|
49
|
+
m.call(*args)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
data/uninstall.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Uninstall hook code here
|
metadata
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tabs_on_rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.8.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Simone Carletti
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-10-09 00:00:00 +02:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rake
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0.8"
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: echoe
|
27
|
+
type: :development
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "3.1"
|
34
|
+
version:
|
35
|
+
description: " TabsOnRails is a simple Ruby on Rails plugin for creating and managing Tabs. It provides helpers for creating tabs with a flexible interface.\n"
|
36
|
+
email: weppos@weppos.net
|
37
|
+
executables: []
|
38
|
+
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files:
|
42
|
+
- CHANGELOG.rdoc
|
43
|
+
- lib/tabs_on_rails/controller_mixin.rb
|
44
|
+
- lib/tabs_on_rails/tabs.rb
|
45
|
+
- lib/tabs_on_rails/version.rb
|
46
|
+
- lib/tabs_on_rails.rb
|
47
|
+
- LICENSE.rdoc
|
48
|
+
- README.rdoc
|
49
|
+
files:
|
50
|
+
- CHANGELOG.rdoc
|
51
|
+
- init.rb
|
52
|
+
- install.rb
|
53
|
+
- lib/tabs_on_rails/controller_mixin.rb
|
54
|
+
- lib/tabs_on_rails/tabs.rb
|
55
|
+
- lib/tabs_on_rails/version.rb
|
56
|
+
- lib/tabs_on_rails.rb
|
57
|
+
- LICENSE.rdoc
|
58
|
+
- Manifest
|
59
|
+
- rails/init.rb
|
60
|
+
- Rakefile
|
61
|
+
- README.rdoc
|
62
|
+
- tabs_on_rails.gemspec
|
63
|
+
- tasks/tabs_on_rails_tasks.rake
|
64
|
+
- test/builder_test.rb
|
65
|
+
- test/controller_mixin_helpers_test.rb
|
66
|
+
- test/controller_mixin_test.rb
|
67
|
+
- test/controller_mixin_with_controller_test.rb
|
68
|
+
- test/fixtures/mixin/standard.html.erb
|
69
|
+
- test/tabs_builder_test.rb
|
70
|
+
- test/tabs_on_rails_test.rb
|
71
|
+
- test/test_helper.rb
|
72
|
+
- uninstall.rb
|
73
|
+
has_rdoc: true
|
74
|
+
homepage: http://code.simonecarletti.com/tabsonrails
|
75
|
+
licenses: []
|
76
|
+
|
77
|
+
post_install_message:
|
78
|
+
rdoc_options:
|
79
|
+
- --line-numbers
|
80
|
+
- --inline-source
|
81
|
+
- --title
|
82
|
+
- Tabs_on_rails
|
83
|
+
- --main
|
84
|
+
- README.rdoc
|
85
|
+
require_paths:
|
86
|
+
- lib
|
87
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: "0"
|
92
|
+
version:
|
93
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: "1.2"
|
98
|
+
version:
|
99
|
+
requirements: []
|
100
|
+
|
101
|
+
rubyforge_project:
|
102
|
+
rubygems_version: 1.3.4
|
103
|
+
signing_key:
|
104
|
+
specification_version: 3
|
105
|
+
summary: A simple Ruby on Rails plugin for creating and managing Tabs.
|
106
|
+
test_files:
|
107
|
+
- test/builder_test.rb
|
108
|
+
- test/controller_mixin_helpers_test.rb
|
109
|
+
- test/controller_mixin_test.rb
|
110
|
+
- test/controller_mixin_with_controller_test.rb
|
111
|
+
- test/tabs_builder_test.rb
|
112
|
+
- test/tabs_on_rails_test.rb
|
113
|
+
- test/test_helper.rb
|