easycrumbs 1.1.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source 'http://gemcutter.org'
2
+ source 'http://gems.github.com'
3
+
4
+ gem 'rails', '~> 3.2.0'
5
+
6
+ group :development do
7
+ gem 'mocha', '=0.9.12'
8
+ gem 'shoulda', '=2.11.3'
9
+ gem 'jeweler', '=1.5.2'
10
+ gem 'sqlite3'
11
+ end
@@ -0,0 +1,98 @@
1
+ GEM
2
+ remote: http://gemcutter.org/
3
+ remote: http://gems.github.com/
4
+ specs:
5
+ actionmailer (3.2.1)
6
+ actionpack (= 3.2.1)
7
+ mail (~> 2.4.0)
8
+ actionpack (3.2.1)
9
+ activemodel (= 3.2.1)
10
+ activesupport (= 3.2.1)
11
+ builder (~> 3.0.0)
12
+ erubis (~> 2.7.0)
13
+ journey (~> 1.0.1)
14
+ rack (~> 1.4.0)
15
+ rack-cache (~> 1.1)
16
+ rack-test (~> 0.6.1)
17
+ sprockets (~> 2.1.2)
18
+ activemodel (3.2.1)
19
+ activesupport (= 3.2.1)
20
+ builder (~> 3.0.0)
21
+ activerecord (3.2.1)
22
+ activemodel (= 3.2.1)
23
+ activesupport (= 3.2.1)
24
+ arel (~> 3.0.0)
25
+ tzinfo (~> 0.3.29)
26
+ activeresource (3.2.1)
27
+ activemodel (= 3.2.1)
28
+ activesupport (= 3.2.1)
29
+ activesupport (3.2.1)
30
+ i18n (~> 0.6)
31
+ multi_json (~> 1.0)
32
+ arel (3.0.2)
33
+ builder (3.0.0)
34
+ erubis (2.7.0)
35
+ git (1.2.5)
36
+ hike (1.2.1)
37
+ i18n (0.6.0)
38
+ jeweler (1.5.2)
39
+ bundler (~> 1.0.0)
40
+ git (>= 1.2.5)
41
+ rake
42
+ journey (1.0.3)
43
+ json (1.6.5)
44
+ mail (2.4.1)
45
+ i18n (>= 0.4.0)
46
+ mime-types (~> 1.16)
47
+ treetop (~> 1.4.8)
48
+ mime-types (1.17.2)
49
+ mocha (0.9.12)
50
+ multi_json (1.1.0)
51
+ polyglot (0.3.3)
52
+ rack (1.4.1)
53
+ rack-cache (1.1)
54
+ rack (>= 0.4)
55
+ rack-ssl (1.3.2)
56
+ rack
57
+ rack-test (0.6.1)
58
+ rack (>= 1.0)
59
+ rails (3.2.1)
60
+ actionmailer (= 3.2.1)
61
+ actionpack (= 3.2.1)
62
+ activerecord (= 3.2.1)
63
+ activeresource (= 3.2.1)
64
+ activesupport (= 3.2.1)
65
+ bundler (~> 1.0)
66
+ railties (= 3.2.1)
67
+ railties (3.2.1)
68
+ actionpack (= 3.2.1)
69
+ activesupport (= 3.2.1)
70
+ rack-ssl (~> 1.3.2)
71
+ rake (>= 0.8.7)
72
+ rdoc (~> 3.4)
73
+ thor (~> 0.14.6)
74
+ rake (0.9.2.2)
75
+ rdoc (3.12)
76
+ json (~> 1.4)
77
+ shoulda (2.11.3)
78
+ sprockets (2.1.2)
79
+ hike (~> 1.2)
80
+ rack (~> 1.0)
81
+ tilt (~> 1.1, != 1.3.0)
82
+ sqlite3 (1.3.5)
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
+
90
+ PLATFORMS
91
+ ruby
92
+
93
+ DEPENDENCIES
94
+ jeweler (= 1.5.2)
95
+ mocha (= 0.9.12)
96
+ rails (~> 3.2.0)
97
+ shoulda (= 2.11.3)
98
+ sqlite3
data/Rakefile CHANGED
@@ -1,3 +1,4 @@
1
+ # -*- encoding: utf-8 -*-#
1
2
  require 'rubygems'
2
3
  require 'rake'
3
4
 
@@ -25,7 +26,7 @@ Rake::TestTask.new(:test) do |test|
25
26
  test.verbose = true
26
27
  end
27
28
 
