radiant-shop-extension 0.9.3 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. data/README.md +9 -3
  2. data/Rakefile +1 -0
  3. data/VERSION +1 -1
  4. data/app/controllers/admin/shop/customers_controller.rb +35 -126
  5. data/app/controllers/shop/categories_controller.rb +1 -5
  6. data/app/controllers/shop/products_controller.rb +1 -1
  7. data/app/models/form_checkout.rb +198 -112
  8. data/app/models/shop_category.rb +3 -3
  9. data/app/models/shop_customer.rb +3 -12
  10. data/app/models/shop_order.rb +5 -3
  11. data/app/models/shop_payment.rb +0 -1
  12. data/app/models/shop_product.rb +3 -3
  13. data/app/views/admin/shop/customers/edit.html.haml +13 -0
  14. data/app/views/admin/shop/customers/edit/_fields.html.haml +33 -0
  15. data/app/views/admin/shop/customers/edit/_head.html.haml +2 -0
  16. data/app/views/admin/shop/customers/edit/_meta.html.haml +7 -0
  17. data/app/views/admin/shop/customers/edit/_parts.html.haml +4 -0
  18. data/app/views/admin/shop/customers/edit/_popups.html.haml +3 -0
  19. data/app/views/admin/shop/customers/edit/meta/_login.html.haml +5 -0
  20. data/app/views/admin/shop/customers/edit/meta/_password.html.haml +5 -0
  21. data/app/views/admin/shop/customers/edit/meta/_password_confirmation.html.haml +5 -0
  22. data/app/views/admin/shop/customers/edit/parts/_address.html.haml +7 -0
  23. data/app/views/admin/shop/customers/edit/parts/_addresses.html.haml +13 -0
  24. data/app/views/admin/shop/customers/edit/parts/_orders.html.haml +29 -0
  25. data/app/views/admin/shop/customers/index.html.haml +9 -35
  26. data/app/views/admin/shop/customers/index/_bottom.html.haml +4 -0
  27. data/app/views/admin/shop/customers/index/_customer.html.haml +9 -0
  28. data/app/views/admin/shop/customers/new.html.haml +11 -0
  29. data/app/views/admin/shop/customers/remove.html.haml +12 -0
  30. data/app/views/admin/shop/products/new.html.haml +1 -1
  31. data/config/locales/en.yml +37 -29
  32. data/config/routes.rb +2 -0
  33. data/db/migrate/20100927041219_remove_payment_methods.rb +16 -0
  34. data/db/migrate/20100927041624_change_payments_add_gateway.rb +11 -0
  35. data/db/migrate/20100927140446_change_payment_add_card_type_card_number.rb +11 -0
  36. data/db/seed.rb +1 -0
  37. data/db/seeds/forms.rb +179 -0
  38. data/db/{migrate/20100520033059_create_layouts.rb → seeds/layouts.rb} +19 -27
  39. data/db/seeds/snippets.rb +23 -0
  40. data/lib/shop/interface/customers.rb +34 -0
  41. data/lib/shop/tags/address.rb +1 -0
  42. data/lib/shop/tags/card.rb +51 -0
  43. data/lib/shop/tags/helpers.rb +53 -38
  44. data/lib/shop/tags/item.rb +1 -1
  45. data/lib/shop/tags/product.rb +23 -22
  46. data/lib/shop/tags/responses.rb +3 -3
  47. data/lib/tasks/shop_extension_tasks.rake +6 -0
  48. data/public/stylesheets/sass/admin/extensions/shop/index.sass +64 -0
  49. data/radiant-shop-extension.gemspec +37 -6
  50. data/shop_extension.rb +7 -2
  51. data/spec/datasets/forms.rb +112 -118
  52. data/spec/datasets/shop_customers.rb +30 -0
  53. data/spec/datasets/shop_orders.rb +7 -3
  54. data/spec/datasets/shop_products.rb +1 -0
  55. data/spec/lib/shop/tags/card_spec.rb +71 -0
  56. data/spec/lib/shop/tags/helpers_spec.rb +270 -283
  57. data/spec/lib/shop/tags/item_spec.rb +9 -0
  58. data/spec/lib/shop/tags/product_spec.rb +172 -158
  59. data/spec/lib/shop/tags/responses_spec.rb +129 -0
  60. data/spec/models/form_checkout_spec.rb +228 -294
  61. data/spec/models/shop_category_page_spec.rb +2 -2
  62. data/spec/models/shop_order_spec.rb +27 -20
  63. data/spec/models/shop_product_attachment_spec.rb +1 -0
  64. metadata +61 -17
  65. data/app/models/shop_payment_method.rb +0 -5
  66. data/db/migrate/20100903122123_create_forms.rb +0 -44
  67. data/db/migrate/20100908063639_create_snippets.rb +0 -22
