bread 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +4 -1
  3. data/bread.gemspec +1 -1
  4. data/lib/bread.rb +15 -10
  5. data/lib/bread/{crumb.rb → data/crumb.rb} +4 -4
  6. data/lib/bread/helper.rb +3 -25
  7. data/lib/bread/manager/actions.rb +37 -0
  8. data/lib/bread/manager/actions/action_scope.rb +32 -0
  9. data/lib/bread/manager/actions/controller_scope.rb +69 -0
  10. data/lib/bread/manager/actions/top_scope.rb +26 -0
  11. data/lib/bread/manager/crumbs.rb +52 -0
  12. data/lib/bread/manager/crumbs/crumb_scope.rb +39 -0
  13. data/lib/bread/manager/crumbs/top_scope.rb +25 -0
  14. data/lib/bread/manager/manager.rb +14 -0
  15. data/lib/bread/version.rb +1 -1
  16. data/test/dummy/app/assets/javascripts/product_photos.js +2 -0
  17. data/test/dummy/app/assets/stylesheets/product_photos.css +4 -0
  18. data/test/dummy/app/controllers/product_photos_controller.rb +67 -0
  19. data/test/dummy/app/controllers/products_controller.rb +12 -23
  20. data/test/dummy/app/helpers/product_photos_helper.rb +2 -0
  21. data/test/dummy/app/lib/bread/actions.rb +18 -0
  22. data/test/dummy/app/lib/bread/actions_next.rb +43 -0
  23. data/test/dummy/app/lib/bread/crumbs.rb +22 -0
  24. data/test/dummy/app/lib/bread/crumbs_next.rb +77 -0
  25. data/test/dummy/app/models/product.rb +8 -0
  26. data/test/dummy/app/models/product_photo.rb +10 -0
  27. data/test/dummy/app/models/user.rb +6 -0
  28. data/test/dummy/app/views/layouts/application.html.erb +10 -5
  29. data/test/dummy/app/views/product_photos/_form.html.erb +29 -0
  30. data/test/dummy/app/views/product_photos/edit.html.erb +6 -0
  31. data/test/dummy/app/views/product_photos/index.html.erb +31 -0
  32. data/test/dummy/app/views/product_photos/new.html.erb +5 -0
  33. data/test/dummy/app/views/product_photos/show.html.erb +19 -0
  34. data/test/dummy/config/initializers/devise.rb +254 -0
  35. data/test/dummy/config/locales/devise.en.yml +59 -0
  36. data/test/dummy/config/routes.rb +4 -1
  37. data/test/dummy/db/migrate/20140306111733_devise_create_users.rb +42 -0
  38. data/test/dummy/db/migrate/20140306114935_create_product_photos.rb +11 -0
  39. data/test/dummy/db/schema.rb +29 -1
  40. data/test/{bread_test.rb → dummy/test/bread_test.rb} +1 -0
  41. data/test/dummy/test/controllers/product_photos_controller_test.rb +98 -0
  42. data/test/dummy/test/controllers/products_controller_test.rb +94 -30
  43. data/test/dummy/test/fixtures/product_photos.yml +11 -0
  44. data/test/dummy/test/fixtures/products.yml +4 -4
  45. data/test/dummy/test/fixtures/users.yml +11 -0
  46. data/test/dummy/test/helpers/product_photos_helper_test.rb +4 -0
  47. data/test/{integration → dummy/test/integration}/navigation_test.rb +0 -0
  48. data/test/dummy/test/models/product_photo_test.rb +7 -0
  49. data/test/dummy/test/models/user_test.rb +7 -0
  50. data/test/dummy/test/support/asserts.rb +17 -0
  51. data/test/test_helper.rb +1 -1
  52. metadata +68 -14
  53. data/lib/bread/commands/config_command.rb +0 -15
  54. data/lib/bread/commands/controller_layout_command.rb +0 -44
  55. data/lib/bread/commands/crumb_to_command.rb +0 -23
  56. data/lib/bread/commands/ivars_command.rb +0 -16
  57. data/lib/bread/config.rb +0 -24
  58. data/lib/bread/controller.rb +0 -30
@@ -1,50 +1,114 @@
1
+ # http://rubydoc.info/github/rack/rack/master/Rack/Utils#HTTP_STATUS_CODES-constant
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class ProductsControllerTest < ActionController::TestCase
4
6
  setup do
5
- @product = Product.create(name: "aaa", category: "bbb")
7
+ @product = Product.create(name: "aaa", category: "Awesome")
6
8
  end
7
9
 
