bread 0.0.11 → 0.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -4
  3. data/Rakefile +15 -19
  4. data/lib/bread/controller.rb +26 -0
  5. data/lib/bread/manager/actions.rb +1 -21
  6. data/lib/bread/manager/crumbs.rb +1 -16
  7. data/lib/bread/reloader.rb +30 -0
  8. data/lib/bread/version.rb +1 -1
  9. data/lib/bread.rb +12 -1
  10. data/lib/generators/bread/install_generator.rb +17 -2
  11. data/{test/dummy/app/lib → lib/generators/bread/templates}/bread/actions.rb +18 -18
  12. data/lib/generators/bread/templates/bread/crumbs.rb +20 -0
  13. data/lib/generators/bread/templates/view.html.erb +9 -0
  14. data/spec/controllers/photos_controller_spec.rb +94 -0
  15. data/spec/controllers/products_controller_spec.rb +94 -0
  16. data/{test → spec}/dummy/README.rdoc +0 -0
  17. data/{test → spec}/dummy/Rakefile +0 -0
  18. data/{test → spec}/dummy/app/assets/javascripts/application.js +0 -0
  19. data/{test → spec}/dummy/app/assets/stylesheets/application.css +0 -0
  20. data/{test → spec}/dummy/app/controllers/application_controller.rb +0 -0
  21. data/spec/dummy/app/controllers/photos_controller.rb +96 -0
  22. data/spec/dummy/app/controllers/products_controller.rb +98 -0
  23. data/{test → spec}/dummy/app/helpers/application_helper.rb +0 -0
  24. data/spec/dummy/app/lib/bread/actions.rb +18 -0
  25. data/{test → spec}/dummy/app/lib/bread/crumbs.rb +26 -25
  26. data/spec/dummy/app/models/category.rb +7 -0
  27. data/spec/dummy/app/models/photo.rb +11 -0
  28. data/spec/dummy/app/models/product.rb +12 -0
  29. data/spec/dummy/app/views/layouts/application.html.erb +23 -0
  30. data/spec/dummy/app/views/photos/_form.html.erb +21 -0
  31. data/spec/dummy/app/views/photos/edit.html.erb +6 -0
  32. data/spec/dummy/app/views/photos/index.html.erb +25 -0
  33. data/spec/dummy/app/views/photos/new.html.erb +5 -0
  34. data/spec/dummy/app/views/photos/show.html.erb +9 -0
  35. data/{test → spec}/dummy/app/views/products/_form.html.erb +4 -4
  36. data/{test → spec}/dummy/app/views/products/edit.html.erb +0 -0
  37. data/{test → spec}/dummy/app/views/products/index.html.erb +1 -3
  38. data/{test → spec}/dummy/app/views/products/new.html.erb +0 -0
  39. data/{test → spec}/dummy/app/views/products/show.html.erb +0 -0
  40. data/{test → spec}/dummy/bin/bundle +0 -0
  41. data/{test → spec}/dummy/bin/rails +0 -0
  42. data/{test → spec}/dummy/bin/rake +0 -0
  43. data/{test → spec}/dummy/config/application.rb +8 -0
  44. data/{test → spec}/dummy/config/boot.rb +0 -0
  45. data/{test → spec}/dummy/config/database.yml +1 -3
  46. data/{test → spec}/dummy/config/environment.rb +0 -0
  47. data/{test → spec}/dummy/config/environments/development.rb +0 -0
  48. data/{test → spec}/dummy/config/environments/production.rb +0 -0
  49. data/{test → spec}/dummy/config/environments/test.rb +0 -1
  50. data/{test → spec}/dummy/config/initializers/backtrace_silencers.rb +0 -0
  51. data/{test → spec}/dummy/config/initializers/filter_parameter_logging.rb +0 -0
  52. data/{test → spec}/dummy/config/initializers/inflections.rb +0 -0
  53. data/{test → spec}/dummy/config/initializers/mime_types.rb +0 -0
  54. data/{test → spec}/dummy/config/initializers/secret_token.rb +1 -1
  55. data/{test → spec}/dummy/config/initializers/session_store.rb +0 -0
  56. data/{test → spec}/dummy/config/initializers/wrap_parameters.rb +0 -0
  57. data/{test → spec}/dummy/config/locales/en.yml +0 -0
  58. data/{test → spec}/dummy/config/routes.rb +1 -3
  59. data/{test → spec}/dummy/config.ru +0 -0
  60. data/{test → spec}/dummy/db/development.sqlite3 +0 -0
  61. data/spec/dummy/db/migrate/20140912040816_create_foos.rb +9 -0
  62. data/spec/dummy/db/migrate/20140912042735_create_admin_foos.rb +9 -0
  63. data/{test/dummy/db/migrate/20140203163238_create_products.rb → spec/dummy/db/migrate/20150312182743_create_products.rb} +1 -1
  64. data/spec/dummy/db/migrate/20150312182826_create_categories.rb +9 -0
  65. data/spec/dummy/db/migrate/20150312183119_create_photos.rb +10 -0
  66. data/{test/dummy/app/controllers/concerns/.keep → spec/dummy/db/production.sqlite3} +0 -0
  67. data/{test → spec}/dummy/db/schema.rb +22 -21
  68. data/{test → spec}/dummy/db/test.sqlite3 +0 -0
  69. data/spec/dummy/lib/templates/rails/scaffold_controller/controller.rb +101 -0
  70. data/spec/dummy/log/development.log +167 -0
  71. data/spec/dummy/log/production.log +66 -0
  72. data/spec/dummy/log/test.log +21931 -0
  73. data/{test → spec}/dummy/public/404.html +0 -0
  74. data/{test → spec}/dummy/public/422.html +0 -0
  75. data/{test → spec}/dummy/public/500.html +0 -0
  76. data/{test → spec}/dummy/public/favicon.ico +0 -0
  77. data/spec/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  78. data/spec/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  79. data/spec/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  80. data/spec/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  81. data/spec/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  82. data/spec/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  83. data/spec/rails_helper.rb +78 -0
  84. data/spec/requests/photos_spec.rb +12 -0
  85. data/spec/requests/products_spec.rb +11 -0
  86. data/spec/spec_helper.rb +85 -0
  87. data/spec/support/bread_spec_controller_methods.rb +11 -0
  88. data/spec/support/controllers/bread_spec_controller_methods.rb +12 -0
  89. metadata +254 -193
  90. data/.gitignore +0 -22
  91. data/Gemfile +0 -26
  92. data/LICENSE.txt +0 -22
  93. data/bread.gemspec +0 -24
  94. data/lib/bread/helper.rb +0 -16
  95. data/lib/generators/bread/templates/skeleton.rb +0 -12
  96. data/test/dummy/app/assets/javascripts/product_photos.js +0 -2
  97. data/test/dummy/app/assets/javascripts/products.js +0 -2
  98. data/test/dummy/app/assets/stylesheets/product_photos.css +0 -4
  99. data/test/dummy/app/assets/stylesheets/products.css +0 -4
  100. data/test/dummy/app/assets/stylesheets/scaffold.css +0 -56
  101. data/test/dummy/app/controllers/product_photos_controller.rb +0 -63
  102. data/test/dummy/app/controllers/products_controller.rb +0 -72
  103. data/test/dummy/app/helpers/product_photos_helper.rb +0 -2
  104. data/test/dummy/app/helpers/products_helper.rb +0 -2
  105. data/test/dummy/app/lib/bread/actions_next.rb +0 -43
  106. data/test/dummy/app/lib/bread/crumbs_next.rb +0 -77
  107. data/test/dummy/app/mailers/.keep +0 -0
  108. data/test/dummy/app/models/.keep +0 -0
  109. data/test/dummy/app/models/concerns/.keep +0 -0
  110. data/test/dummy/app/models/product.rb +0 -10
  111. data/test/dummy/app/models/product_photo.rb +0 -10
  112. data/test/dummy/app/models/user.rb +0 -6
  113. data/test/dummy/app/views/layouts/application.html.erb +0 -34
  114. data/test/dummy/app/views/product_photos/_form.html.erb +0 -25
  115. data/test/dummy/app/views/product_photos/edit.html.erb +0 -6
  116. data/test/dummy/app/views/product_photos/index.html.erb +0 -31
  117. data/test/dummy/app/views/product_photos/new.html.erb +0 -5
  118. data/test/dummy/app/views/product_photos/show.html.erb +0 -19
  119. data/test/dummy/config/breadcrumbs.rb +0 -18
  120. data/test/dummy/config/initializers/devise.rb +0 -254
  121. data/test/dummy/config/locales/devise.en.yml +0 -59
  122. data/test/dummy/db/migrate/20140306111733_devise_create_users.rb +0 -42
  123. data/test/dummy/db/migrate/20140306114935_create_product_photos.rb +0 -11
  124. data/test/dummy/lib/assets/.keep +0 -0
  125. data/test/dummy/lib/templates/rails/scaffold_controller/controller.rb +0 -146
  126. data/test/dummy/log/.keep +0 -0
  127. data/test/dummy/test/bread_test.rb +0 -7
  128. data/test/dummy/test/controllers/product_photos_controller_test.rb +0 -98
  129. data/test/dummy/test/controllers/products_controller_test.rb +0 -114
  130. data/test/dummy/test/fixtures/product_photos.yml +0 -11
  131. data/test/dummy/test/fixtures/products.yml +0 -9
  132. data/test/dummy/test/fixtures/users.yml +0 -11
  133. data/test/dummy/test/helpers/product_photos_helper_test.rb +0 -4
  134. data/test/dummy/test/helpers/products_helper_test.rb +0 -4
  135. data/test/dummy/test/integration/devise_test.rb +0 -166
  136. data/test/dummy/test/integration/navigation_test.rb +0 -10
  137. data/test/dummy/test/models/product_photo_test.rb +0 -7
  138. data/test/dummy/test/models/product_test.rb +0 -7
  139. data/test/dummy/test/models/user_test.rb +0 -7
  140. data/test/dummy/test/support/asserts.rb +0 -38
  141. data/test/dummy/test/support/others.rb +0 -20
  142. data/test/test_helper.rb +0 -21
