breadcrumbs_on_rails 2.2.0 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,3 +1,8 @@
1
+ # Bundler
1
2
  .bundle
2
- pkg
3
- yardoc
3
+ pkg/*
4
+ Gemfile.lock
5
+
6
+ # YARD
7
+ .yardoc
8
+ yardoc/
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use @breadcrumbs_on_rails --create
data/CHANGELOG.md CHANGED
@@ -1,6 +1,17 @@
1
1
  # Changelog
2
2
 
3
3
 
4
+ ## Release 2.3.0
5
+
6
+ * FIXED: In some circumstances the BreadcrumbsOnRails::ActionController::HelperMethods is not mixed into the controller.
7
+
8
+ * FIXED: Breadcrumbs now accepts a polymorphic path (GH-15).
9
+
10
+ * CHANGED: Second argument on `add_breadcrumb` is now optional (GH-6, GH-32). [Thanks @mpartel]
11
+
12
+ * CHANGED: Breadcrumb path computation fallbacks to url_for in case of unknown arguments.
13
+
14
+
4
15
  ## Release 2.2.0
5
16
 
6
17
  * NEW: Support for Rails 3.2.
@@ -1,4 +1,4 @@
1
- Copyright (c) 2009-2012 Simone Carletti
1
+ Copyright (c) 2009-2012 Simone Carletti <weppos@weppos.net>
2
2
 
3
3
  MIT License
4
4
 
@@ -2,19 +2,19 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "breadcrumbs_on_rails"
5
- s.version = "2.2.0"
5
+ s.version = "2.3.0"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Simone Carletti"]
9
- s.date = "2012-02-03"
9
+ s.date = "2012-12-25"
10
10
  s.description = "BreadcrumbsOnRails is a simple Ruby on Rails plugin for creating and managing a breadcrumb navigation for a Rails project."
11
11
  s.email = "weppos@weppos.net"
12
- s.files = [".gitignore", ".travis.yml", "Appraisals", "CHANGELOG.md", "Gemfile", "Gemfile.lock", "LICENSE", "README.md", "Rakefile", "breadcrumbs_on_rails.gemspec", "gemfiles/3.0.gemfile", "gemfiles/3.0.gemfile.lock", "gemfiles/3.1.gemfile", "gemfiles/3.1.gemfile.lock", "gemfiles/3.2.gemfile", "gemfiles/3.2.gemfile.lock", "init.rb", "lib/breadcrumbs_on_rails.rb", "lib/breadcrumbs_on_rails/action_controller.rb", "lib/breadcrumbs_on_rails/breadcrumbs.rb", "lib/breadcrumbs_on_rails/railtie.rb", "lib/breadcrumbs_on_rails/version.rb", "test/test_helper.rb", "test/unit/builder_test.rb", "test/unit/element_test.rb", "test/unit/simple_builder_test.rb"]
12
+ s.files = [".gitignore", ".rvmrc", ".travis.yml", "Appraisals", "CHANGELOG.md", "Gemfile", "LICENSE.txt", "README.md", "Rakefile", "breadcrumbs_on_rails.gemspec", "gemfiles/3.0.gemfile", "gemfiles/3.0.gemfile.lock", "gemfiles/3.1.gemfile", "gemfiles/3.1.gemfile.lock", "gemfiles/3.2.gemfile", "gemfiles/3.2.gemfile.lock", "init.rb", "lib/breadcrumbs_on_rails.rb", "lib/breadcrumbs_on_rails/action_controller.rb", "lib/breadcrumbs_on_rails/breadcrumbs.rb", "lib/breadcrumbs_on_rails/railtie.rb", "lib/breadcrumbs_on_rails/version.rb", "test/dummy.rb", "test/test_helper.rb", "test/unit/action_controller_test.rb", "test/unit/builder_test.rb", "test/unit/element_test.rb", "test/unit/simple_builder_test.rb", "test/views/example/default.html.erb"]
13
13
  s.homepage = "http://www.simonecarletti.com/code/breadcrumbs_on_rails"
14
14
  s.require_paths = ["lib"]
15
- s.rubygems_version = "1.8.11"
15
+ s.rubygems_version = "1.8.24"
16
16
  s.summary = "A simple Ruby on Rails plugin for creating and managing a breadcrumb navigation."
17
- s.test_files = ["test/test_helper.rb", "test/unit/builder_test.rb", "test/unit/element_test.rb", "test/unit/simple_builder_test.rb"]
17
+ s.test_files = ["test/dummy.rb", "test/test_helper.rb", "test/unit/action_controller_test.rb", "test/unit/builder_test.rb", "test/unit/element_test.rb", "test/unit/simple_builder_test.rb", "test/views/example/default.html.erb"]
18
18
 
19
19
  if s.respond_to? :specification_version then
20
20
  s.specification_version = 3
@@ -19,7 +19,7 @@ module BreadcrumbsOnRails
19
19
 
20
20
  protected
21
21
 
22
- def add_breadcrumb(name, path, options = {})
22
+ def add_breadcrumb(name, path = nil, options = {})
23
23
  self.breadcrumbs << Breadcrumbs::Element.new(name, path, options)
24
24
  end
25
25
 
@@ -60,7 +60,7 @@ module BreadcrumbsOnRails
60
60
 
61
61
  module ClassMethods
62
62
 
63
- def add_breadcrumb(name, path, filter_options = {})
63
+ def add_breadcrumb(name, path = nil, filter_options = {})
64
64
  # This isn't really nice here
65
65
  if eval = Utils.convert_to_set_of_strings(filter_options.delete(:eval), %w(name path))
66
66
  name = Utils.instance_proc(name) if eval.include?("name")
@@ -61,10 +61,8 @@ module BreadcrumbsOnRails
61
61
  @context.send(path)
62
62
  when Proc
63
63
  path.call(@context)
64
- when Hash
65
- @context.url_for(path)
66
64
  else
67
- path.to_s
65
+ @context.url_for(path)
68
66
  end
69
67
  end
70
68
 
@@ -87,7 +85,11 @@ module BreadcrumbsOnRails
87
85
  end
88
86
 
89
87
  def render_element(element)
90
- content = @context.link_to_unless_current(compute_name(element), compute_path(element), element.options)
88
+ if element.path == nil
89
+ content = compute_name(element)
90
+ else
91
+ content = @context.link_to_unless_current(compute_name(element), compute_path(element), element.options)
92
+ end
91
93
  if @options[:tag]
92
94
  @context.content_tag(@options[:tag], content)
93
95
  else
@@ -116,7 +118,7 @@ module BreadcrumbsOnRails
116
118
  # @param [Hash] options The element/link URL.
117
119
  # @return [Element]
118
120
  #
119
- def initialize(name, path, options = {})
121
+ def initialize(name, path = nil, options = {})
120
122
  self.name = name
121
123
  self.path = path
122
124
  self.options = options
@@ -10,11 +10,10 @@ module BreadcrumbsOnRails
10
10
 
11
11
  class Railtie < Rails::Railtie
12
12
  initializer "breadcrumbs_on_rails.initialize" do
13
+ ActiveSupport.on_load(:action_controller) do
14
+ include BreadcrumbsOnRails::ActionController
15
+ end
13
16
  end
14
17
  end
15
18
 
16
19
  end
17
-
18
- ActiveSupport.on_load(:action_controller) do
19
- include BreadcrumbsOnRails::ActionController
20
- end
@@ -10,7 +10,7 @@ module BreadcrumbsOnRails
10
10
 
11
11
  module Version
12
12
  MAJOR = 2
13
- MINOR = 2
13
+ MINOR = 3
14
14
  PATCH = 0
15
15
  BUILD = nil
16
16
 
data/test/dummy.rb ADDED
@@ -0,0 +1,41 @@
1
+ ENV["RAILS_ENV"] = "test"
2
+
3
+ require "active_support"
4
+ require "action_controller"
5
+ require "rails/railtie"
6
+
7
+
8
+ class Dummy
9
+ Routes = ActionDispatch::Routing::RouteSet.new
10
+ Routes.draw do
11
+ match ':controller(/:action(/:id))'
12
+ end
13
+ end
14
+
15
+ ActionController::Base.view_paths = File.join(File.dirname(__FILE__), 'views')
16
+ ActionController::Base.send :include, Dummy::Routes.url_helpers
17
+
18
+ class ActiveSupport::TestCase
19
+
20
+ setup do
21
+ @routes = Dummy::Routes
22
+ end
23
+
24
+
25
+ def controller
26
+ @controller_proxy ||= ControllerProxy.new(@controller)
27
+ end
28
+
29
+ class ControllerProxy
30
+ def initialize(controller)
31
+ @controller = controller
32
+ end
33
+ def method_missing(method, *args)
34
+ @controller.instance_eval do
35
+ m = method(method)
36
+ m.call(*args)
37
+ end
38
+ end
39
+ end
40
+
41
+ end
data/test/test_helper.rb CHANGED
@@ -1,20 +1,6 @@
1
1
  require 'test/unit'
2
2
  require 'mocha'
3
-
4
- ENV["RAILS_ENV"] = "test"
5
-
6
- require "active_support"
7
- require "action_controller"
8
- require "rails/railtie"
3
+ require 'dummy'
9
4
 
10
5
  $:.unshift File.expand_path('../../lib', __FILE__)
11
6
  require 'breadcrumbs_on_rails'
12
-
13
- ActionController::Base.view_paths = File.join(File.dirname(__FILE__), 'views')
14
-
15
- BreadcrumbsOnRails::Routes = ActionDispatch::Routing::RouteSet.new
16
- BreadcrumbsOnRails::Routes.draw do
17
- match ':controller(/:action(/:id))'
18
- end
19
-
20
- ActionController::Base.send :include, BreadcrumbsOnRails::Routes.url_helpers
@@ -0,0 +1,72 @@
1
+ require 'test_helper'
2
+
3
+
4
+ class ExampleController < ActionController::Base
5
+ include BreadcrumbsOnRails::ActionController
6
+
7
+ def self.controller_name; "example"; end
8
+ def self.controller_path; "example"; end
9
+
10
+ layout false
11
+
12
+ def action_default
13
+ execute("action_default")
14
+ end
15
+
16
+ def action_compute_paths
17
+ add_breadcrumb "String", "/"
18
+ add_breadcrumb "Proc", proc { |c| "/?proc" }
19
+ add_breadcrumb "Polymorfic", [:admin, :namespace]
20
+ execute("action_default")
21
+ end
22
+
23
+
24
+ private
25
+
26
+ def execute(method)
27
+ if method.to_s =~ /^action_(.*)/
28
+ render :action => (params[:template] || 'default')
29
+ end
30
+ end
31
+
32
+ def admin_namespace_path(*)
33
+ "/?polymorfic"
34
+ end
35
+ helper_method :admin_namespace_path
36
+
37
+ end
38
+
39
+ class ExampleControllerTest < ActionController::TestCase
40
+ tests ExampleController
41
+
42
+ def test_render_default
43
+ get :action_default
44
+ assert_dom_equal %(),
45
+ @response.body
46
+ end
47
+
48
+ def test_render_compute_paths
49
+ get :action_compute_paths
50
+ assert_dom_equal %(<a href="/">String</a> &raquo; <a href="/?proc">Proc</a> &raquo; <a href="/?polymorfic">Polymorfic</a>),
51
+ @response.body
52
+ end
53
+
54
+ end
55
+
56
+ class ExampleHelpersTest < ActionView::TestCase
57
+ tests BreadcrumbsOnRails::ActionController::HelperMethods
58
+ include ActionView::Helpers::TagHelper
59
+ include ActionView::Helpers::UrlHelper
60
+
61
+ attr_accessor :breadcrumbs
62
+
63
+ setup do
64
+ self.breadcrumbs = []
65
+ end
66
+
67
+ def test_render_breadcrumbs
68
+ assert_dom_equal '', render_breadcrumbs
69
+ end
70
+
71
+ end
72
+
@@ -81,7 +81,12 @@ class BuilderTest < ActionView::TestCase
81
81
 
82
82
 
83
83
  def url_for(params)
84
- "http://localhost?" + params.to_param
84
+ case params
85
+ when String
86
+ params
87
+ else
88
+ "http://localhost?" + params.to_param
89
+ end
85
90
  end
86
91
 
87
92
  protected
@@ -2,10 +2,9 @@ require 'test_helper'
2
2
 
3
3
  class ElementTest < ActiveSupport::TestCase
4
4
 
5
- def test_initialize_should_require_name_and_path
5
+ def test_initialize_should_require_name
6
6
  assert_raise(ArgumentError) { BreadcrumbsOnRails::Breadcrumbs::Element.new }
7
- assert_raise(ArgumentError) { BreadcrumbsOnRails::Breadcrumbs::Element.new(nil) }
8
- assert_nothing_raised { BreadcrumbsOnRails::Breadcrumbs::Element.new(nil, nil) }
7
+ assert_nothing_raised { BreadcrumbsOnRails::Breadcrumbs::Element.new(nil) }
9
8
  end
10
9
 
11
10
  def test_initialize_should_set_name
@@ -41,5 +40,10 @@ class ElementTest < ActiveSupport::TestCase
41
40
  element.options = { :title => "Go to the Homepage" }
42
41
  assert_equal({ :title => "Go to the Homepage" }, element.options)
43
42
  end
43
+
44
+ def test_path_is_optional
45
+ element = BreadcrumbsOnRails::Breadcrumbs::Element.new(:homepage)
46
+ assert_nil element.path
47
+ end
44
48
 
45
49
  end
@@ -52,6 +52,14 @@ class SimpleBuilderTest < ActionView::TestCase
52
52
  simplebuilder(@template, generate_elements(2)).render)
53
53
  end
54
54
 
55
+ def test_render_with_no_links
56
+ elements = (1..2).collect do |index|
57
+ BreadcrumbsOnRails::Breadcrumbs::Element.new("Element #{index}", nil)
58
+ end
59
+ assert_dom_equal("Element 1 &raquo; Element 2",
60
+ simplebuilder(@template, elements).render)
61
+ end
62
+
55
63
 
56
64
  protected
57
65
 
@@ -0,0 +1 @@
1
+ <%= render_breadcrumbs %>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: breadcrumbs_on_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-03 00:00:00.000000000Z
12
+ date: 2012-12-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &70311920950420 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: '3.0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70311920950420
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '3.0'
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: appraisal
27
- requirement: &70311920948980 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ! '>='
@@ -32,10 +37,15 @@ dependencies:
32
37
  version: '0'
33
38
  type: :development
34
39
  prerelease: false
35
- version_requirements: *70311920948980
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: mocha
38
- requirement: &70311920940920 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ~>
@@ -43,10 +53,15 @@ dependencies:
43
53
  version: 0.9.10
44
54
  type: :development
45
55
  prerelease: false
46
- version_requirements: *70311920940920
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 0.9.10
47
62
  - !ruby/object:Gem::Dependency
48
63
  name: yard
49
- requirement: &70311920940160 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
50
65
  none: false
51
66
  requirements:
52
67
  - - ! '>='
@@ -54,7 +69,12 @@ dependencies:
54
69
  version: '0'
55
70
  type: :development
56
71
  prerelease: false
57
- version_requirements: *70311920940160
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
58
78
  description: BreadcrumbsOnRails is a simple Ruby on Rails plugin for creating and
59
79
  managing a breadcrumb navigation for a Rails project.
60
80
  email: weppos@weppos.net
@@ -63,12 +83,12 @@ extensions: []
63
83
  extra_rdoc_files: []
64
84
  files:
65
85
  - .gitignore
86
+ - .rvmrc
66
87
  - .travis.yml
67
88
  - Appraisals
68
89
  - CHANGELOG.md
69
90
  - Gemfile
70
- - Gemfile.lock
71
- - LICENSE
91
+ - LICENSE.txt
72
92
  - README.md
73
93
  - Rakefile
74
94
  - breadcrumbs_on_rails.gemspec
@@ -84,10 +104,13 @@ files:
84
104
  - lib/breadcrumbs_on_rails/breadcrumbs.rb
85
105
  - lib/breadcrumbs_on_rails/railtie.rb
86
106
  - lib/breadcrumbs_on_rails/version.rb
107
+ - test/dummy.rb
87
108
  - test/test_helper.rb
109
+ - test/unit/action_controller_test.rb
88
110
  - test/unit/builder_test.rb
89
111
  - test/unit/element_test.rb
90
112
  - test/unit/simple_builder_test.rb
113
+ - test/views/example/default.html.erb
91
114
  homepage: http://www.simonecarletti.com/code/breadcrumbs_on_rails
92
115
  licenses: []
93
116
  post_install_message:
@@ -108,12 +131,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
131
  version: '0'
109
132
  requirements: []
110
133
  rubyforge_project:
111
- rubygems_version: 1.8.11
134
+ rubygems_version: 1.8.24
112
135
  signing_key:
113
136
  specification_version: 3
114
137
  summary: A simple Ruby on Rails plugin for creating and managing a breadcrumb navigation.
115
138
  test_files:
139
+ - test/dummy.rb
116
140
  - test/test_helper.rb
141
+ - test/unit/action_controller_test.rb
117
142
  - test/unit/builder_test.rb
118
143
  - test/unit/element_test.rb
119
144
  - test/unit/simple_builder_test.rb
145
+ - test/views/example/default.html.erb
data/Gemfile.lock DELETED
@@ -1,99 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- breadcrumbs_on_rails (2.2.0)
5
-
6
- GEM
7
- remote: http://rubygems.org/
8
- specs:
9
- actionmailer (3.2.1)
10
- actionpack (= 3.2.1)
11
- mail (~> 2.4.0)
12
- actionpack (3.2.1)
13
- activemodel (= 3.2.1)
14
- activesupport (= 3.2.1)
15
- builder (~> 3.0.0)
16
- erubis (~> 2.7.0)
17
- journey (~> 1.0.1)
18
- rack (~> 1.4.0)
19
- rack-cache (~> 1.1)
20
- rack-test (~> 0.6.1)
21
- sprockets (~> 2.1.2)
22
- activemodel (3.2.1)
23
- activesupport (= 3.2.1)
24
- builder (~> 3.0.0)
25
- activerecord (3.2.1)
26
- activemodel (= 3.2.1)
27
- activesupport (= 3.2.1)
28
- arel (~> 3.0.0)
29
- tzinfo (~> 0.3.29)
30
- activeresource (3.2.1)
31
- activemodel (= 3.2.1)
32
- activesupport (= 3.2.1)
33
- activesupport (3.2.1)
34
- i18n (~> 0.6)
35
- multi_json (~> 1.0)
36
- appraisal (0.4.0)
37
- bundler
38
- rake
39
- arel (3.0.0)
40
- builder (3.0.0)
41
- erubis (2.7.0)
42
- hike (1.2.1)
43
- i18n (0.6.0)
44
- journey (1.0.1)
45
- json (1.6.5)
46
- mail (2.4.1)
47
- i18n (>= 0.4.0)
48
- mime-types (~> 1.16)
49
- treetop (~> 1.4.8)
50
- mime-types (1.17.2)
51
- mocha (0.9.12)
52
- multi_json (1.0.4)
53
- polyglot (0.3.3)
54
- rack (1.4.1)
55
- rack-cache (1.1)
56
- rack (>= 0.4)
57
- rack-ssl (1.3.2)
58
- rack
59
- rack-test (0.6.1)
60
- rack (>= 1.0)
61
- rails (3.2.1)
62
- actionmailer (= 3.2.1)
63
- actionpack (= 3.2.1)
64
- activerecord (= 3.2.1)
65
- activeresource (= 3.2.1)
66
- activesupport (= 3.2.1)
67
- bundler (~> 1.0)
68
- railties (= 3.2.1)
69
- railties (3.2.1)
70
- actionpack (= 3.2.1)
71
- activesupport (= 3.2.1)
72
- rack-ssl (~> 1.3.2)
73
- rake (>= 0.8.7)
74
- rdoc (~> 3.4)
75
- thor (~> 0.14.6)
76
- rake (0.9.2.2)
77
- rdoc (3.12)
78
- json (~> 1.4)
79
- sprockets (2.1.2)
80
- hike (~> 1.2)
81
- rack (~> 1.0)
82
- tilt (~> 1.1, != 1.3.0)
83
- thor (0.14.6)
84
- tilt (1.3.3)
85
- treetop (1.4.10)
86
- polyglot
87
- polyglot (>= 0.3.1)
88
- tzinfo (0.3.31)
89
- yard (0.7.5)
90
-
91
- PLATFORMS
92
- ruby
93
-
94
- DEPENDENCIES
95
- appraisal
96
- breadcrumbs_on_rails!
97
- mocha (~> 0.9.10)
98
- rails (>= 3.0)
99
- yard