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
@@ -59,7 +59,7 @@ module Shop
59
59
  end
60
60
 
61
61
  # Output the related elements attributes
62
- [:name, :price, :weight].each do |symbol|
62
+ [:name, :sku, :price, :weight].each do |symbol|
63
63
  desc %{ outputs the #{symbol} of the current cart item }
64
64
  tag "shop:cart:item:#{symbol}" do |tag|
65
65
  tag.locals.shop_line_item.item.send(symbol)
@@ -15,15 +15,16 @@ module Shop
15
15
  end
16
16
 
17
17
  tag 'shop:products' do |tag|
18
+ tag.locals.shop_products = Helpers.current_products(tag)
19
+
18
20
  tag.expand
19
21
  end
20
22
 
21
23
  desc %{ iterates through each product within the scope }
22
24
  tag 'shop:products:each' do |tag|
23
- content = ''
24
- products = Helpers.current_products(tag)
25
+ content = ''
25
26
 
26
- products.each do |product|
27
+ tag.locals.shop_products.each do |product|
27
28
  tag.locals.shop_product = product
28
29
  content << tag.expand
29
30
  end
@@ -33,7 +34,8 @@ module Shop
33
34
 
34
35
  tag 'shop:product' do |tag|
35
36
  tag.locals.shop_product = Helpers.current_product(tag)
36
- tag.expand unless tag.locals.shop_product.nil?
37
+
38
+ tag.expand if tag.locals.shop_product.present?
37
39
  end
38
40
 
39
41
  [:id, :name, :sku, :slug].each do |symbol|
@@ -50,53 +52,52 @@ module Shop
50
52
 
51
53
  desc %{ generates a link to the products generated page }
52
54
  tag 'shop:product:link' do |tag|
53
- product = tag.locals.shop_product
54
55
  options = tag.attr.dup
55
56
  attributes = options.inject('') { |s, (k, v)| s << %{#{k.downcase}="#{v}" } }.strip
56
- attributes = " #{attributes}" unless attributes.empty?
57
+ attributes = " #{attributes}" if attributes.present?
57
58
 
58
- text = tag.double? ? tag.expand : product.name
59
+ text = tag.double? ? tag.expand : tag.locals.shop_product.name
59
60
 
60
- %{<a href="#{product.slug}"#{attributes}>#{text}</a>}
61
+ %{<a href="#{tag.locals.shop_product.slug}"#{attributes}>#{text}</a>}
61
62
  end
62
63
 
63
64
  desc %{ outputs the slug to the products generated page }
64
65
  tag 'shop:product:slug' do |tag|
65
- product = tag.locals.shop_product
66
- product.slug unless product.nil?
66
+ tag.locals.shop_product.slug
67
67
  end
68
68
 
69
69
  desc %{ output price of product }
70
70
  tag 'shop:product:price' do |tag|
71
71
  attr = tag.attr.symbolize_keys
72
- product = tag.locals.shop_product
73
-
74
- number_to_currency(product.price,
72
+
73
+ number_to_currency(tag.locals.shop_product.price,
75
74
  :precision =>(attr[:precision] || Radiant::Config['shop.price_precision']).to_i,
76
75
  :unit => attr[:unit] || Radiant::Config['shop.price_unit'],
77
76
  :separator => attr[:separator] || Radiant::Config['shop.price_seperator'],
78
77
  :delimiter => attr[:delimiter] || Radiant::Config['shop.price_delimiter'])
79
78
  end
80
79
 
81
- desc %{ expands if the product has a valid image }
82
- tag 'shop:product:if_images' do |tag|
83
- tag.expand unless tag.locals.shop_product.images.empty?
80
+ tag 'shop:product:images' do |tag|
81
+ tag.locals.images = tag.locals.shop_product.attachments
82
+
83
+ tag.expand
84
84
  end
85
85
 
86
- desc %{ expands if the product does not have a valid image }
87
- tag 'shop:product:unless_images' do |tag|
88
- tag.expand if tag.locals.shop_product.images.empty?
86
+ desc %{ expands if the product has a valid image }
87
+ tag 'shop:product:images:if_images' do |tag|
88
+ tag.expand if tag.locals.images.present?
89
89
  end
90
90
 
91
- tag 'shop:product:images' do |tag|
92
- tag.expand
91
+ desc %{ expands if the product does not have a valid image }
92
+ tag 'shop:product:images:unless_images' do |tag|
93
+ tag.expand unless tag.locals.images.present?
93
94
  end
94
95
 
95
96
  desc %{ iterates through each of the products images }
96
97
  tag 'shop:product:images:each' do |tag|
97
98
  content = ''
98
99
 
99
- tag.locals.shop_product.images.each do |image|
100
+ tag.locals.images.each do |image|
100
101
  tag.locals.image = image
101
102
  content << tag.expand
102
103
  end
@@ -14,19 +14,19 @@ module Shop
14
14
  # Expand if there is a checkout payment response
15
15
  desc %{ Expand if there is a checkout payment response }
16
16
  tag 'response:checkout:payment' do |tag|
17
- tag.expand if tag.locals.response_checkout[:payment].present?
17
+ tag.expand
18
18
  end
19
19
 
20
20
  # Expand if the payment was successful
21
21
  desc %{ Expand if the payment was successful }
22
22
  tag 'response:checkout:payment:if_success' do |tag|
23
- tag.expand if tag.locals.response_checkout[:payment][:success]
23
+ tag.expand if tag.locals.response_checkout[:payment] === true
24
24
  end
25
25
 
26
26
  # Expand if the payment was not successful
27
27
  desc %{ Expand if the payment was not successful }
28
28
  tag 'response:checkout:payment:unless_success' do |tag|
29
- tag.expand unless tag.locals.response_checkout[:payment][:success]
29
+ tag.expand if tag.locals.response_checkout[:payment] === false
30
30
  end
31
31
 
32
32
  end
@@ -13,6 +13,12 @@ namespace :radiant do
13
13
  Rake::Task['db:schema:dump'].invoke
14
14
  end
15
15
 
16
+ desc "Runs the migration of the Shop extension"
17
+ task :seed => :environment do
18
+ load "#{ShopExtension.root}/db/seed.rb"
19
+ end
20
+
21
+
16
22
  desc "Copies public assets of the Shop to the instance public/ directory."
17
23
  task :update => :environment do
18
24
  is_svn_or_dir = proc {|path| path =~ /\.svn/ || File.directory?(path) }
@@ -0,0 +1,64 @@
1
+ .map
2
+ border:
3
+ top: 21px #9e9e9e solid
4
+
5
+ .object
6
+ position: relative
7
+ height: 45px
8
+ line:
9
+ height: 45px
10
+ margin:
11
+ bottom: 2px
12
+
13
+ .attributes
14
+ padding:
15
+ left: 5px
16
+ border:
17
+ bottom: 1px solid #cecece
18
+
19
+ &:hover
20
+ background:
21
+ color: #e0f0ff
22
+
23
+ .name, .name a
24
+ color: black
25
+ font:
26
+ weight: bold
27
+ size: 16px
28
+ text:
29
+ decoration: none
30
+
31
+ &:hover
32
+ color: #0066ce
33
+ text:
34
+ decoration: underline
35
+
36
+ .modify
37
+ float: right
38
+ width: 200px
39
+ text:
40
+ align: right
41
+ font:
42
+ size: 10px
43
+
44
+ span
45
+ padding:
46
+ left: 15px
47
+ right: 15px
48
+
49
+ a
50
+ color: black
51
+ text:
52
+ decoration: none
53
+
54
+ .add_child
55
+ background:
56
+ image: url(/images/admin/plus.png)
57
+ repeat: no-repeat
58
+ position: 0 50%
59
+
60
+ .remove
61
+ background:
62
+ image: url(/images/admin/minus.png)
63
+ repeat: no-repeat
64
+ position: 0 50%
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{radiant-shop-extension}
8
- s.version = "0.9.3"
8
+ s.version = "0.10.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Dirk Kelly", "John Barker"]
12
- s.date = %q{2010-09-24}
12
+ s.date = %q{2010-09-28}
13
13
  s.description = %q{Radiant Shop is an attempt at a simple but complete store. It includes Products, Categories, Orders and Credit Card Payments}
14
14
  s.email = %q{dk@dirkkelly.com}
15
15
  s.extra_rdoc_files = [
@@ -44,7 +44,6 @@ Gem::Specification.new do |s|
44
44
  "app/models/shop_line_item.rb",
45
45
  "app/models/shop_order.rb",
46
46
  "app/models/shop_payment.rb",
47
- "app/models/shop_payment_method.rb",
48
47
  "app/models/shop_product.rb",
49
48
  "app/models/shop_product_attachment.rb",
50
49
  "app/models/shop_product_page.rb",
@@ -64,7 +63,23 @@ Gem::Specification.new do |s|
64
63
  "app/views/admin/shop/categories/index/_category.html.haml",
65
64
  "app/views/admin/shop/categories/new.html.haml",
66
65
  "app/views/admin/shop/categories/remove.html.haml",
66
+ "app/views/admin/shop/customers/edit.html.haml",
67
+ "app/views/admin/shop/customers/edit/_fields.html.haml",
68
+ "app/views/admin/shop/customers/edit/_head.html.haml",
69
+ "app/views/admin/shop/customers/edit/_meta.html.haml",
70
+ "app/views/admin/shop/customers/edit/_parts.html.haml",
71
+ "app/views/admin/shop/customers/edit/_popups.html.haml",
72
+ "app/views/admin/shop/customers/edit/meta/_login.html.haml",
73
+ "app/views/admin/shop/customers/edit/meta/_password.html.haml",
74
+ "app/views/admin/shop/customers/edit/meta/_password_confirmation.html.haml",
75
+ "app/views/admin/shop/customers/edit/parts/_address.html.haml",
76
+ "app/views/admin/shop/customers/edit/parts/_addresses.html.haml",
77
+ "app/views/admin/shop/customers/edit/parts/_orders.html.haml",
67
78
  "app/views/admin/shop/customers/index.html.haml",
79
+ "app/views/admin/shop/customers/index/_bottom.html.haml",
80
+ "app/views/admin/shop/customers/index/_customer.html.haml",
81
+ "app/views/admin/shop/customers/new.html.haml",
82
+ "app/views/admin/shop/customers/remove.html.haml",
68
83
  "app/views/admin/shop/orders/index.html.haml",
69
84
  "app/views/admin/shop/products/edit.html.haml",
70
85
  "app/views/admin/shop/products/edit/_fields.html.haml",
@@ -95,17 +110,23 @@ Gem::Specification.new do |s|
95
110
  "config/shop_cart.yml",
96
111
  "cucumber.yml",
97
112
  "db/migrate/20100311053701_initial.rb",
98
- "db/migrate/20100520033059_create_layouts.rb",
99
- "db/migrate/20100903122123_create_forms.rb",
100
- "db/migrate/20100908063639_create_snippets.rb",
113
+ "db/migrate/20100927041219_remove_payment_methods.rb",
114
+ "db/migrate/20100927041624_change_payments_add_gateway.rb",
115
+ "db/migrate/20100927140446_change_payment_add_card_type_card_number.rb",
116
+ "db/seed.rb",
117
+ "db/seeds/forms.rb",
118
+ "db/seeds/layouts.rb",
119
+ "db/seeds/snippets.rb",
101
120
  "features/support/env.rb",
102
121
  "features/support/paths.rb",
103
122
  "lib/shop/controllers/application_controller.rb",
104
123
  "lib/shop/controllers/site_controller.rb",
124
+ "lib/shop/interface/customers.rb",
105
125
  "lib/shop/interface/products.rb",
106
126
  "lib/shop/models/image.rb",
107
127
  "lib/shop/models/page.rb",
108
128
  "lib/shop/tags/address.rb",
129
+ "lib/shop/tags/card.rb",
109
130
  "lib/shop/tags/cart.rb",
110
131
  "lib/shop/tags/category.rb",
111
132
  "lib/shop/tags/core.rb",
@@ -120,6 +141,7 @@ Gem::Specification.new do |s|
120
141
  "public/javascripts/admin/extensions/shop/products/edit.js",
121
142
  "public/javascripts/admin/extensions/shop/products/index.js",
122
143
  "public/stylesheets/sass/admin/extensions/shop/edit.sass",
144
+ "public/stylesheets/sass/admin/extensions/shop/index.sass",
123
145
  "public/stylesheets/sass/admin/extensions/shop/products/edit.sass",
124
146
  "public/stylesheets/sass/admin/extensions/shop/products/index.sass",
125
147
  "radiant-shop-extension.gemspec",
@@ -136,6 +158,7 @@ Gem::Specification.new do |s|
136
158
  "spec/datasets/images.rb",
137
159
  "spec/datasets/shop_addresses.rb",
138
160
  "spec/datasets/shop_categories.rb",
161
+ "spec/datasets/shop_customers.rb",
139
162
  "spec/datasets/shop_line_items.rb",
140
163
  "spec/datasets/shop_orders.rb",
141
164
  "spec/datasets/shop_products.rb",
@@ -143,12 +166,14 @@ Gem::Specification.new do |s|
143
166
  "spec/lib/shop/models/image_spec.rb",
144
167
  "spec/lib/shop/models/page_spec.rb",
145
168
  "spec/lib/shop/tags/address_spec.rb",
169
+ "spec/lib/shop/tags/card_spec.rb",
146
170
  "spec/lib/shop/tags/cart_spec.rb",
147
171
  "spec/lib/shop/tags/category_spec.rb",
148
172
  "spec/lib/shop/tags/core_spec.rb",
149
173
  "spec/lib/shop/tags/helpers_spec.rb",
150
174
  "spec/lib/shop/tags/item_spec.rb",
151
175
  "spec/lib/shop/tags/product_spec.rb",
176
+ "spec/lib/shop/tags/responses_spec.rb",
152
177
  "spec/matchers/comparison.rb",
153
178
  "spec/matchers/render_matcher.rb",
154
179
  "spec/models/form_checkout_spec.rb",
@@ -194,6 +219,7 @@ Gem::Specification.new do |s|
194
219
  "spec/datasets/images.rb",
195
220
  "spec/datasets/shop_addresses.rb",
196
221
  "spec/datasets/shop_categories.rb",
222
+ "spec/datasets/shop_customers.rb",
197
223
  "spec/datasets/shop_line_items.rb",
198
224
  "spec/datasets/shop_orders.rb",
199
225
  "spec/datasets/shop_products.rb",
@@ -201,12 +227,14 @@ Gem::Specification.new do |s|
201
227
  "spec/lib/shop/models/image_spec.rb",
202
228
  "spec/lib/shop/models/page_spec.rb",
203
229
  "spec/lib/shop/tags/address_spec.rb",
230
+ "spec/lib/shop/tags/card_spec.rb",
204
231
  "spec/lib/shop/tags/cart_spec.rb",
205
232
  "spec/lib/shop/tags/category_spec.rb",
206
233
  "spec/lib/shop/tags/core_spec.rb",
207
234
  "spec/lib/shop/tags/helpers_spec.rb",
208
235
  "spec/lib/shop/tags/item_spec.rb",
209
236
  "spec/lib/shop/tags/product_spec.rb",
237
+ "spec/lib/shop/tags/responses_spec.rb",
210
238
  "spec/matchers/comparison.rb",
211
239
  "spec/matchers/render_matcher.rb",
212
240
  "spec/models/form_checkout_spec.rb",
@@ -225,17 +253,20 @@ Gem::Specification.new do |s|
225
253
  s.specification_version = 3
226
254
 
227
255
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
256
+ s.add_runtime_dependency(%q<radiant>, [">= 0.9.1"])
228
257
  s.add_runtime_dependency(%q<radiant-forms-extension>, [">= 3.1.0"])
229
258
  s.add_runtime_dependency(%q<radiant-images-extension>, [">= 0.2.0"])
230
259
  s.add_runtime_dependency(%q<radiant-layouts-extension>, [">= 0.9.1"])
231
260
  s.add_runtime_dependency(%q<radiant-settings-extension>, [">= 1.1.1"])
232
261
  else
262
+ s.add_dependency(%q<radiant>, [">= 0.9.1"])
233
263
  s.add_dependency(%q<radiant-forms-extension>, [">= 3.1.0"])
234
264
  s.add_dependency(%q<radiant-images-extension>, [">= 0.2.0"])
235
265
  s.add_dependency(%q<radiant-layouts-extension>, [">= 0.9.1"])
236
266
  s.add_dependency(%q<radiant-settings-extension>, [">= 1.1.1"])
237
267
  end
238
268
  else
269
+ s.add_dependency(%q<radiant>, [">= 0.9.1"])
239
270
  s.add_dependency(%q<radiant-forms-extension>, [">= 3.1.0"])
240
271
  s.add_dependency(%q<radiant-images-extension>, [">= 0.2.0"])
241
272
  s.add_dependency(%q<radiant-layouts-extension>, [">= 0.9.1"])
data/shop_extension.rb CHANGED
@@ -17,10 +17,11 @@ class ShopExtension < Radiant::Extension
17
17
 
18
18
  # View Hooks
19
19
  unless defined? admin.products
20
- Radiant::AdminUI.send :include, Shop::Interface::Products
20
+ Radiant::AdminUI.send :include, Shop::Interface::Products, Shop::Interface::Customers
21
21
 
22
22
  admin.products = Radiant::AdminUI.load_default_shop_products_regions
23
23
  admin.categories = Radiant::AdminUI.load_default_shop_categories_regions
24
+ admin.customers = Radiant::AdminUI.load_default_shop_customers_regions
24
25
  end
25
26
 
26
27
  if admin.respond_to? :page
@@ -29,7 +30,7 @@ class ShopExtension < Radiant::Extension
29
30
  end
30
31
 
31
32
  # Tags
32
- Page.send :include, Shop::Tags::Core, Shop::Tags::Cart, Shop::Tags::Category, Shop::Tags::Item, Shop::Tags::Product, Shop::Tags::Address, Shop::Tags::Responses
33
+ Page.send :include, Shop::Tags::Core, Shop::Tags::Cart, Shop::Tags::Category, Shop::Tags::Item, Shop::Tags::Product, Shop::Tags::Address, Shop::Tags::Responses, Shop::Tags::Card
33
34
 
34
35
  # Model Includes
35
36
  Page.send :include, Shop::Models::Page
@@ -42,6 +43,7 @@ class ShopExtension < Radiant::Extension
42
43
  # Tabs3
43
44
  tab "Shop" do
44
45
  add_item "Products", "/admin/shop"
46
+ add_item "Customers", "/admin/shop/customers"
45
47
  end
46
48
 
47
49
  # Ensure there is always a shop prefix, otherwise we'll lose admin and pages
@@ -57,6 +59,9 @@ class ShopExtension < Radiant::Extension
57
59
  Radiant::Config['shop.price_precision'] ||= 2
58
60
  Radiant::Config['shop.price_seperator'] ||= '.'
59
61
  Radiant::Config['shop.price_delimiter'] ||= ','
62
+
63
+ # Scoped Customer Welcome Page
64
+ Radiant::Config['scoped.customer.redirect'] = '/cart'
60
65
  end
61
66
 
62
67
  end
@@ -1,4 +1,7 @@
1
1
  class FormsDataset < Dataset::Base
2
+
3
+ uses :pages, :shop_orders
4
+
2
5
  def load
3
6
  create_record :form, :checkout,
4
7
  :title => 'Checkout',
@@ -10,122 +13,38 @@ class FormsDataset < Dataset::Base
10
13
  def body
11
14
  <<-BODY
12
15
  <r:shop:cart>
13
- <ul class="items">
14
- <r:items:each:item>
15
- <li class="item"><r:quantity /> x <r:name /></li>
16
- </r:items:each:item>
17
- </ul>
18
- <div class="addresses">
19
- <ol class="billing">
20
- <li>
21
- <r:label for='billing[name]'>Name</r:label>
22
- <r:text name='billing[name]' />
23
- </li>
24
- <li>
25
- <r:label for='billing[unit]'>Unit</r:label>
26
- <r:text name='billing[unit]' />
27
- </li>
28
- <li>
29
- <r:label for='billing[street]'>Street</r:label>
30
- <r:text name='billing[street]' />
31
- </li>
16
+ <div class="addresses">
17
+ <ol class="billing">
18
+ <li>
19
+ <r:label for='billing[name]'>Name</r:label>
20
+ <r:text name='billing[name]' />
21
+ </li>
22
+ <li>
23
+ <r:label for='billing[unit]'>Address</r:label>
24
+ <r:text name='billing[unit]' /> <r:text name='billing[street]' /> <r:text name='billing[suburb]' />
25
+ </li>
26
+ <li>
27
+ <r:label for='billing[state]'>State and Country</r:label>
28
+ <r:text name='billing[state]' /> <r:text name='billing[country]' />
29
+ </li>
30
+ <li>
31
+ <r:label for='billing[postcode]'>Postcode</r:label>
32
+ <r:text name='billing[postcode]' />
33
+ </li>
34
+ </ol>
35
+ </div>
36
+ <ol class="card">
32
37
  <li>
33
- <r:label for='billing[suburb]'>Suburb</r:label>
34
- <r:text name='billing[suburb]' />
38
+ <r:label for='card[name]'>Name on Card</r:label>
39
+ <r:text name='card[name]' />
35
40
  </li>
36
41
  <li>
37
- <r:label for='billing[state]'>State</r:label>
38
- <r:text name='billing[state]' />
39
- </li>
40
- <li>
41
- <r:label for='billing[postcode]'>Postcode</r:label>
42
- <r:text name='billing[postcode]' />
43
- </li>
44
- <li>
45
- <r:label for='billing[country]'>Country</r:label>
46
- <r:text name='billing[country]' />
42
+ <r:label for='card[number]'>Card</r:label>
43
+ <r:card:type /> <r:text name='card[number]' /> <r:text name='card[verification]' length='4' />
44
+ <r:card:month /> <r:card:year />
47
45
  </li>
48
46
  </ol>
49
- <ol class="shipping">
50
- <li>
51
- <r:label for='shipping[name]'>Name</r:label>
52
- <r:text name='shipping[name]' />
53
- </li>
54
- <li>
55
- <r:label for='shipping[unit]'>Unit</r:label>
56
- <r:text name='shipping[unit]' />
57
- </li>
58
- <li>
59
- <r:label for='shipping[street]'>Street</r:label>
60
- <r:text name='shipping[street]' />
61
- </li>
62
- <li>
63
- <r:label for='shipping[suburb]'>Suburb</r:label>
64
- <r:text name='shipping[suburb]' />
65
- </li>
66
- <li>
67
- <r:label for='shipping[state]'>State</r:label>
68
- <r:text name='shipping[state]' />
69
- </li>
70
- <li>
71
- <r:label for='shipping[postcode]'>Postcode</r:label>
72
- <r:text name='shipping[postcode]' />
73
- </li>
74
- <li>
75
- <r:label for='shipping[country]'>Country</r:label>
76
- <r:text name='shipping[country]' />
77
- </li>
78
- </ol>
79
- </div>
80
- <ol class="card">
81
- <li>
82
- <r:label for='card[type]'>Type Card</r:label>
83
- <r:select name='card[type]'>
84
- <r:option value='visa'>Visa</r:option>
85
- <r:option value='mastercard'>Master Card</r:option>
86
- <r:option value='diners'>Diners Club</r:option>
87
- <r:option vlaue='amex'>AMEX</r:option>
88
- </r:select>
89
- </li>
90
- <li>
91
- <r:label for='card[name]'>Name on Card</r:label>
92
- <r:text name='card[name]' />
93
- </li>
94
- <li>
95
- <r:label for='card[number]'>Card Number</r:label>
96
- <r:text name='card[number]' />
97
- </li>
98
- <li>
99
- <r:label for='card[verification]'>Verification Code</r:label>
100
- <r:text name='card[verification]' length='4' />
101
- </li>
102
- <li>
103
- <r:label for='card[month]'>Date on Card</r:label>
104
- # Todo turns these into tags
105
- <r:select name='card[month]'>
106
- <r:option value='01'>01 - January</r:option>
107
- <r:option value='02'>02 - February</r:option>
108
- <r:option value='03'>03 - March</r:option>
109
- <r:option value='04'>04 - April</r:option>
110
- <r:option value='05'>05 - May</r:option>
111
- <r:option value='06'>06 - June</r:option>
112
- <r:option value='07'>07 - July</r:option>
113
- <r:option value='08'>08 - August</r:option>
114
- <r:option value='09'>09 - September</r:option>
115
- <r:option value='10'>10 - October</r:option>
116
- <r:option value='11'>11 - November</r:option>
117
- <r:option value='12'>12 - December</r:option>
118
- </r:select>
119
- <r:select name='card[year]'>
120
- <r:option value='2010'>2010</r:option>
121
- <r:option value='2011'>2011</r:option>
122
- <r:option value='2012'>2012</r:option>
123
- <r:option value='2013'>2013</r:option>
124
- <r:option value='2014'>2014</r:option>
125
- </r:select>
126
- </li>
127
- </ol>
128
- <r:form:submit />
47
+ <r:form:submit />
129
48
  </r:shop:cart>
130
49
  BODY
131
50
  end
@@ -139,15 +58,90 @@ CONTENT
139
58
  def config
140
59
  <<-CONFIG
141
60
  checkout:
142
- shipping:
143
- enabled: true
61
+ test: true
144
62
  gateway:
145
- name: PayWay
146
- username: 123456
147
- password: abcdef
148
- merchant: test
149
- pem: /var/www/certificate.pem
63
+ name: Bogus
64
+ credentials:
65
+ login: 123456
150
66
  CONFIG
151
67
  end
152
68
 
69
+ helpers do
70
+ def mock_page_with_request_and_data
71
+ @page = pages(:home)
72
+
73
+ @request = OpenStruct.new({
74
+ :session => {}
75
+ })
76
+ @data = {}
77
+
78
+ stub(@page).data { @data }
79
+ stub(@page).request { @request }
80
+ end
81
+
82
+ def mock_response
83
+ @response = OpenStruct.new({
84
+ :result => {
85
+ :results => {}
86
+ }
87
+ })
88
+ mock(Forms::Tags::Responses).current(anything,anything) { @response }
89
+ end
90
+
91
+ def mock_valid_form_checkout_request
92
+ @form = forms(:checkout)
93
+ @form[:extensions] = {
94
+ :checkout => {
95
+ :test => true,
96
+ :gateway => {
97
+ :name => 'Bogus'
98
+ },
99
+ :mail => {
100
+ :subject=> 'new order',
101
+ :bcc => 'orders@example.com'
102
+ },
103
+ }
104
+ }
105
+
106
+ @data = {
107
+ :card => {
108
+ :number => '1',
109
+ :name => 'Mr. Joe Bloggs',
110
+ :verification => '123',
111
+ :month => 1,
112
+ :year => 2012,
113
+ :type => 'visa'
114
+ },
115
+ :billing => {
116
+ :id => shop_addresses(:billing).id,
117
+ :name => shop_addresses(:billing).name,
118
+ :email => shop_addresses(:billing).email,
119
+ :street => shop_addresses(:billing).street,
120
+ :city => shop_addresses(:billing).city,
121
+ :state => shop_addresses(:billing).state,
122
+ :country => shop_addresses(:billing).country,
123
+ :postcode => shop_addresses(:billing).postcode
124
+ },
125
+ :shipping => {
126
+ :id => shop_addresses(:shipping).id,
127
+ :name => shop_addresses(:shipping).name,
128
+ :email => shop_addresses(:shipping).email,
129
+ :street => shop_addresses(:shipping).street,
130
+ :city => shop_addresses(:shipping).city,
131
+ :state => shop_addresses(:shipping).state,
132
+ :country => shop_addresses(:shipping).country,
133
+ :postcode => shop_addresses(:shipping).postcode
134
+ },
135
+ :options => {
136
+ :address => {
137
+ :address1 => 'address',
138
+ :zip => 'zip'
139
+ }
140
+ }
141
+ }
142
+
143
+ @request.session = { :shop_order => @order.id }
144
+ end
145
+ end
146
+
153
147
  end