@@ -3,8 +3,8 @@ require 'spec/spec_helper'
3
3
  describe ShopCategoryPage do
4
4
 
5
5
  it 'should not have a cache' do
6
- s = ShopProductPage.new
7
- s.cache?.should === false
6
+ page = ShopCategoryPage.new
7
+ page.cache?.should === false
8
8
  end
9
9
 
10
10
  end
@@ -27,51 +27,58 @@ describe ShopOrder do
27
27
  describe '#new?' do
28
28
  context 'success' do
29
29
  it 'should return true' do
30
- shop_orders(:empty).update_attribute(:status, 'new')
31
- shop_orders(:empty).new?.should === true
30
+ shop_orders(:one_item).update_attribute(:status, 'new')
31
+ shop_orders(:one_item).new?.should === true
32
32
  end
33
33
  end
34
34
  context 'failure' do
35
35
  it 'should return false' do
36
- shop_orders(:empty).update_attribute(:status, 'paid')
37
- shop_orders(:empty).new?.should === false
36
+ shop_orders(:one_item).update_attribute(:status, 'paid')
37
+ shop_orders(:one_item).new?.should === false
38
38
 
39
- shop_orders(:empty).update_attribute(:status, 'shipped')
40
- shop_orders(:empty).new?.should === false
39
+ shop_orders(:one_item).update_attribute(:status, 'shipped')
40
+ shop_orders(:one_item).new?.should === false
41
41
  end
42
42
  end
43
43
  end
44
- describe '#paid?' do
44
+ describe '#shipped?' do
45
45
  context 'success' do
46
46
  it 'should return true' do
47
- shop_orders(:empty).update_attribute(:status, 'paid')
48
- shop_orders(:empty).paid?.should === true
47
+ shop_orders(:one_item).update_attribute(:status, 'shipped')
48
+ shop_orders(:one_item).shipped?.should === true
49
49
  end
50
50
  end
51
51
  context 'failure' do
52
52
  it 'should return false' do
53
- shop_orders(:empty).update_attribute(:status, 'new')
54
- shop_orders(:empty).paid?.should === false
53
+ shop_orders(:one_item).update_attribute(:status, 'new')
54
+ shop_orders(:one_item).shipped?.should === false
55
55
 
56
- shop_orders(:empty).update_attribute(:status, 'shipped')
57
- shop_orders(:empty).paid?.should === false
56
+ shop_orders(:one_item).update_attribute(:status, 'paid')
57
+ shop_orders(:one_item).shipped?.should === false
58
58
  end
59
59
  end
60
60
  end
61
- describe '#shipped?' do
61
+ describe '#paid?' do
62
62
  context 'success' do
63
63
  it 'should return true' do
64
- shop_orders(:empty).update_attribute(:status, 'shipped')
65
- shop_orders(:empty).shipped?.should === true
64
+ payment = ShopPayment.create({
65
+ :amount => shop_orders(:one_item).price,
66
+ :card_number => '1234',
67
+ :card_type => 'visa',
68
+ :gateway => 'Eway',
69
+ :order => shop_orders(:one_item)
70
+ })
71
+ shop_orders(:one_item).update_attribute(:status, 'paid')
72
+ shop_orders(:one_item).paid?.should === true
66
73
  end
67
74
  end
68
75
  context 'failure' do
69
76
  it 'should return false' do
70
- shop_orders(:empty).update_attribute(:status, 'new')
71
- shop_orders(:empty).shipped?.should === false
77
+ shop_orders(:one_item).update_attribute(:status, 'new')
78
+ shop_orders(:one_item).paid?.should === false
72
79
 
73
- shop_orders(:empty).update_attribute(:status, 'paid')
74
- shop_orders(:empty).shipped?.should === false
80
+ shop_orders(:one_item).update_attribute(:status, 'shipped')
81
+ shop_orders(:one_item).paid?.should === false
75
82
  end