28
- task :test => :check_dependencies
29
+ task :test
29
30
 
30
31
  task :default => :test
31
32
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.0
1
+ 2.0.0
@@ -1,61 +1,85 @@
1
1
  # Generated by jeweler
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = %q{easycrumbs}
8
- s.version = "1.1.0"
7
+ s.name = "easycrumbs"
8
+ s.version = "2.0.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Stanis\305\202aw Kolarzowski"]
12
- s.date = %q{2010-10-31}
13
- s.description = %q{Easy breadcrumbs for your website}
14
- s.email = %q{stanislaw.kolarzowski@gmail.com}
11
+ s.authors = ["Stanis\u{142}aw Kolarzowski"]
12
+ s.date = "2012-04-23"
13
+ s.description = "Easy breadcrumbs for your website"
14
+ s.email = "stanislaw.kolarzowski@gmail.com"
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE",
17
- "README.rdoc"
17
+ "README.rdoc"
18
18
  ]
19
19
  s.files = [
20
20
  ".document",
21
- ".gitignore",
22
- "LICENSE",
23
- "README.rdoc",
24
- "Rakefile",
25
- "VERSION",
26
- "easycrumbs.gemspec",
27
- "lib/easycrumbs.rb",
28
- "lib/easycrumbs/breadcrumb.rb",
29
- "lib/easycrumbs/collection.rb",
30
- "lib/easycrumbs/errors.rb",
31
- "lib/easycrumbs/view_helpers.rb",
32
- "test/helper.rb",
33
- "test/routes.rb",
34
- "test/test_custom_collection.rb",
35
- "test/test_easycrumbs.rb"
21
+ "Gemfile",
22
+ "Gemfile.lock",
23
+ "LICENSE",
24
+ "README.rdoc",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "easycrumbs.gemspec",
28
+ "lib/easycrumbs.rb",
29
+ "lib/easycrumbs/breadcrumb.rb",
30
+ "lib/easycrumbs/collection.rb",
31
+ "lib/easycrumbs/errors.rb",
32
+ "lib/easycrumbs/view_helpers.rb",
33
+ "test/helper.rb",
34
+ "test/routes.rb",
35
+ "test/support/helpers/actors_helper.rb",
36
+ "test/support/helpers/application_helper.rb",
37
+ "test/support/helpers/countries_helper.rb",
38
+ "test/support/helpers/movies_helper.rb",
39
+ "test/support/stub_request.rb",
40
+ "test/test_custom_collection.rb",
41
+ "test/test_easycrumbs.rb"
36
42
  ]