8
10
  test "should get index" do
9
11
  get :index
10
12
  assert_response :success
11
13
  assert_not_nil assigns(:products)
14
+ # bread
15
+ assert_crumb "Home"
16
+ assert_crumb "Products"
12
17
  end
13
18
 
14
- test "should get new" do
15
- get :new
16
- assert_response :success
17
- assert response.body.include? ("Add")
18
- end
19
+ test "should get new" do
20
+ get :new
21
+ assert_response :success
22
+ # bread
23
+ assert_crumb "Home"
24
+ assert_crumb "Products"
25
+ assert_crumb "New"
26
+ end
19
27
 
20
- test "should create product" do
21
- assert_difference('Product.count') do
22
- post :create, product: { category: @product.category, name: @product.name }
23
- end
28
+ test "should create product" do
29
+ assert_difference('Product.count') do
30
+ post :create, product: { category: @product.category, name: @product.name }
31
+ end
24
32
 
25
- assert_redirected_to product_path(assigns(:product))
26
- end
33
+ assert_redirected_to product_path(assigns(:product))
34
+ end
27
35
 
28
- test "should show product" do
29
- get :show, id: @product
30
- assert_response :success
31
- end
36
+ test "shouldnt create product" do
37
+ assert_no_difference('Product.count') do
38
+ post :create, product: {name: ''}
39
+ end
32
40
 
33
- test "should get edit" do
34
- get :edit, id: @product
35
- assert_response :success
36
- end
41
+ assert_response :success
42
+ assert_template :new
43
+ # bread
44
+ assert_crumb "Home"
45
+ assert_crumb "Products"
46
+ assert_crumb "New"
47
+ end
37
48
 
38
- test "should update product" do
39
- patch :update, id: @product, product: { category: @product.category, name: @product.name }
40
- assert_redirected_to product_path(assigns(:product))
41
- end
42
49
 
43
- test "should destroy product" do
44
- assert_difference('Product.count', -1) do
45
- delete :destroy, id: @product
46
- end
50
+ test "should get by_category" do
51
+ get :by_category, category: @product.category
52
+ assert_response :success
53
+ assert_not_nil assigns(:products)
54
+ # bread
55
+ assert_crumb "Products"
56
+ assert_crumb @product.category
57
+ end
47
58
 
48
- assert_redirected_to products_path
49
- end
59
+ test "should show product" do
60
+ get :show, id: @product
61
+ assert_response :success
62
+ # bread
63
+ assert_crumb "Products"
64
+ assert_crumb @product.category
65
+ assert_crumb @product.name
66
+ end
67
+
68
+ test "should get edit" do
69
+ get :edit, id: @product
70
+ assert_response :success
71
+ # bread
72
+ assert_crumb "Products"
73
+ assert_crumb @product.name
74
+ assert_crumb "Edit"
75
+ end
76
+
77
+ test "should update product" do
78
+ patch :update, id: @product, product: { category: @product.category, name: @product.name }
79
+ assert_redirected_to product_path(assigns(:product))
80
+ end
81
+
82
+ test "shouldnt update product" do
83
+ patch :update, id: @product, product: {name: ''}
84
+
85
+ assert_response :success
86
+ assert_template :edit
87
+ # bread
88
+ assert_crumb "Products"
89
+ assert_crumb @product.name
90
+ assert_crumb "Edit"
91
+ end
92
+
93
+ test "should destroy product" do
94
+ assert_difference('Product.count', -1) do
95
+ delete :destroy, id: @product
96
+ end
97
+
98
+ assert_redirected_to products_path
99
+ end
100
+
101
+ test "shouldnt destroy product" do
102
+ @product.product_photos.create(name: "aaa")
103
+ assert_no_difference('Product.count') do
104
+ delete :destroy, id: @product
105
+ end
106
+
107
+ assert_response :success
108
+ assert_template :edit
109
+ # bread
110
+ assert_crumb "Products"
111
+ assert_crumb @product.name
112
+ assert_crumb "Edit"
113
+ end
50
114
  end
@@ -0,0 +1,11 @@
1
+ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
2
+
3
+ one:
4
+ product_id:
5
+ name: MyString
6
+ order: 1
7
+
8
+ two:
9
+ product_id:
10
+ name: MyString
11
+ order: 1
@@ -1,9 +1,9 @@
1
1
  # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
2
2
 
3
3
  one:
4
- name: MyString
5
- category: MyString
4
+ name: prod-1
5
+ category: cat-a
6
6
 
7
7
  two:
