crumbs 1.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +31 -0
  4. data/Rakefile +32 -0
  5. data/lib/crumbs/action_controller/base.rb +120 -0
  6. data/lib/crumbs/history.rb +31 -0
  7. data/lib/crumbs/railtie.rb +12 -0
  8. data/lib/crumbs/version.rb +5 -0
  9. data/lib/crumbs.rb +8 -0
  10. data/test/dummy/README.rdoc +28 -0
  11. data/test/dummy/Rakefile +6 -0
  12. data/test/dummy/app/assets/javascripts/application.js +13 -0
  13. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  14. data/test/dummy/app/controllers/application_controller.rb +5 -0
  15. data/test/dummy/app/controllers/pages_controller.rb +33 -0
  16. data/test/dummy/app/helpers/application_helper.rb +2 -0
  17. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  18. data/test/dummy/app/views/pages/crumbs.html.erb +3 -0
  19. data/test/dummy/bin/bundle +3 -0
  20. data/test/dummy/bin/rails +4 -0
  21. data/test/dummy/bin/rake +4 -0
  22. data/test/dummy/config/application.rb +23 -0
  23. data/test/dummy/config/boot.rb +5 -0
  24. data/test/dummy/config/database.yml +25 -0
  25. data/test/dummy/config/environment.rb +5 -0
  26. data/test/dummy/config/environments/development.rb +29 -0
  27. data/test/dummy/config/environments/production.rb +80 -0
  28. data/test/dummy/config/environments/test.rb +36 -0
  29. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  30. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  31. data/test/dummy/config/initializers/inflections.rb +16 -0
  32. data/test/dummy/config/initializers/mime_types.rb +5 -0
  33. data/test/dummy/config/initializers/secret_token.rb +12 -0
  34. data/test/dummy/config/initializers/session_store.rb +3 -0
  35. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  36. data/test/dummy/config/locales/en.yml +23 -0
  37. data/test/dummy/config/routes.rb +72 -0
  38. data/test/dummy/config.ru +4 -0
  39. data/test/dummy/db/development.sqlite3 +0 -0
  40. data/test/dummy/db/schema.rb +16 -0
  41. data/test/dummy/db/test.sqlite3 +0 -0
  42. data/test/dummy/log/development.log +7 -0
  43. data/test/dummy/log/test.log +788 -0
  44. data/test/dummy/public/404.html +58 -0
  45. data/test/dummy/public/422.html +58 -0
  46. data/test/dummy/public/500.html +57 -0
  47. data/test/dummy/public/favicon.ico +0 -0
  48. data/test/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  49. data/test/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  50. data/test/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  51. data/test/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  52. data/test/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  53. data/test/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  54. data/test/test_helper.rb +21 -0
  55. data/test/with_last_test.rb +264 -0
  56. data/test/without_last_test.rb +249 -0
  57. metadata +174 -0