37
- s.homepage = %q{http://github.com/staszek/easycrumbs}
38
- s.rdoc_options = ["--charset=UTF-8"]
43
+ s.homepage = "http://github.com/staszek/easycrumbs"
39
44
  s.require_paths = ["lib"]
40
- s.rubygems_version = %q{1.3.7}
41
- s.summary = %q{Easy breadcrumbs}
45
+ s.rubygems_version = "1.8.10"
46
+ s.summary = "Easy breadcrumbs"
42
47
  s.test_files = [
43
48
  "test/helper.rb",
44
- "test/routes.rb",
45
- "test/test_custom_collection.rb",
46
- "test/test_easycrumbs.rb"
49
+ "test/routes.rb",
50
+ "test/support/helpers/actors_helper.rb",
51
+ "test/support/helpers/application_helper.rb",
52
+ "test/support/helpers/countries_helper.rb",
53
+ "test/support/helpers/movies_helper.rb",
54
+ "test/support/stub_request.rb",
55
+ "test/test_custom_collection.rb",
56
+ "test/test_easycrumbs.rb"
47
57
  ]
48
58
 
49
59
  if s.respond_to? :specification_version then
50
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
51
60
  s.specification_version = 3
52
61
 
53
62
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
63
+ s.add_runtime_dependency(%q<rails>, ["~> 3.2.0"])
64
+ s.add_development_dependency(%q<mocha>, ["= 0.9.12"])
65
+ s.add_development_dependency(%q<shoulda>, ["= 2.11.3"])
66
+ s.add_development_dependency(%q<jeweler>, ["= 1.5.2"])
67
+ s.add_development_dependency(%q<sqlite3>, [">= 0"])
54
68
  s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
55
69
  else
70
+ s.add_dependency(%q<rails>, ["~> 3.2.0"])
71
+ s.add_dependency(%q<mocha>, ["= 0.9.12"])
72
+ s.add_dependency(%q<shoulda>, ["= 2.11.3"])
73
+ s.add_dependency(%q<jeweler>, ["= 1.5.2"])
74
+ s.add_dependency(%q<sqlite3>, [">= 0"])
56
75
  s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
57
76
  end
58
77
  else
78
+ s.add_dependency(%q<rails>, ["~> 3.2.0"])
79
+ s.add_dependency(%q<mocha>, ["= 0.9.12"])
80
+ s.add_dependency(%q<shoulda>, ["= 2.11.3"])
81
+ s.add_dependency(%q<jeweler>, ["= 1.5.2"])
82
+ s.add_dependency(%q<sqlite3>, [">= 0"])
59
83
  s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
60
84
  end
61
85
  end
@@ -88,15 +88,15 @@ module EasyCrumbs
88
88
  i18n == true ? I18n.t("breadcrumbs.actions.#{action}", :name => name) : "#{action.titlecase} #{name}"
89
89
  end
90
90
 
91
- # Set path using hash from ActionController::Routing::Routes.recognize_path
91
+ # Set path using hash from Rails.application.routes.recognize_path
92
92
  # Example looks like:
93
93
  # {:country_id => "1", :movie_id => "1", :id => "1", :action => "show", :controller => "movies"}
94
94
  def set_path(path, blank_links)
95
- path.nil? || path.empty? ? "/" : ActionController::Routing::Routes.generate_extras(path).first
95
+ path.nil? || path.empty? ? "/" : Rails.application.routes.generate_extras(path).first
96
96
  rescue ActionController::RoutingError => e
97
97
  raise EasyCrumbs::NoPath.new(e.message) unless blank_links == true
98
98
  nil
99
99
  end
100
100
 
101
101
  end
102
- end
102
+ end
@@ -16,10 +16,8 @@ module EasyCrumbs
16
16
 
17
17
  # Finding route with given path and method
18
18
  # Return ActionController:Routing::Route object
19
- def find_route
20
- routes = ActionController::Routing::Routes.routes.select do |route|
21
- route.recognize(request_path, :method => request_method) != nil
22
- end
19
+ def find_route(request = @request)
20
+ routes = Rails.application.routes.router.send(:find_routes, request.env)
23
21
  raise EasyCrumbs::NotRecognized if routes.empty?
24
22
  routes.first
25
23
  end
@@ -28,40 +26,72 @@ module EasyCrumbs
28
26
  # for example:
29
27
  # { :controller => 'movies', :action => 'show', :country_id => '23', :id => '12' }
30
28
  def find_path
31
- @route.recognize(request_path, :method => request_method)
29
+ #@route.recognize(request_path, :method => request_method)
30
+ @route.second
32
31
  end
33
32
 
34
33
  # Select only static and dynamic segments from route. Static segments points at controllers and dynamic points at models.
35
34
  # It is given in right order
36
35
  # If last segment is equal to member action then it should be deleted. for example movies/123/edit should not return "edit" segment
37
36
  def segments
38
- segments = @route.segments.select do |segment|
39
- [ActionController::Routing::DynamicSegment, ActionController::Routing::StaticSegment].include? segment.class
37
+ #segments = @route.segments.select do |segment|
38
+ # [ActionController::Routing::DynamicSegment, ActionController::Routing::StaticSegment].include? segment.class
39
+ #end
40
+ #segments.pop if segments.last.is_a?(ActionController::Routing::StaticSegment) && segments.last.value == @action && segments.last.value != 'new'
41
+ #segments
42
+ resolve_segments
43
+ end
44
+
45
+ # Return array of dynamic segments
46
+ # for example
47
+ # [ :country_id, :dynamic], [:movie_id, :dynamic], [:id, :dynamic] ]
48
+ def dynamic_segments
49
+ @route.third.path.names.map do |segment|
50
+ [segment.to_sym, :dynamic]
51
+ end
52
+ end
53
+
54
+ # Return array of all segments with :static and :dynamic annotation
55
+ # for examle:
56
+ # [[:countries, :static], [:country_id, :dynamic], [:movies, :static], [:movie_id, :dynamic], [:actors, :static] ]
57
+ def resolve_segments
58
+ @route.third.path.spec.to_s.split(/[\/(\)\.]/).map do |segment|
59
+ [segment.delete(":").to_sym, :static] unless segment.blank?
60
+ end.compact.map do |segment|
61
+ if dynamic_segments.map(&:first).include? segment.first
62
+ [segment.first, :dynamic]
63
+ else
64
+ segment
65
+ end
40
66
  end
41
- segments.pop if segments.last.is_a?(ActionController::Routing::StaticSegment) && segments.last.value == @action && segments.last.value != 'new'
42
- segments
43
67
  end
44
68
 
45
69
  # Returning controller object from static segment
46
70
  def pick_controller(segment)
47
- segment = last_controller_segment if segment.value == "new"
48
- "#{segment.value.titlecase}Controller".constantize.new
71
+ #segment = last_controller_segment if segment.value == "new"
72
+ #"#{segment.value.titlecase}Controller".constantize.new
73
+ segment = last_controller_segment if segment.first == :new
74
+ "#{segment.first.to_s.titlecase}Controller".constantize.new rescue nil
49
75
  end
50
76
 
51
77
  # Returns last controller segment in segments
52
78
  def last_controller_segment
53
- segments.select{ |seg| seg.is_a?(ActionController::Routing::StaticSegment) && seg.value != "new"}.last
79
+ #segments.select{ |seg| seg.is_a?(ActionController::Routing::StaticSegment) && seg.value != "new"}.last
80
+ segments.select{ |seg| seg.second == :static && seg.first != :new }.last
54
81
  end
55
82
 
56
83
  # Retrung model object from dynamic segment
57
84
  # If key has not model name then it is taken from current controller(it is taken from path)
58
85
  def pick_model(segment)
59
- key = segment.key
86
+ key = segment.first
60
87
  if key == :id
61
88
  model = @controller.singularize
62
- else
89
+ elsif key.to_s.include?("_id")
63
90
  model = key.to_s[0..-4] # model_id without last 3 signs = model
91
+ else
92
+ return nil
64
93
  end
94
+
65
95
  model = model.titlecase.constantize
66
96
  model.find(@path[key])
67
97
  end
@@ -71,12 +101,12 @@ module EasyCrumbs
71
101
  # [#<CountriesController:0x001>, #<Country:0x001 @name="usa">, #<MoviesController:0x001>, #<Movie:0x001 @name="titanic">]
72
102
  def objects
73
103
  segments.map do |segment|
74
- if segment.is_a? ActionController::Routing::DynamicSegment
104
+ if segment.second == :dynamic
75
105
  pick_model(segment)
76
106
  else
77
107
  pick_controller(segment)
78
108
  end
79
- end
109
+ end.compact
80
110
  end
81
111
 
82
112
  # Return array of breadcrumbs object in right order
@@ -92,23 +122,23 @@ module EasyCrumbs
92
122
 
93
123
  # Retrurn parameters for path of model
94
124
  # If it is last object then action is equal to request action
95
- def path_for_model(segment)
96
- key = segment.key
97
- if key == :id
98
- {:action => @action, :id => @path[key]}
99
- else
100
- {:action => 'show', key => @path[key]}
101
- end
102
- end
125
+ #def path_for_model(segment)
126
+ # key = segment.value
127
+ # if key == :id
128
+ # {:action => @action, :id => @path[key]}
129
+ # else
130
+ # {:action => 'show', key => @path[key]}
131
+ # end
132
+ #end
103
133
 
104
134
  # Retrun parameters for path of controller
105
- def path_for_controller(segment)
106
- if segment.value == "new"
107
- {:action => "new", :controller => last_controller_segment.value}
108
- else
109
- {:action => 'index', :controller => segment.value}
110
- end
111
- end
135
+ #def path_for_controller(segment)
136
+ # if segment.value == "new"
137
+ # {:action => "new", :controller => last_controller_segment.value}
138
+ # else
139
+ # {:action => 'index', :controller => segment.value}
140
+ # end
141
+ #end
112
142
 
113
143
  # If controller name is connected with object then parameter should be :id instead of :object_id
114
144
  # {:controller => 'movies', :movie_id => 1} will be {:controller => 'movies', :id => 1}
@@ -130,16 +160,28 @@ module EasyCrumbs
130
160
  # {:action => 'index', :controller => 'actors', :country_id => 1, :movie_id => 2},
131
161
  # {:action => 'update', :controller => 'actors', :country_id => 1, :movie_id => 2, :id => 3}
132
162
  def make_pathes
133
- path = {}
134
- segments.map do |segment|
135
- if segment.is_a? ActionController::Routing::DynamicSegment
136
- path.merge! path_for_model(segment)
137
- result = repaired_model_path(path)
138
- else
139
- result = path.merge! path_for_controller(segment)
140
- end
141
- result.dup
163
+ #path = {}
164
+ #segments.map do |segment|
165
+ # if segment.is_a? ActionController::Routing::DynamicSegment
166
+ # path.merge! path_for_model(segment)
167
+ # result = repaired_model_path(path)
168
+ # else
169
+ # result = path.merge! path_for_controller(segment)
170
+ # end
171
+ # result.dup
172
+ #end
173
+ result = []
174
+ @route.first.to_s.split("/")[1...-1].inject([]) do |current_path, segment|
175
+ current_path << segment
176
+ request = ActionDispatch::Request.new("PATH_INFO" => "/#{current_path.join("/")}",
177
+ "REQUEST_METHOD" => "GET")
178
+
179
+ result << (find_route(request).second rescue nil)
180
+
181
+ current_path
142
182
  end
183
+
184
+ (result << @route.second).compact
143
185
  end
144
186
 
145
187
  def render(options = {})
@@ -1,14 +1,15 @@
1
- require 'rubygems'
2
1
  require 'test/unit'
3
2
  require 'shoulda'
4
3
  require "mocha"
5
- require 'active_record'
6
- require "action_view"
4
+ require "rails"
5
+ require "active_record"
7
6
  require "action_controller"
8
7
  require "routes"
9
8
 
10
9
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
10
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), 'support', 'helpers'))
11
11
  $LOAD_PATH.unshift(File.dirname(__FILE__))