@@ -1,114 +0,0 @@
1
- # http://rubydoc.info/github/rack/rack/master/Rack/Utils#HTTP_STATUS_CODES-constant
2
-
3
- require 'test_helper'
4
-
5
- class ProductsControllerTest < ActionController::TestCase
6
- setup do
7
- @product = Product.create(name: "aaa", category: "Awesome")
8
- end
9
-
10
- test "should get index" do
11
- get :index
12
- assert_response :success
13
- assert_not_nil assigns(:products)
14
- # bread
15
- assert_crumb "Home"
16
- assert_crumb "Products"
17
- end
18
-
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
27
-
28
- test "should create product" do
29
- assert_difference('Product.count') do
30
- post :create, product: { category: @product.category, name: @product.name }
31
- end
32
-
33
- assert_redirected_to product_path(assigns(:product))
34
- end
35
-
36
- test "shouldnt create product" do
37
- assert_no_difference('Product.count') do
38
- post :create, product: {name: ''}
39
- end
40
-
41
- assert_response :success
42
- assert_template :new
43
- # bread
44
- assert_crumb "Home"
45
- assert_crumb "Products"
46
- assert_crumb "New"
47
- end
48
-
49
-
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
58
-
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
114
- end
@@ -1,11 +0,0 @@
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 +0,0 @@
1
- # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
2
-
3
- one:
4
- name: prod-1
5
- category: cat-a
6
-
7
- two:
8
- name: prod-2
9
- category: cat-a
@@ -1,11 +0,0 @@
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
@@ -1,4 +0,0 @@
1
- require 'test_helper'
2
-
3
- class ProductPhotosHelperTest < ActionView::TestCase
4
- end
@@ -1,4 +0,0 @@
1
- require 'test_helper'
2
-
3
- class ProductsHelperTest < ActionView::TestCase
4
- end
@@ -1,166 +0,0 @@
1
- require 'test_helper'
2
-
3
- class DeviseGuestNavigationTest < ActionDispatch::IntegrationTest
4
- setup do
5
- @email = 'test@gmail.com'
6
- @password = '12345678'
7
- @sample_user = User.create! email: @email, password: @password
8
- end
9
-
10
- test "should sign in" do
11
- visit new_user_session_path
12
- # bread
13
- assert_crumb "Home"
14
- assert_crumb "Sign In"
15
-
16
- fill_in_email_password_click(@email, @password, nil, 'Sign in')
17
-
18
- assert page.has_content?('Signed in successfully.'), page.body
19
- end
20
-
21
- test "shouldnt sign in" do
22
- visit new_user_session_path
23
-
24
- click_button('Sign in')
25
-
26
- assert page.has_content?('Invalid email or password.'), page.body
27
- end
28
-
29
- test "should sign up" do
30
- visit new_user_registration_path
31
- # bread
32
- assert_crumb "Home"
33
- assert_crumb "Sign Up"
34
- fill_in_email_password_click("new@gmail.com", @password, @password, 'Sign up')
35
-
36
- assert page.has_content?('Welcome! You have signed up successfully.'), page.body
37
- end
38
-
39
- test "shouldnt sign up" do
40
- visit new_user_registration_path
41
- click_button('Sign up')
42
-
43
- assert page.has_content?('prohibited this user from being'), page.body
44
- end
45
-
46
- test "should remember" do
47
- visit new_user_password_path
48
- # bread
49
- assert_crumb "Home"
50
- assert_crumb "Sign In"
51
- assert_crumb "Forgot Password"
52
- fill_in_email_password_click(@email, nil, nil, 'Send me')
53
-
54
- assert page.has_content?('You will receive an email with instructions about how to reset your password in a few minutes.'), page.body
55
- end
56
-
57
- test "shouldnt remember when blank" do
58
- visit new_user_password_path
59
- click_button('Send me')
60
-
61
- assert page.has_content?('prohibited this user from being'), page.body
62
- end
63
-
64
- test "shouldnt remember when wrong" do
65
- visit new_user_password_path
66
- fill_in_email_password_click('wrong', nil, nil, 'Send me')
67
-
68
- assert page.has_content?('prohibited this user from being'), page.body
69
- end
70
-
71
- test "should edit password" do
72
- raw_reset_password_token = User.last.send_reset_password_instructions
73
-
74
- visit edit_user_password_path(reset_password_token: raw_reset_password_token)
75
-
76
- # bread
77
- assert_crumb "Home"
78
- assert_crumb "Sign In"
79
- assert_crumb "Forgot Password"
80
-
81
- fill_in 'New password', with: '12341234'
82
- fill_in 'Confirm new password', with: '12341234'
83
- click_button 'Change'
84
-
85
- assert page.has_content?('Your password was changed successfully. You are now signed in.'), page.body
86
- end
87
-
88
- test "shouldnt edit password when no token" do
89
- visit edit_user_password_path
90
-
91
- assert page.has_content?('please make sure you used the full URL provided.'), page.body
92
- end
93
-
94
- test "shouldnt edit password when no password" do
95
- raw_reset_password_token = User.last.send_reset_password_instructions
96
-
97
- visit edit_user_password_path(reset_password_token: raw_reset_password_token)
98
- click_button 'Change'
99
-
100
- assert page.has_content?('prohibited this user from being saved:'), page.body
101
- end
102
-
103
- end
104
-
105
- class DeviseUserNavigationTest < ActionDispatch::IntegrationTest
106
- setup do
107
- @email = 'test@gmail.com'
108
- @password = '12345678'
109
- sign_in(@email, @password)
110
- @new_password = '12341234'
111
- end
112
-
113
- test "should edit profile email" do
114
- visit edit_user_registration_path
115
- # bread
116
- assert_crumb "Home"
117
- assert_crumb "Edit Profile"
118
-
119
- fill_in('Email', with: "omg-#{@email}")
120
- fill_in('Current password', with: @password)
121
- click_button 'Update'
122
-
123
- assert page.has_content?('You updated your account successfully.'), page.body
124
- end
125
-
126
- test "shouldnt edit profile when no match" do
127
- visit edit_user_registration_path
128
- fill_in('Password', with: @new_password)
129
- click_button 'Update'
130
-
131
- assert page.has_content?("doesn't match"), page.body
132
- end
133
-
134
- test "shouldnt edit profile when current password is blank" do
135
- visit edit_user_registration_path
136
- fill_in('Password', with: @new_password)
137
- fill_in('Password confirmation', with: @new_password)
138
- click_button 'Update'
139
-
140
- assert page.has_content?("can't be blank"), page.body
141
- end
142
-
143
- test "should edit profile password" do
144
- visit edit_user_registration_path
145
- fill_in('Current password', with: @password)
146
- fill_in('Password', with: @new_password)
147
- fill_in('Password confirmation', with: @new_password)
148
- click_button 'Update'
149
-
150
- assert page.has_content?("You updated your account successfully."), page.body
151
- end
152
-
153
- test "should remove profile" do
154
- visit edit_user_registration_path
155
- click_button 'Cancel my account'
156
-
157
- assert page.has_content?('Bye! Your account was successfully cancelled. We hope to see you again soon.'), page.body
158
- end
159
-
160
- test "should sign out" do
161
- click_link 'Sign Out'
162
-
163
- assert page.has_content?('Signed out successfully.'), page.body
164
- end
165
-
166
- end
@@ -1,10 +0,0 @@
1
- require 'test_helper'
2
-
3
- class NavigationTest < ActionDispatch::IntegrationTest
4
- # fixtures :all
5
-
6
- test "the truth" do
7
- assert true
8
- end
9
- end
10
-
@@ -1,7 +0,0 @@
1
- require 'test_helper'
2
-
3
- class ProductPhotoTest < ActiveSupport::TestCase
4
- # test "the truth" do
5
- # assert true
6
- # end
7
- end
@@ -1,7 +0,0 @@
1
- require 'test_helper'
2
-
3
- class ProductTest < ActiveSupport::TestCase
4
- # test "the truth" do
5
- # assert true
6
- # end
7
- end
@@ -1,7 +0,0 @@
1
- require 'test_helper'
2
-
3
- class UserTest < ActiveSupport::TestCase
4
- # test "the truth" do
5
- # assert true
6
- # end
7
- end
@@ -1,38 +0,0 @@
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
- if response.present?
10
- assert_select("ul#breadcrumbs li a", text, get_clean_response_body_error(text))
11
- else
12
- result = page.all("ul#breadcrumbs li a", text: text)
13
- case result.count
14
- when 0
15
- assert(false, get_clean_response_body_error(text))
16
- when 1
17
- assert(true)
18
- else
19
- assert(false, get_clean_response_body_error(text))
20
- end
21
-
22
- end
23
- end
24
-
25
- def get_clean_response_body
26
- if response.present?
27
- response
28
- else
29
- page
30
- end.body.gsub("\n", '').gsub(' ', '')
31
- end
32
-
33
- def get_clean_response_body_error(text)
34
- "<li><a>#{text.magenta}</a></li> should be included exactly once in #{get_clean_response_body.blue} but wasn't"
35
- end
36
-
37
-
38
-
@@ -1,20 +0,0 @@
1
-
2
-
3
-
4
- def fill_in_email_password_click(email, password, password2, button_text)
5
- fill_in('Email', with: email)
6
- fill_in('Password', with: password) if password
7
- fill_in('Password confirmation', with: password2) if password2
8
- click_button button_text
9
- end
10
-
11
-
12
- def sign_in(email, password)
13
- User.create! email: email, password: password
14
-
15
- visit new_user_session_path
16
- fill_in_email_password_click(email, password, nil, 'Sign in')
17
-
18
- assert page.has_content?('Signed in successfully.'), page.body
19
- end
20
-
data/test/test_helper.rb DELETED
@@ -1,21 +0,0 @@
1
- # Configure Rails Environment
2
- ENV["RAILS_ENV"] = "test"
3
-
4
- require File.expand_path("../dummy/config/environment.rb", __FILE__)
5
- require "rails/test_help"
6
- require 'capybara/rails'
7
-
8
- Rails.backtrace_cleaner.remove_silencers!
9
-
10
- # Load support files
11
- Dir["#{File.dirname(__FILE__)}/dummy/test/support/**/*.rb"].each { |f| require f }
12
-
13
- # Load fixtures from the engine
14
- if ActiveSupport::TestCase.method_defined?(:fixture_path=)
15
- ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
16
- end
17
-
18
- class ActionDispatch::IntegrationTest
19
- # Make the Capybara DSL available in all integration tests
20
- include Capybara::DSL
21
- end