76
83
  end
77
84
  end
@@ -34,6 +34,7 @@ describe ShopProductAttachment do
34
34
  context 'alias methods' do
35
35
 
36
36
  before(:each) do
37
+ stub(AWS::S3::Base).establish_connection!
37
38
  @product_image = shop_products(:soft_bread).attachments.first
38
39
  end
39
40
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: radiant-shop-extension
3
3
  version: !ruby/object:Gem::Version
4
- hash: 61
4
+ hash: 55
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 9
9
- - 3
10
- version: 0.9.3
8
+ - 10
9
+ - 0
10
+ version: 0.10.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Dirk Kelly
@@ -16,13 +16,29 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-09-24 00:00:00 +08:00
19
+ date: 2010-09-28 00:00:00 +08:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
23
- name: radiant-forms-extension
23
+ name: radiant
24
24
  prerelease: false
25
25
  requirement: &id001 !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ">="
29
+ - !ruby/object:Gem::Version
30
+ hash: 57
31
+ segments:
32
+ - 0
33
+ - 9
34
+ - 1
35
+ version: 0.9.1
36
+ type: :runtime
37
+ version_requirements: *id001
38
+ - !ruby/object:Gem::Dependency
39
+ name: radiant-forms-extension
40
+ prerelease: false
41
+ requirement: &id002 !ruby/object:Gem::Requirement
26
42
  none: false
27
43
  requirements:
28
44
  - - ">="
@@ -34,11 +50,11 @@ dependencies:
34
50
  - 0
35
51
  version: 3.1.0
36
52
  type: :runtime
37
- version_requirements: *id001
53
+ version_requirements: *id002
38
54
  - !ruby/object:Gem::Dependency
39
55
  name: radiant-images-extension
40
56
  prerelease: false
41
- requirement: &id002 !ruby/object:Gem::Requirement
57
+ requirement: &id003 !ruby/object:Gem::Requirement
42
58
  none: false
43
59
  requirements:
44
60
  - - ">="
@@ -50,11 +66,11 @@ dependencies:
50
66
  - 0
51
67
  version: 0.2.0
52
68
  type: :runtime
53
- version_requirements: *id002
69
+ version_requirements: *id003
54
70
  - !ruby/object:Gem::Dependency
55
71
  name: radiant-layouts-extension
56
72
  prerelease: false
57
- requirement: &id003 !ruby/object:Gem::Requirement
73
+ requirement: &id004 !ruby/object:Gem::Requirement
58
74
  none: false
59
75
  requirements:
60
76
  - - ">="
@@ -66,11 +82,11 @@ dependencies:
66
82
  - 1
67
83
  version: 0.9.1
68
84
  type: :runtime
69
- version_requirements: *id003
85
+ version_requirements: *id004
70
86
  - !ruby/object:Gem::Dependency
71
87
  name: radiant-settings-extension
72
88
  prerelease: false
73
- requirement: &id004 !ruby/object:Gem::Requirement
89
+ requirement: &id005 !ruby/object:Gem::Requirement
74
90
  none: false
75
91
  requirements:
76
92
  - - ">="
@@ -82,7 +98,7 @@ dependencies:
82
98
  - 1
83
99
  version: 1.1.1
84
100
  type: :runtime
85
- version_requirements: *id004
101
+ version_requirements: *id005
86
102
  description: Radiant Shop is an attempt at a simple but complete store. It includes Products, Categories, Orders and Credit Card Payments
87
103
  email: dk@dirkkelly.com
88
104
  executables: []
@@ -120,7 +136,6 @@ files:
120
136
  - app/models/shop_line_item.rb
121
137
  - app/models/shop_order.rb
122
138
  - app/models/shop_payment.rb
123
- - app/models/shop_payment_method.rb
124
139
  - app/models/shop_product.rb
125
140
  - app/models/shop_product_attachment.rb
126
141
  - app/models/shop_product_page.rb
@@ -140,7 +155,23 @@ files:
140
155
  - app/views/admin/shop/categories/index/_category.html.haml
141
156
  - app/views/admin/shop/categories/new.html.haml
142
157
  - app/views/admin/shop/categories/remove.html.haml