12
+ require 'support/stub_request'
12
13
  require 'easycrumbs'
13
14
 
14
15
  ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:")
@@ -1,9 +1,12 @@
1
- ActionController::Routing::Routes.draw do |map|
2
-
3
- map.resources :countries do |country|
4
- country.resources :movies do |movie|
5
- movie.resources :actors
1
+ module EasyCrumbs
2
+ class Application < ::Rails::Application
3
+ end
4
+ end
5
+
6
+ EasyCrumbs::Application.routes.draw do
7
+ resources :countries do
8
+ resources :movies do
9
+ resources :actors
6
10
  end
7
11
  end
8
-
9
- end
12
+ end
File without changes
File without changes
@@ -0,0 +1,4 @@
1
+ def stub_request(path="/", method=:get)
2
+ ActionDispatch::TestRequest.new("PATH_INFO" => path,
3
+ "REQUEST_METHOD" => method.to_s.upcase)
4
+ end
@@ -132,17 +132,17 @@ class TestEasycrumbs < Test::Unit::TestCase
132
132
  context "Collection" do
133
133
  setup do
134
134
  Collection.any_instance.stubs(:request_path => "/countries/#{@usa.id}/movies/#{@titanic.id}/actors/#{@leo.id}", :request_method => :put)
135
- @collection = Collection.new("request object")
135
+ @collection = Collection.new(stub_request("/countries/#{@usa.id}/movies/#{@titanic.id}/actors/#{@leo.id}", :put))
136
136
  end