8
- name: MyString
9
- category: MyString
8
+ name: prod-2
9
+ category: cat-a
@@ -0,0 +1,11 @@
1
+ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
2
+
3
+ # This model initially had no columns defined. If you add columns to the
4
+ # model remove the '{}' from the fixture names and add the columns immediately
5
+ # below each fixture, per the syntax in the comments below
6
+ #
7
+ one: {}
8
+ # column: value
9
+ #
10
+ two: {}
11
+ # column: value
@@ -0,0 +1,4 @@
1
+ require 'test_helper'
2
+
3
+ class ProductPhotosHelperTest < ActionView::TestCase
4
+ end
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class ProductPhotoTest < ActiveSupport::TestCase
4
+ # test "the truth" do
5
+ # assert true
6
+ # end
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class UserTest < ActiveSupport::TestCase
4
+ # test "the truth" do
5
+ # assert true
6
+ # end
7
+ end
@@ -0,0 +1,17 @@
1
+
2
+
3
+ # http://guides.rubyonrails.org/testing.html#available-assertions
4
+ # http://edgeguides.rubyonrails.org/testing.html#rails-specific-assertions
5
+
6
+
7
+
8
+ def assert_crumb(text)
9
+ assert_select("li a", text, "<li><a>#{text.magenta}</a></li> should be included in #{get_clean_response_body.blue} but wasn't")
10
+ end
11
+
12
+ def get_clean_response_body
13
+ response.body.gsub("\n", '').gsub(' ', '')
14
+ end
15
+
16
+
17
+
data/test/test_helper.rb CHANGED
@@ -7,7 +7,7 @@ require "rails/test_help"
7
7
  Rails.backtrace_cleaner.remove_silencers!
8
8
 
9
9
  # Load support files
10
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
10
+ Dir["#{File.dirname(__FILE__)}/dummy/test/support/**/*.rb"].each { |f| require f }
11
11
 
12
12
  # Load fixtures from the engine
13
13
  if ActiveSupport::TestCase.method_defined?(:fixture_path=)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bread
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thiago Pinto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-05 00:00:00.000000000 Z
11
+ date: 2014-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,36 +52,52 @@ files:
52
52
  - Rakefile
53
53
  - bread.gemspec
54
54
  - lib/bread.rb
55
- - lib/bread/commands/config_command.rb
56
- - lib/bread/commands/controller_layout_command.rb
57
- - lib/bread/commands/crumb_to_command.rb
58
- - lib/bread/commands/ivars_command.rb
59
- - lib/bread/config.rb
60
- - lib/bread/controller.rb
61
- - lib/bread/crumb.rb
55
+ - lib/bread/data/crumb.rb
62
56
  - lib/bread/helper.rb
57
+ - lib/bread/manager/actions.rb
58
+ - lib/bread/manager/actions/action_scope.rb
59
+ - lib/bread/manager/actions/controller_scope.rb
60
+ - lib/bread/manager/actions/top_scope.rb
61
+ - lib/bread/manager/crumbs.rb
62
+ - lib/bread/manager/crumbs/crumb_scope.rb
63
+ - lib/bread/manager/crumbs/top_scope.rb
64
+ - lib/bread/manager/manager.rb
63
65
  - lib/bread/version.rb
64
66
  - lib/generators/bread/USAGE
65
67
  - lib/generators/bread/install_generator.rb
66
68
  - lib/generators/bread/templates/skeleton.rb
67
- - test/bread_test.rb
68
69
  - test/dummy/README.rdoc
69
70
  - test/dummy/Rakefile
70
71
  - test/dummy/app/assets/javascripts/application.js
72
+ - test/dummy/app/assets/javascripts/product_photos.js
71
73
  - test/dummy/app/assets/javascripts/products.js
72
74
  - test/dummy/app/assets/stylesheets/application.css
75
+ - test/dummy/app/assets/stylesheets/product_photos.css
73
76
  - test/dummy/app/assets/stylesheets/products.css
74
77
  - test/dummy/app/assets/stylesheets/scaffold.css
75
78
  - test/dummy/app/controllers/application_controller.rb
76
79
  - test/dummy/app/controllers/concerns/.keep
80
+ - test/dummy/app/controllers/product_photos_controller.rb
77
81
  - test/dummy/app/controllers/products_controller.rb
78
82
  - test/dummy/app/helpers/application_helper.rb
83
+ - test/dummy/app/helpers/product_photos_helper.rb
79
84
  - test/dummy/app/helpers/products_helper.rb