158
+ - app/views/admin/shop/customers/edit.html.haml
159
+ - app/views/admin/shop/customers/edit/_fields.html.haml
160
+ - app/views/admin/shop/customers/edit/_head.html.haml
161
+ - app/views/admin/shop/customers/edit/_meta.html.haml
162
+ - app/views/admin/shop/customers/edit/_parts.html.haml
163
+ - app/views/admin/shop/customers/edit/_popups.html.haml
164
+ - app/views/admin/shop/customers/edit/meta/_login.html.haml
165
+ - app/views/admin/shop/customers/edit/meta/_password.html.haml
166
+ - app/views/admin/shop/customers/edit/meta/_password_confirmation.html.haml
167
+ - app/views/admin/shop/customers/edit/parts/_address.html.haml
168
+ - app/views/admin/shop/customers/edit/parts/_addresses.html.haml
169
+ - app/views/admin/shop/customers/edit/parts/_orders.html.haml
143
170
  - app/views/admin/shop/customers/index.html.haml
171
+ - app/views/admin/shop/customers/index/_bottom.html.haml
172
+ - app/views/admin/shop/customers/index/_customer.html.haml
173
+ - app/views/admin/shop/customers/new.html.haml
174
+ - app/views/admin/shop/customers/remove.html.haml
144
175
  - app/views/admin/shop/orders/index.html.haml
145
176
  - app/views/admin/shop/products/edit.html.haml
146
177
  - app/views/admin/shop/products/edit/_fields.html.haml
@@ -171,17 +202,23 @@ files:
171
202
  - config/shop_cart.yml
172
203
  - cucumber.yml
173
204
  - db/migrate/20100311053701_initial.rb
174
- - db/migrate/20100520033059_create_layouts.rb
175
- - db/migrate/20100903122123_create_forms.rb
176
- - db/migrate/20100908063639_create_snippets.rb
205
+ - db/migrate/20100927041219_remove_payment_methods.rb
206
+ - db/migrate/20100927041624_change_payments_add_gateway.rb
207
+ - db/migrate/20100927140446_change_payment_add_card_type_card_number.rb
208
+ - db/seed.rb
209
+ - db/seeds/forms.rb
210
+ - db/seeds/layouts.rb
211
+ - db/seeds/snippets.rb
177
212
  - features/support/env.rb
178
213
  - features/support/paths.rb
179
214
  - lib/shop/controllers/application_controller.rb
180
215
  - lib/shop/controllers/site_controller.rb
216
+ - lib/shop/interface/customers.rb
181
217
  - lib/shop/interface/products.rb
182
218
  - lib/shop/models/image.rb
183
219
  - lib/shop/models/page.rb
184
220
  - lib/shop/tags/address.rb
221
+ - lib/shop/tags/card.rb
185
222
  - lib/shop/tags/cart.rb
186
223
  - lib/shop/tags/category.rb
187
224
  - lib/shop/tags/core.rb
@@ -196,6 +233,7 @@ files:
196
233
  - public/javascripts/admin/extensions/shop/products/edit.js
197
234
  - public/javascripts/admin/extensions/shop/products/index.js
198
235
  - public/stylesheets/sass/admin/extensions/shop/edit.sass
236
+ - public/stylesheets/sass/admin/extensions/shop/index.sass
199
237
  - public/stylesheets/sass/admin/extensions/shop/products/edit.sass
200
238
  - public/stylesheets/sass/admin/extensions/shop/products/index.sass
201
239
  - radiant-shop-extension.gemspec
@@ -212,6 +250,7 @@ files:
212
250
  - spec/datasets/images.rb
213
251
  - spec/datasets/shop_addresses.rb
214
252
  - spec/datasets/shop_categories.rb
253
+ - spec/datasets/shop_customers.rb
215
254
  - spec/datasets/shop_line_items.rb
216
255
  - spec/datasets/shop_orders.rb
217
256
  - spec/datasets/shop_products.rb
@@ -219,12 +258,14 @@ files:
219
258
  - spec/lib/shop/models/image_spec.rb
220
259
  - spec/lib/shop/models/page_spec.rb
221
260
  - spec/lib/shop/tags/address_spec.rb
261
+ - spec/lib/shop/tags/card_spec.rb
222
262
  - spec/lib/shop/tags/cart_spec.rb
223
263
  - spec/lib/shop/tags/category_spec.rb
224
264
  - spec/lib/shop/tags/core_spec.rb