137
137
 
138
138
  context "finding route" do
139
139
  should "return route if it can find it" do
140
- assert_equal(ActionController::Routing::Route, @collection.route.class)
140
+ assert_equal(Journey::Route, @collection.route.third.class)
141
141
  end
142
142
 
143
143
  should "raise error when it can not find route" do
144
144
  assert_raise(EasyCrumbs::NotRecognized) do
145
- @collection.stubs(:request_path => "/countres/1/videos/1")
145
+ @collection = Collection.new(stub_request("/countres/1/videos/"))
146
146
  @collection.find_route
147
147
  end
148
148
  end
@@ -157,61 +157,63 @@ class TestEasycrumbs < Test::Unit::TestCase
157
157
  context "selecting right segments" do
158
158
  should "select only static and dynamic segments" do
159
159
  results = @collection.segments
160
- results = results.map(&:class).uniq
161
- results.delete(ActionController::Routing::StaticSegment)
162
- results.delete(ActionController::Routing::DynamicSegment)
160
+ results = results.map(&:second).uniq
161
+ results.delete(:static)
162
+ results.delete(:dynamic)
163
163
  assert_equal(true, results.empty?)
164
164
  end
165
165
 
166
166
  should "return proper segments for member action" do
167
- Collection.any_instance.stubs(:request_path => "/countries/#{@usa.id}/movies/#{@titanic.id}/actors/#{@leo.id}/edit", :request_method => :get)
168
- collection = Collection.new("request object")
169
- assert_equal(6, collection.segments.size)
167
+ #Collection.any_instance.stubs(:request_path => "/countries/#{@usa.id}/movies/#{@titanic.id}/actors/#{@leo.id}/edit", :request_method => :get)
168
+ collection = Collection.new(stub_request("/countries/#{@usa.id}/movies/#{@titanic.id}/actors/#{@leo.id}/edit", :get))
169
+ assert_equal(8, collection.segments.size)
170
170
  end