@@ -0,0 +1,249 @@
1
+ require 'test_helper'
2
+
3
+ class WithoutLastTest < ActionDispatch::IntegrationTest
4
+
5
+ setup do
6
+ Rails.application.config.crumbs.show_last = false
7
+ end
8
+
9
+ test "should remember last requests in the same path" do
10
+ get '/'
11
+ assert_equal [
12
+ { base_url: 'http://www.example.com', path: '/', fullpath: '/' }
13
+ ], session[:referer]
14
+ assert_select 'a', false
15
+
16
+ get '/static'
17
+ assert_equal [
18
+ { base_url: 'http://www.example.com', path: '/', fullpath: '/' },
19
+ { base_url: 'http://www.example.com', path: '/static', fullpath: '/static' }
20
+ ], session[:referer]
21
+ assert_select 'a', count: 1
22
+ assert_select 'a[href="/"]', 'Home'
23
+
24
+ get '/static/nested'
25
+ assert_equal [
26
+ { base_url: 'http://www.example.com', path: '/', fullpath: '/' },
27
+ { base_url: 'http://www.example.com', path: '/static', fullpath: '/static' },
28
+ { base_url: 'http://www.example.com', path: '/static/nested', fullpath: '/static/nested' }
29
+ ], session[:referer]
30
+ assert_select 'a', count: 2
31
+ assert_select 'a[href="/"]', 'Home'
32
+ assert_select 'a[href="/static"]', 'Static'
33
+
34
+ get '/'
35
+ assert_equal [
36
+ { base_url: 'http://www.example.com', path: '/', fullpath: '/' }
37
+ ], session[:referer]
38
+ assert_select 'a', false
39
+ end
40
+
41
+ test "should remember last request with parameters in the same path" do
42
+ get '/?p1=p1'
43
+ assert_equal [
44
+ { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' }
45
+ ], session[:referer]
46
+ assert_select 'a', false
47
+
48
+ get '/static?p2=p2'
49
+ assert_equal [
50
+ { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' },
51
+ { base_url: 'http://www.example.com', path: '/static', fullpath: '/static?p2=p2' }
52
+ ], session[:referer]
53
+ assert_select 'a', count: 1
54
+ assert_select 'a[href="/?p1=p1"]', 'Home'
55
+
56
+ get '/static/nested?p3=p3'
57
+ assert_equal [
58
+ { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' },
59
+ { base_url: 'http://www.example.com', path: '/static', fullpath: '/static?p2=p2' },
60
+ { base_url: 'http://www.example.com', path: '/static/nested', fullpath: '/static/nested?p3=p3' }
61
+ ], session[:referer]
62
+ assert_select 'a', count: 2
63
+ assert_select 'a[href="/?p1=p1"]', 'Home'
64
+ assert_select 'a[href="/static?p2=p2"]', 'Static'
65
+
66
+ get '/'
67
+ assert_equal [
68
+ { base_url: 'http://www.example.com', path: '/', fullpath: '/' }
69
+ ], session[:referer]
70
+ assert_select 'a', false
71
+ end
72
+
73
+ test "gaps shouldn't cause any error and should generate crumbs either" do
74
+ get '/?p1=p1'
75
+ assert_equal [
76
+ { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' }
77
+ ], session[:referer]
78
+ assert_select 'a', false
79
+
80
+ get '/static/nested?p3=p3'
81
+ assert_equal [
82
+ { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' },
83
+ { base_url: 'http://www.example.com', path: '/static/nested', fullpath: '/static/nested?p3=p3' }
84
+ ], session[:referer]
85
+ assert_select 'a', count: 2
86
+ assert_select 'a[href="/?p1=p1"]', 'Home'
87
+ assert_select 'a[href="/static"]', 'Static'
88
+
89
+ get '/'
90
+ assert_equal [
91
+ { base_url: 'http://www.example.com', path: '/', fullpath: '/' }
92
+ ], session[:referer]
93
+ assert_select 'a', false
94
+ end
95
+
96
+ test "empty crumbs shouldn't cause any error and should't generate crumbs" do
97
+ get '/?p1=p1'
98
+ assert_equal [
99
+ { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' }
100
+ ], session[:referer]
101
+ assert_select 'a', false
102
+
103
+ get '/empty?p2=p2'
104
+ assert_equal [
105
+ { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' },
106
+ { base_url: 'http://www.example.com', path: '/empty', fullpath: '/empty?p2=p2' }
107
+ ], session[:referer]
108
+ assert_select 'a', count: 1
109
+ assert_select 'a[href="/?p1=p1"]', 'Home'
110
+
111
+ get '/empty/nested?p3=p3'
112
+ assert_equal [
113
+ { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' },
114
+ { base_url: 'http://www.example.com', path: '/empty', fullpath: '/empty?p2=p2' },
115
+ { base_url: 'http://www.example.com', path: '/empty/nested', fullpath: '/empty/nested?p3=p3' }
116
+ ], session[:referer]
117
+ assert_select 'a', count: 1
118
+ assert_select 'a[href="/?p1=p1"]', 'Home'
119
+
120
+ get '/'
121
+ assert_equal [
122
+ { base_url: 'http://www.example.com', path: '/', fullpath: '/' }
123
+ ], session[:referer]
124
+ assert_select 'a', false
125
+ end
126
+
127
+ test "params shouldn't cause any error and can be use alter crumb name" do
128
+ get '/?p1=p1'
129
+ assert_equal [
130
+ { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' }
131
+ ], session[:referer]
132
+ assert_select 'a', false
133
+
134
+ get '/param?p2=p2'
135
+ assert_equal [
136
+ { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' },
137
+ { base_url: 'http://www.example.com', path: '/param', fullpath: '/param?p2=p2' }
138
+ ], session[:referer]
139
+ assert_select 'a', count: 1
140
+ assert_select 'a[href="/?p1=p1"]', 'Home'
141
+
142
+ get '/param/1?p3=p3'
143
+ assert_equal [
144
+ { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' },
145
+ { base_url: 'http://www.example.com', path: '/param', fullpath: '/param?p2=p2' },
146
+ { base_url: 'http://www.example.com', path: '/param/1', fullpath: '/param/1?p3=p3' }
147
+ ], session[:referer]
148
+ assert_select 'a', count: 2
149
+ assert_select 'a[href="/?p1=p1"]', 'Home'
150
+ assert_select 'a[href="/param?p2=p2"]', ''
151
+
152
+ get '/param/1/nested?p4=p4'
153
+ assert_equal [
154
+ { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' },
155
+ { base_url: 'http://www.example.com', path: '/param', fullpath: '/param?p2=p2' },
156
+ { base_url: 'http://www.example.com', path: '/param/1', fullpath: '/param/1?p3=p3' },
157
+ { base_url: 'http://www.example.com', path: '/param/1/nested', fullpath: '/param/1/nested?p4=p4' }
158
+ ], session[:referer]
159
+ assert_select 'a', count: 3
160
+ assert_select 'a[href="/?p1=p1"]', 'Home'
161
+ assert_select 'a[href="/param?p2=p2"]', ''
162
+ assert_select 'a[href="/param/1?p3=p3"]', '1'
163
+
164
+ get '/'
165
+ assert_equal [
166
+ { base_url: 'http://www.example.com', path: '/', fullpath: '/' }
167
+ ], session[:referer]
168
+ assert_select 'a', false
169
+ end
170
+
171
+ test "going back shouldn't cause any error and should retain history" do
172
+ get '/?p1=p1'
173
+ assert_equal [
174
+ { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' }
175
+ ], session[:referer]
176
+ assert_select 'a', false
177
+
178
+ get '/param?p2=p2'
179
+ assert_equal [
180
+ { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' },
181
+ { base_url: 'http://www.example.com', path: '/param', fullpath: '/param?p2=p2' }
182
+ ], session[:referer]
183
+ assert_select 'a', count: 1
184
+ assert_select 'a[href="/?p1=p1"]', 'Home'
185
+
186
+ get '/param/1?p3=p3'
187
+ assert_equal [
188
+ { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' },
189
+ { base_url: 'http://www.example.com', path: '/param', fullpath: '/param?p2=p2' },
190
+ { base_url: 'http://www.example.com', path: '/param/1', fullpath: '/param/1?p3=p3' }
191
+ ], session[:referer]
192
+ assert_select 'a', count: 2
193
+ assert_select 'a[href="/?p1=p1"]', 'Home'
194
+ assert_select 'a[href="/param?p2=p2"]', ''
195
+
196
+ get '/param/1/nested?p4=p4'
197
+ assert_equal [
198
+ { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' },
199
+ { base_url: 'http://www.example.com', path: '/param', fullpath: '/param?p2=p2' },
200
+ { base_url: 'http://www.example.com', path: '/param/1', fullpath: '/param/1?p3=p3' },
201
+ { base_url: 'http://www.example.com', path: '/param/1/nested', fullpath: '/param/1/nested?p4=p4' }
202
+ ], session[:referer]
203
+ assert_select 'a', count: 3
204
+ assert_select 'a[href="/?p1=p1"]', 'Home'
205
+ assert_select 'a[href="/param?p2=p2"]', ''
206
+ assert_select 'a[href="/param/1?p3=p3"]', '1'
207
+
208
+ get '/param'
209
+ assert_equal [
210
+ { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' },
211
+ { base_url: 'http://www.example.com', path: '/param', fullpath: '/param' }
212
+ ], session[:referer]
213
+ assert_select 'a', count: 1
214
+ assert_select 'a[href="/?p1=p1"]', 'Home'
215
+ end
216
+
217
+ test "using t method shouldn't cause any error" do
218
+ get '/?p1=p1'
219
+ assert_equal [
220
+ { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' }
221
+ ], session[:referer]
222
+ assert_select 'a', false
223
+
224
+ get '/i18n?p2=p2'
225
+ assert_equal [
226
+ { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' },
227
+ { base_url: 'http://www.example.com', path: '/i18n', fullpath: '/i18n?p2=p2' }
228
+ ], session[:referer]
229
+ assert_select 'a', count: 1
230
+ assert_select 'a[href="/?p1=p1"]', 'Home'
231
+
232
+ get '/i18n/nested?p3=p3'
233
+ assert_equal [
234
+ { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' },
235
+ { base_url: 'http://www.example.com', path: '/i18n', fullpath: '/i18n?p2=p2' },
236
+ { base_url: 'http://www.example.com', path: '/i18n/nested', fullpath: '/i18n/nested?p3=p3' }
237
+ ], session[:referer]
238
+ assert_select 'a', count: 2
239
+ assert_select 'a[href="/?p1=p1"]', 'Home'
240
+ assert_select 'a[href="/i18n?p2=p2"]', 'Hello world'
241
+
242
+ get '/?p1=p1'
243
+ assert_equal [
244
+ { base_url: 'http://www.example.com', path: '/', fullpath: '/?p1=p1' }
245
+ ], session[:referer]
246
+ assert_select 'a', false
247
+ end
248
+
249
+ end
metadata ADDED
@@ -0,0 +1,174 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: crumbs
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.7
5
+ platform: ruby
6
+ authors:
7
+ - Mattways
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-08-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: 3.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: 3.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: sqlite3
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Adds a handy crumbs variable available in your views.
42
+ email:
43
+ - contact@mattways.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - lib/crumbs/action_controller/base.rb
49
+ - lib/crumbs/history.rb
50
+ - lib/crumbs/railtie.rb
51
+ - lib/crumbs/version.rb
52
+ - lib/crumbs.rb
53
+ - MIT-LICENSE
54
+ - Rakefile
55
+ - README.rdoc
56
+ - test/dummy/app/assets/javascripts/application.js
57
+ - test/dummy/app/assets/stylesheets/application.css
58
+ - test/dummy/app/controllers/application_controller.rb
59
+ - test/dummy/app/controllers/pages_controller.rb
60
+ - test/dummy/app/helpers/application_helper.rb
61
+ - test/dummy/app/views/layouts/application.html.erb
62
+ - test/dummy/app/views/pages/crumbs.html.erb
63
+ - test/dummy/bin/bundle
64
+ - test/dummy/bin/rails
65
+ - test/dummy/bin/rake
66
+ - test/dummy/config/application.rb
67
+ - test/dummy/config/boot.rb
68
+ - test/dummy/config/database.yml
69
+ - test/dummy/config/environment.rb
70
+ - test/dummy/config/environments/development.rb
71
+ - test/dummy/config/environments/production.rb
72
+ - test/dummy/config/environments/test.rb
73
+ - test/dummy/config/initializers/backtrace_silencers.rb
74
+ - test/dummy/config/initializers/filter_parameter_logging.rb
75
+ - test/dummy/config/initializers/inflections.rb
76
+ - test/dummy/config/initializers/mime_types.rb
77
+ - test/dummy/config/initializers/secret_token.rb
78
+ - test/dummy/config/initializers/session_store.rb
79
+ - test/dummy/config/initializers/wrap_parameters.rb
80
+ - test/dummy/config/locales/en.yml
81
+ - test/dummy/config/routes.rb
82
+ - test/dummy/config.ru
83
+ - test/dummy/db/development.sqlite3
84
+ - test/dummy/db/schema.rb
85
+ - test/dummy/db/test.sqlite3
86
+ - test/dummy/log/development.log
87
+ - test/dummy/log/test.log
88
+ - test/dummy/public/404.html
89
+ - test/dummy/public/422.html
90
+ - test/dummy/public/500.html
91
+ - test/dummy/public/favicon.ico
92
+ - test/dummy/Rakefile
93
+ - test/dummy/README.rdoc
94
+ - test/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705
95
+ - test/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af
96
+ - test/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953
97
+ - test/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994
98
+ - test/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6
99
+ - test/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655
100
+ - test/test_helper.rb
101
+ - test/with_last_test.rb
102
+ - test/without_last_test.rb
103
+ homepage: https://github.com/mattways/crumbs
104
+ licenses:
105
+ - MIT
106
+ metadata: {}
107
+ post_install_message:
108
+ rdoc_options: []
109
+ require_paths:
110
+ - lib
111
+ required_ruby_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - '>='
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ required_rubygems_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - '>='
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ requirements: []
122
+ rubyforge_project:
123
+ rubygems_version: 2.0.3
124
+ signing_key:
125
+ specification_version: 4
126
+ summary: Crumbs for Rails.
127
+ test_files:
128
+ - test/dummy/app/assets/javascripts/application.js
129
+ - test/dummy/app/assets/stylesheets/application.css
130
+ - test/dummy/app/controllers/application_controller.rb
131
+ - test/dummy/app/controllers/pages_controller.rb
132
+ - test/dummy/app/helpers/application_helper.rb
133
+ - test/dummy/app/views/layouts/application.html.erb
134
+ - test/dummy/app/views/pages/crumbs.html.erb
135
+ - test/dummy/bin/bundle
136
+ - test/dummy/bin/rails
137
+ - test/dummy/bin/rake
138
+ - test/dummy/config/application.rb
139
+ - test/dummy/config/boot.rb
140
+ - test/dummy/config/database.yml
141
+ - test/dummy/config/environment.rb
142
+ - test/dummy/config/environments/development.rb
143
+ - test/dummy/config/environments/production.rb
144
+ - test/dummy/config/environments/test.rb
145
+ - test/dummy/config/initializers/backtrace_silencers.rb
146
+ - test/dummy/config/initializers/filter_parameter_logging.rb
147
+ - test/dummy/config/initializers/inflections.rb
148
+ - test/dummy/config/initializers/mime_types.rb
149
+ - test/dummy/config/initializers/secret_token.rb
150
+ - test/dummy/config/initializers/session_store.rb
151
+ - test/dummy/config/initializers/wrap_parameters.rb
152
+ - test/dummy/config/locales/en.yml
153
+ - test/dummy/config/routes.rb
154
+ - test/dummy/config.ru
155
+ - test/dummy/db/development.sqlite3
156
+ - test/dummy/db/schema.rb
157
+ - test/dummy/db/test.sqlite3
158
+ - test/dummy/log/development.log
159
+ - test/dummy/log/test.log
160
+ - test/dummy/public/404.html
161
+ - test/dummy/public/422.html
162
+ - test/dummy/public/500.html
163
+ - test/dummy/public/favicon.ico
164
+ - test/dummy/Rakefile
165
+ - test/dummy/README.rdoc
166
+ - test/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705
167
+ - test/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af
168
+ - test/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953
169
+ - test/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994
170
+ - test/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6
171
+ - test/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655
172
+ - test/test_helper.rb
173
+ - test/with_last_test.rb
174
+ - test/without_last_test.rb