225
265
  - spec/lib/shop/tags/helpers_spec.rb
226
266
  - spec/lib/shop/tags/item_spec.rb
227
267
  - spec/lib/shop/tags/product_spec.rb
268
+ - spec/lib/shop/tags/responses_spec.rb
228
269
  - spec/matchers/comparison.rb
229
270
  - spec/matchers/render_matcher.rb
230
271
  - spec/models/form_checkout_spec.rb
@@ -298,6 +339,7 @@ test_files:
298
339
  - spec/datasets/images.rb
299
340
  - spec/datasets/shop_addresses.rb
300
341
  - spec/datasets/shop_categories.rb
342
+ - spec/datasets/shop_customers.rb
301
343
  - spec/datasets/shop_line_items.rb
302
344
  - spec/datasets/shop_orders.rb
303
345
  - spec/datasets/shop_products.rb
@@ -305,12 +347,14 @@ test_files:
305
347
  - spec/lib/shop/models/image_spec.rb
306
348
  - spec/lib/shop/models/page_spec.rb
307
349
  - spec/lib/shop/tags/address_spec.rb
350
+ - spec/lib/shop/tags/card_spec.rb
308
351
  - spec/lib/shop/tags/cart_spec.rb
309
352
  - spec/lib/shop/tags/category_spec.rb
310
353
  - spec/lib/shop/tags/core_spec.rb
311
354
  - spec/lib/shop/tags/helpers_spec.rb
312
355
  - spec/lib/shop/tags/item_spec.rb
313
356
  - spec/lib/shop/tags/product_spec.rb
357
+ - spec/lib/shop/tags/responses_spec.rb
314
358
  - spec/matchers/comparison.rb
315
359
  - spec/matchers/render_matcher.rb
316
360
  - spec/models/form_checkout_spec.rb
@@ -1,5 +0,0 @@
1
- class ShopPaymentMethod < ActiveRecord::Base
2
-
3
- has_many :payments, :class_name => 'ShopPayment'
4
-
5
- end
@@ -1,44 +0,0 @@
1
- class CreateForms < ActiveRecord::Migration
2
- def self.up
3
- # Will only create a layout if it doesn't exist
4
- Form.create({
5
- :title => 'AddCartItem',
6
- :action => '/shop/cart/items',
7
- :body => <<-CONTENT
8
- <r:shop>
9
- <r:product>
10
- <input type="hidden" name="line_item[item_id]" value="<r:id />" />
11
- <!-- Your Customisation Below -->
12
-
13
- <r:form:text name='line_item[quantity]' /> <!-- Amount of items to add -->
14
- <input type="submit" name="add_to_cart" id="add_to_cart_<r:id />" value="Add To Cart" />
15
-
16
- <!-- Your Customisation Above -->
17
- </r:product>
18
- </r:shop>
19
- CONTENT
20
- })
21
-
22
- Form.create({
23
- :title => 'UpdateCartItem',
24
- :action => '/shop/cart/items/x',
25
- :body => <<-CONTENT
26
- <r:shop:cart>
27
- <r:item>
28
- <input type="hidden" name="_method" value="put" />
29
- <input type="hidden" name="line_item[id]" value="<r:item:id />" />
30
- <!-- Your Customisation Below -->
31
-
32
- <input type="text" name="line_item[quantity]" value="" />
33
- <input type="submit" name="add_to_cart" id="update_<r:id />" value="Update" />
34
-
35
- <!-- Your Customisation Above -->
36
- </r:item>
37
- </r:shop:cart>
38
- CONTENT
39
- })
40
- end
41
-
42
- def self.down
43
- end
44
- end
@@ -1,22 +0,0 @@
1
- class CreateSnippets < ActiveRecord::Migration
2
- def self.up
3
- Snippet.create({
4
- :name => 'CartOverview',
5
- :content => <<-BEGIN
6
- <r:shop:cart>
7
- <r:if_items>
8
- <span class="quantity"><r:quantity /></span>
9
- <span class="price"><r:price /></span>
10
- <r:link>checkout</r:link>
11
- </r:if_items>
12
- <r:unless_items>
13
- <p>Your cart is empty</p>
14
- </r:unless_items>
15
- </r:shop:cart>
16
- BEGIN
17
- })
18
- end
19
-
20
- def self.down
21
- end
22
- end