171
171
 
172
172
  should "return proper segments for new action" do
173
- Collection.any_instance.stubs(:request_path => "/countries/#{@usa.id}/movies/#{@titanic.id}/actors/new", :request_method => :get)
174
- collection = Collection.new("request object")
175
- assert_equal(6, collection.segments.size)
173
+ #Collection.any_instance.stubs(:request_path => "/countries/#{@usa.id}/movies/#{@titanic.id}/actors/new", :request_method => :get)
174
+ collection = Collection.new(stub_request("/countries/#{@usa.id}/movies/#{@titanic.id}/actors/new", :get))
175
+ assert_equal(7, collection.segments.size)
176
176
  end
177
177
  end
178
178
 
179
179
  context "pick_controller" do
180
180
  should "return controller object" do
181
- assert_equal(MoviesController, @collection.pick_controller(ActionController::Routing::StaticSegment.new("movies")).class)
181
+ assert_equal(MoviesController, @collection.pick_controller([:movies, :static]).class)
182
182
  end
183
183
 
184
184
  should "return controller object if action is new" do
185
- assert_equal(ActorsController, @collection.pick_controller(ActionController::Routing::StaticSegment.new("new")).class)
185
+ assert_equal(ActorsController, @collection.pick_controller([:new, :static]).class)
186
186
  end
187
187
  end
188
188
 
189
189
  context "last controller" do
190
190
  should "return last controller object if last segment is dynamic" do
191
- assert_equal("actors", @collection.last_controller_segment.value)
191
+ assert_equal(:actors, @collection.last_controller_segment.first)
192
192
  end
193
193
 
194
194
  should "return last controller object if last segment is static" do
195
- Collection.any_instance.stubs(:request_path => "/countries/#{@usa.id}/movies/#{@titanic.id}/actors", :request_method => :get)
196
- collection = Collection.new("request object")
197
- assert_equal("actors", collection.last_controller_segment.value)
195
+ #Collection.any_instance.stubs(:request_path => "/countries/#{@usa.id}/movies/#{@titanic.id}/actors", :request_method => :get)
196
+ collection = Collection.new(stub_request("/countries/#{@usa.id}/movies/#{@titanic.id}/actors", :get))
197
+ assert_equal(:actors, collection.last_controller_segment.first)
198
198
  end
199
199
 
200
200
  should "return last controller object if last segment is new action" do
201
- Collection.any_instance.stubs(:request_path => "/countries/#{@usa.id}/movies/#{@titanic.id}/actors/new", :request_method => :get)
202
- collection = Collection.new("request object")
203
- assert_equal("actors", collection.last_controller_segment.value)
201
+ #Collection.any_instance.stubs(:request_path => "/countries/#{@usa.id}/movies/#{@titanic.id}/actors/new", :request_method => :get)
202
+ collection = Collection.new(stub_request("/countries/#{@usa.id}/movies/#{@titanic.id}/actors/new", :get))
203
+ assert_equal(:actors, collection.last_controller_segment.first)
204
204
  end
205
205
  end
206
206
 
207
207
  context "pick_model" do
208
208
  should "return model object when key has model name" do
209
- segment = ActionController::Routing::DynamicSegment.new(:movie_id)
209
+ #segment = ActionController::Routing::DynamicSegment.new(:movie_id)
210
+ segment = [:movie_id, :dynamic]
210
211
  assert_equal(@titanic, @collection.pick_model(segment))
211
212
  end
212
213
 
213
214
  should "return model object when key has not model name"do
214
- segment = ActionController::Routing::DynamicSegment.new(:id)
215
+ #segment = ActionController::Routing::DynamicSegment.new(:id)
216
+ segment = [:id, :dynamic]
215
217
  assert_equal(@leo, @collection.pick_model(segment))
216
218
  end
217
219
  end
@@ -222,29 +224,29 @@ class TestEasycrumbs < Test::Unit::TestCase
222
224
  end
223
225
  end
224
226
 