85
+ - test/dummy/app/lib/bread/actions.rb
86
+ - test/dummy/app/lib/bread/actions_next.rb
87
+ - test/dummy/app/lib/bread/crumbs.rb
88
+ - test/dummy/app/lib/bread/crumbs_next.rb
80
89
  - test/dummy/app/mailers/.keep
81
90
  - test/dummy/app/models/.keep
82
91
  - test/dummy/app/models/concerns/.keep
83
92
  - test/dummy/app/models/product.rb
93
+ - test/dummy/app/models/product_photo.rb
94
+ - test/dummy/app/models/user.rb
84
95
  - test/dummy/app/views/layouts/application.html.erb
96
+ - test/dummy/app/views/product_photos/_form.html.erb
97
+ - test/dummy/app/views/product_photos/edit.html.erb
98
+ - test/dummy/app/views/product_photos/index.html.erb
99
+ - test/dummy/app/views/product_photos/new.html.erb
100
+ - test/dummy/app/views/product_photos/show.html.erb
85
101
  - test/dummy/app/views/products/_form.html.erb
86
102
  - test/dummy/app/views/products/edit.html.erb
87
103
  - test/dummy/app/views/products/index.html.erb
@@ -100,16 +116,20 @@ files:
100
116
  - test/dummy/config/environments/production.rb
101
117
  - test/dummy/config/environments/test.rb
102
118
  - test/dummy/config/initializers/backtrace_silencers.rb
119
+ - test/dummy/config/initializers/devise.rb
103
120
  - test/dummy/config/initializers/filter_parameter_logging.rb
104
121
  - test/dummy/config/initializers/inflections.rb
105
122
  - test/dummy/config/initializers/mime_types.rb
106
123
  - test/dummy/config/initializers/secret_token.rb
107
124
  - test/dummy/config/initializers/session_store.rb
108
125
  - test/dummy/config/initializers/wrap_parameters.rb
126
+ - test/dummy/config/locales/devise.en.yml
109
127
  - test/dummy/config/locales/en.yml
110
128
  - test/dummy/config/routes.rb
111
129
  - test/dummy/db/development.sqlite3
112
130
  - test/dummy/db/migrate/20140203163238_create_products.rb
131
+ - test/dummy/db/migrate/20140306111733_devise_create_users.rb
132
+ - test/dummy/db/migrate/20140306114935_create_product_photos.rb
113
133
  - test/dummy/db/schema.rb
114
134
  - test/dummy/db/test.sqlite3
115
135
  - test/dummy/lib/assets/.keep
@@ -118,13 +138,21 @@ files:
118
138
  - test/dummy/public/422.html
119
139
  - test/dummy/public/500.html
120
140
  - test/dummy/public/favicon.ico
141
+ - test/dummy/test/bread_test.rb
142
+ - test/dummy/test/controllers/product_photos_controller_test.rb
121
143
  - test/dummy/test/controllers/products_controller_test.rb
144
+ - test/dummy/test/fixtures/product_photos.yml
122
145
  - test/dummy/test/fixtures/products.yml
146
+ - test/dummy/test/fixtures/users.yml
147
+ - test/dummy/test/helpers/product_photos_helper_test.rb
123
148
  - test/dummy/test/helpers/products_helper_test.rb
149
+ - test/dummy/test/integration/navigation_test.rb
150
+ - test/dummy/test/models/product_photo_test.rb
124
151
  - test/dummy/test/models/product_test.rb
125
- - test/integration/navigation_test.rb
152
+ - test/dummy/test/models/user_test.rb
153
+ - test/dummy/test/support/asserts.rb
126
154
  - test/test_helper.rb
127
- homepage: https://github.com/yakko/bread
155
+ homepage: https://github.com/hi/bread
128
156
  licenses:
129
157
  - MIT
130
158
  metadata: {}
@@ -149,24 +177,38 @@ signing_key:
149
177
  specification_version: 4
150
178
  summary: Set up all your breadcrumbs with on a dependency-based simple block of code
151
179
  test_files:
152
- - test/bread_test.rb
153
180
  - test/dummy/README.rdoc
154
181
  - test/dummy/Rakefile
155
182
  - test/dummy/app/assets/javascripts/application.js
183
+ - test/dummy/app/assets/javascripts/product_photos.js
156
184
  - test/dummy/app/assets/javascripts/products.js
157
185
  - test/dummy/app/assets/stylesheets/application.css
186
+ - test/dummy/app/assets/stylesheets/product_photos.css
158
187
  - test/dummy/app/assets/stylesheets/products.css