225
- context "path_for_model" do
226
- should "return id and current action for last object" do
227
- segment = ActionController::Routing::DynamicSegment.new(:id)
228
- assert_equal({:action => 'update', :id => @leo.id.to_s}, @collection.path_for_model(segment))
229
- end
230
-
231
- should "return show action and object id for not last object" do
232
- segment = ActionController::Routing::DynamicSegment.new(:movie_id)
233
- assert_equal({:action => 'show', :movie_id => @titanic.id.to_s}, @collection.path_for_model(segment))
234
- end
235
- end
236
-
237
- context "path_for_controller" do
238
- should "return index action and controller name" do
239
- segment = ActionController::Routing::StaticSegment.new("movies")
240
- assert_equal({:action => 'index', :controller => 'movies'}, @collection.path_for_controller(segment))
241
- end
242
-
243
- should "return new action and controller name for new action segment" do
244
- segment = ActionController::Routing::StaticSegment.new("new")
245
- assert_equal({:action => 'new', :controller => 'actors'}, @collection.path_for_controller(segment))
246
- end
247
- end
227
+ #context "path_for_model" do
228
+ # should "return id and current action for last object" do
229
+ # segment = ActionController::Routing::DynamicSegment.new(:id)
230
+ # assert_equal({:action => 'update', :id => @leo.id.to_s}, @collection.path_for_model(segment))
231
+ # end
232
+ #
233
+ # should "return show action and object id for not last object" do
234
+ # segment = ActionController::Routing::DynamicSegment.new(:movie_id)
235
+ # assert_equal({:action => 'show', :movie_id => @titanic.id.to_s}, @collection.path_for_model(segment))
236
+ # end
237
+ #end
238
+
239
+ #context "path_for_controller" do
240
+ # should "return index action and controller name" do
241
+ # segment = ActionController::Routing::StaticSegment.new("movies")
242
+ # assert_equal({:action => 'index', :controller => 'movies'}, @collection.path_for_controller(segment))
243
+ # end
244
+ #
245
+ # should "return new action and controller name for new action segment" do
246
+ # segment = ActionController::Routing::StaticSegment.new("new")
247
+ # assert_equal({:action => 'new', :controller => 'actors'}, @collection.path_for_controller(segment))
248
+ # end
249
+ #end
248
250
 
249
251
  context "repaired_model_path" do
250
252
  should "return repaired path if model is connected with controller" do
@@ -271,8 +273,8 @@ class TestEasycrumbs < Test::Unit::TestCase
271
273
  end
272
274
 
273
275
  should "return patches array for objects for new action" do