159
188
  - test/dummy/app/assets/stylesheets/scaffold.css
160
189
  - test/dummy/app/controllers/application_controller.rb
161
190
  - test/dummy/app/controllers/concerns/.keep
191
+ - test/dummy/app/controllers/product_photos_controller.rb
162
192
  - test/dummy/app/controllers/products_controller.rb
163
193
  - test/dummy/app/helpers/application_helper.rb
194
+ - test/dummy/app/helpers/product_photos_helper.rb
164
195
  - test/dummy/app/helpers/products_helper.rb
196
+ - test/dummy/app/lib/bread/actions.rb
197
+ - test/dummy/app/lib/bread/actions_next.rb
198
+ - test/dummy/app/lib/bread/crumbs.rb
199
+ - test/dummy/app/lib/bread/crumbs_next.rb
165
200
  - test/dummy/app/mailers/.keep
166
201
  - test/dummy/app/models/.keep
167
202
  - test/dummy/app/models/concerns/.keep
168
203
  - test/dummy/app/models/product.rb
204
+ - test/dummy/app/models/product_photo.rb
205
+ - test/dummy/app/models/user.rb
169
206
  - test/dummy/app/views/layouts/application.html.erb
207
+ - test/dummy/app/views/product_photos/_form.html.erb
208
+ - test/dummy/app/views/product_photos/edit.html.erb
209
+ - test/dummy/app/views/product_photos/index.html.erb
210
+ - test/dummy/app/views/product_photos/new.html.erb
211
+ - test/dummy/app/views/product_photos/show.html.erb
170
212
  - test/dummy/app/views/products/_form.html.erb
171
213
  - test/dummy/app/views/products/edit.html.erb
172
214
  - test/dummy/app/views/products/index.html.erb
@@ -185,16 +227,20 @@ test_files:
185
227
  - test/dummy/config/environments/production.rb
186
228
  - test/dummy/config/environments/test.rb
187
229
  - test/dummy/config/initializers/backtrace_silencers.rb
230
+ - test/dummy/config/initializers/devise.rb
188
231
  - test/dummy/config/initializers/filter_parameter_logging.rb
189
232
  - test/dummy/config/initializers/inflections.rb
190
233
  - test/dummy/config/initializers/mime_types.rb
191
234
  - test/dummy/config/initializers/secret_token.rb
192
235
  - test/dummy/config/initializers/session_store.rb
193
236
  - test/dummy/config/initializers/wrap_parameters.rb
237
+ - test/dummy/config/locales/devise.en.yml
194
238
  - test/dummy/config/locales/en.yml
195
239
  - test/dummy/config/routes.rb
196
240
  - test/dummy/db/development.sqlite3
197
241
  - test/dummy/db/migrate/20140203163238_create_products.rb
242
+ - test/dummy/db/migrate/20140306111733_devise_create_users.rb
243
+ - test/dummy/db/migrate/20140306114935_create_product_photos.rb
198
244
  - test/dummy/db/schema.rb
199
245
  - test/dummy/db/test.sqlite3
200
246
  - test/dummy/lib/assets/.keep
@@ -203,9 +249,17 @@ test_files:
203
249
  - test/dummy/public/422.html
204
250
  - test/dummy/public/500.html
205
251
  - test/dummy/public/favicon.ico
252
+ - test/dummy/test/bread_test.rb
253
+ - test/dummy/test/controllers/product_photos_controller_test.rb
206
254
  - test/dummy/test/controllers/products_controller_test.rb
255
+ - test/dummy/test/fixtures/product_photos.yml
207
256
  - test/dummy/test/fixtures/products.yml
257
+ - test/dummy/test/fixtures/users.yml
258
+ - test/dummy/test/helpers/product_photos_helper_test.rb
208
259
  - test/dummy/test/helpers/products_helper_test.rb
260
+ - test/dummy/test/integration/navigation_test.rb
261
+ - test/dummy/test/models/product_photo_test.rb
209
262
  - test/dummy/test/models/product_test.rb
210
- - test/integration/navigation_test.rb
263
+ - test/dummy/test/models/user_test.rb
264
+ - test/dummy/test/support/asserts.rb
211
265
  - test/test_helper.rb
@@ -1,15 +0,0 @@
1
- module Bread
2
- class ConfigCommand
3
-
4
- attr_reader :crumb_definitions
5
-
6
- def initialize
7
- @crumb_definitions = {}
8
- end
9
-
10
- def key(key_name, &block)
11
- @crumb_definitions[key_name] = block
12
- end
13
-
14
- end
15
- end