274
- Collection.any_instance.stubs(:request_path => "/countries/#{@usa.id}/movies/#{@titanic.id}/actors/new", :request_method => :get)
275
- collection = Collection.new("request_object")
276
+ #Collection.any_instance.stubs(:request_path => "/countries/#{@usa.id}/movies/#{@titanic.id}/actors/new", :request_method => :get)
277
+ collection = Collection.new(stub_request("/countries/#{@usa.id}/movies/#{@titanic.id}/actors/new", :get))
276
278
  assert_equal([
277
279
  {:action => 'index', :controller => 'countries'},
278
280
  {:action => 'show', :controller => 'countries', :id => @usa.id.to_s},
@@ -291,7 +293,7 @@ class TestEasycrumbs < Test::Unit::TestCase
291
293
 
292
294
  should "return array of breadcrumbs objects" do
293
295
  assert_equal(@collection.objects.size + 1, @results.size)
294
- @results.map.uniq == [EasyCrumbs::Breadcrumb]
296
+ @results.uniq == [EasyCrumbs::Breadcrumb]
295
297
  end
296
298
 
297
299
  should "last breadcrumb have name with action prefix" do
metadata CHANGED
@@ -1,49 +1,93 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: easycrumbs
3
- version: !ruby/object:Gem::Version
4
- hash: 19
5
- prerelease: false
6
- segments:
7
- - 1
8
- - 1
9
- - 0
10
- version: 1.1.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.0.0
5
+ prerelease:
11
6
  platform: ruby
12
- authors:
13
- - "Stanis\xC5\x82aw Kolarzowski"
7
+ authors:
8
+ - Stanisław Kolarzowski
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2010-10-31 00:00:00 +02:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
22
- name: thoughtbot-shoulda
12
+ date: 2012-04-23 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rails
16
+ requirement: &2174258960 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 3.2.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *2174258960
25
+ - !ruby/object:Gem::Dependency
26
+ name: mocha
27
+ requirement: &2174258320 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - =
31
+ - !ruby/object:Gem::Version
32
+ version: 0.9.12
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *2174258320
36
+ - !ruby/object:Gem::Dependency
37
+ name: shoulda
38
+ requirement: &2174257540 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - =
42
+ - !ruby/object:Gem::Version
43
+ version: 2.11.3
44
+ type: :development
23
45
  prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
46
+ version_requirements: *2174257540
47
+ - !ruby/object:Gem::Dependency
48
+ name: jeweler
49
+ requirement: &2174256760 !ruby/object:Gem::Requirement
25
50
  none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 3
30
- segments:
31
- - 0
32
- version: "0"
51
+ requirements:
52
+ - - =
53
+ - !ruby/object:Gem::Version
54
+ version: 1.5.2
33
55
  type: :development
34
- version_requirements: *id001
56
+ prerelease: false
57
+ version_requirements: *2174256760
58
+ - !ruby/object:Gem::Dependency
59
+ name: sqlite3
60
+ requirement: &2174256060 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *2174256060
69
+ - !ruby/object:Gem::Dependency
70
+ name: thoughtbot-shoulda
71
+ requirement: &2174255340 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *2174255340
35
80
  description: Easy breadcrumbs for your website
36
81
  email: stanislaw.kolarzowski@gmail.com
37
82
  executables: []
38
-
39
83
  extensions: []
40
-
41
- extra_rdoc_files:
84
+ extra_rdoc_files:
42
85
  - LICENSE
43
86
  - README.rdoc
44
- files:
87
+ files:
45
88
  - .document
46
- - .gitignore
89
+ - Gemfile
90
+ - Gemfile.lock
47
91
  - LICENSE
48
92
  - README.rdoc
49
93
  - Rakefile
@@ -56,44 +100,47 @@ files:
56
100
  - lib/easycrumbs/view_helpers.rb
57
101
  - test/helper.rb
58
102
  - test/routes.rb
103
+ - test/support/helpers/actors_helper.rb
104
+ - test/support/helpers/application_helper.rb
105
+ - test/support/helpers/countries_helper.rb
106
+ - test/support/helpers/movies_helper.rb
107
+ - test/support/stub_request.rb
59
108
  - test/test_custom_collection.rb
60
109
  - test/test_easycrumbs.rb
61
- has_rdoc: true
62
110
  homepage: http://github.com/staszek/easycrumbs
63
111
  licenses: []
64
-
65
112
  post_install_message:
66
- rdoc_options:
67
- - --charset=UTF-8
68
- require_paths:
113
+ rdoc_options: []
114
+ require_paths:
69
115
  - lib
70
- required_ruby_version: !ruby/object:Gem::Requirement
116
+ required_ruby_version: !ruby/object:Gem::Requirement
71
117
  none: false
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- hash: 3
76
- segments:
118
+ requirements:
119
+ - - ! '>='
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ segments:
77
123
  - 0
78
- version: "0"
79
- required_rubygems_version: !ruby/object:Gem::Requirement
124
+ hash: -899090780415789417
125
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
126
  none: false
81
- requirements:
82
- - - ">="
83
- - !ruby/object:Gem::Version
84
- hash: 3
85
- segments:
86
- - 0
87
- version: "0"
127
+ requirements:
128
+ - - ! '>='
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
88
131
  requirements: []
89
-
90
132
  rubyforge_project:
91
- rubygems_version: 1.3.7
133
+ rubygems_version: 1.8.10
92
134
  signing_key:
93
135
  specification_version: 3
94
136
  summary: Easy breadcrumbs
95
- test_files:
137
+ test_files:
96
138
  - test/helper.rb
97
139
  - test/routes.rb
140
+ - test/support/helpers/actors_helper.rb
141
+ - test/support/helpers/application_helper.rb
142
+ - test/support/helpers/countries_helper.rb
143
+ - test/support/helpers/movies_helper.rb
144
+ - test/support/stub_request.rb
98
145
  - test/test_custom_collection.rb
99
146
  - test/test_easycrumbs.rb
data/.gitignore DELETED
@@ -1,21 +0,0 @@
1
- ## MAC OS
2
- .DS_Store
3
-
4
- ## TEXTMATE
5
- *.tmproj
6
- tmtags
7
-
8
- ## EMACS
9
- *~
10
- \#*
11
- .\#*
12
-
13
- ## VIM
14
- *.swp
15
-
16
- ## PROJECT::GENERAL
17
- coverage
18
- rdoc
19
- pkg
20
-
21
- ## PROJECT::SPECIFIC