radiant-shop-extension 0.90.4 → 0.91.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -23,7 +23,7 @@ describe Shop::Tags::Card do
23
23
  context 'all cards' do
24
24
  it 'should output the card types' do
25
25
  tag = %{<r:form:card:type />}
26
- exp = %{<select name="card[type]" id="card_type">
26
+ exp = %{<select name="credit_card[type]" id="credit_card_type">
27
27
  <option value="amex">American Express</option>
28
28
  <option value="diners">Diners Club</option>
29
29
  <option value="master">Master Card</option>
@@ -37,7 +37,7 @@ describe Shop::Tags::Card do
37
37
  context 'except amex and diners' do
38
38
  it 'should output all except amex and diners' do
39
39
  tag = %{<r:form:card:type except="amex,diners" />}
40
- exp = %{<select name="card[type]" id="card_type">
40
+ exp = %{<select name="credit_card[type]" id="credit_card_type">
41
41
  <option value="master">Master Card</option>
42
42
  <option value="visa">Visa</option>
43
43
  </select>}
@@ -49,7 +49,7 @@ describe Shop::Tags::Card do
49
49
  context 'only amex and diners' do
50
50
  it 'should output all except amex' do
51
51
  tag = %{<r:form:card:type only="amex,diners" />}
52
- exp = %{<select name="card[type]" id="card_type">
52
+ exp = %{<select name="credit_card[type]" id="credit_card_type">
53
53
  <option value="amex">American Express</option>
54
54
  <option value="diners">Diners Club</option>
55
55
  </select>}
@@ -62,7 +62,7 @@ describe Shop::Tags::Card do
62
62
  describe 'form:card:month' do
63
63
  it 'should output the card months' do
64
64
  tag = %{<r:form:card:month />}
65
- exp = %{<select name="card[month]" id="card_month">
65
+ exp = %{<select name="credit_card[month]" id="credit_card_month">
66
66
  <option value="01">01 - January</option>
67
67
  <option value="02">02 - February</option>
68
68
  <option value="03">03 - March</option>
@@ -84,7 +84,7 @@ describe Shop::Tags::Card do
84
84
  describe 'form:card:year' do
85
85
  it 'should output the card years' do
86
86
  tag = %{<r:form:card:year />}
87
- exp = %{<select name="card[year]" id="card_year">\n}
87
+ exp = %{<select name="credit_card[year]" id="credit_card_year">\n}
88
88
  (Time.new.year ... Time.new.year + 15).each do |year|
89
89
  exp << %{<option value="#{year}">#{year}</option>\n}
90
90
  end
@@ -392,21 +392,34 @@ describe Shop::Tags::Helpers do
392
392
 
393
393
  describe '#current_address' do
394
394
  before :each do
395
- @address = shop_addresses(:billing)
395
+ @address = shop_billings(:order_billing)
396
396
  @tag.attr = { 'type' => 'billing' }
397
397
  end
398
398
 
399
- context 'billing address already exists and billing type was requested' do
399
+ context 'billing address already exists' do
400
400
  before :each do
401
- @tag.locals.address = @address
402
- @tag.locals.address_type = 'billing'
401
+ @tag.locals.billing = @address
403
402
  end
404
- it 'should return the existing address' do
403
+ it 'should return the existing billing' do
404
+ result = Shop::Tags::Helpers.current_address(@tag,'billing')
405
+ result.should == @address
406
+ end
407
+ it 'should return the existing billing if no type is sent' do
405
408
  result = Shop::Tags::Helpers.current_address(@tag)
406
409
  result.should == @address
407
410
  end
408
411
  end
409
412
 
413
+ context 'shipping address already exists' do
414
+ before :each do
415
+ @tag.locals.shipping = @address
416
+ end
417
+ it 'should return the existing address' do
418
+ result = Shop::Tags::Helpers.current_address(@tag,'shipping')
419
+ result.should == @address
420
+ end
421
+ end
422
+
410
423
  context 'current_order exists and has billing' do
411
424
  before :each do
412
425
  @order = shop_orders(:one_item)
@@ -414,7 +427,7 @@ describe Shop::Tags::Helpers do
414
427
  @tag.locals.shop_order = @order
415
428
  end
416
429
  it 'should return the order billing address' do
417
- result = Shop::Tags::Helpers.current_address(@tag)
430
+ result = Shop::Tags::Helpers.current_address(@tag,'billing')
418
431
  result.should == @address
419
432
  end
420
433
  end
@@ -424,14 +437,14 @@ describe Shop::Tags::Helpers do
424
437
  @order = shop_orders(:one_item)
425
438
  end
426
439
  it 'should return nil' do
427
- result = Shop::Tags::Helpers.current_address(@tag)
440
+ result = Shop::Tags::Helpers.current_address(@tag,'billing')
428
441
  result.should be_nil
429
442
  end
430
443
  end
431
444
 
432
445
  context 'no order exists' do
433
446
  it 'should return nil' do
434
- result = Shop::Tags::Helpers.current_address(@tag)
447
+ result = Shop::Tags::Helpers.current_address(@tag,'billing')
435
448
  result.should be_nil
436
449
  end
437
450
  end
@@ -18,17 +18,17 @@ describe FormAddress do
18
18
 
19
19
  context 'both billing and shipping' do
20
20
  it 'should assign that address to the order billing and shipping' do
21
- @data[:billing] = { :id => shop_orders(:several_items).billing.id }
22
- @data[:shipping] = { :id => shop_orders(:several_items).shipping.id }
21
+ @data[:billing] = shop_orders(:several_items).billing.attributes.reject{ |k,v| k == 'id' }
22
+ @data[:shipping] = shop_orders(:several_items).shipping.attributes.reject{ |k,v| k == 'id' }
23
23
 
24
24
  @address = FormAddress.new(@form, @page, @form[:extensions][:addresses])
25
25
  result = @address.create
26
26
 
27
- shop_orders(:one_item).billing.should === shop_addresses(:billing)
28
- shop_orders(:one_item).shipping.should === shop_addresses(:shipping)
27
+ shop_orders(:one_item).billing.attributes.reject{ |k,v| k == 'id' || k = 'addressable_id' }.should == shop_billings(:order_billing).attributes.reject{ |k,v| k == 'id' || k = 'addressable_id' }
28
+ shop_orders(:one_item).shipping.attributes.reject{ |k,v| k == 'id' || k = 'addressable_id' }.should == shop_shippings(:order_shipping).attributes.reject{ |k,v| k == 'id' || k = 'addressable_id' }
29
29
 
30
- result[:billing].should === shop_addresses(:billing).id
31
- result[:shipping].should === shop_addresses(:shipping).id
30
+ result[:billing].should === shop_orders(:one_item).billing.id
31
+ result[:shipping].should === shop_orders(:one_item).shipping.id
32
32
  end
33
33
  end
34
34
 
@@ -41,53 +41,12 @@ describe FormAddress do
41
41
  @address = FormAddress.new(@form, @page, @form[:extensions][:addresses])
42
42
  result = @address.create
43
43
 
44
- shop_orders(:one_item).billing.should === shop_addresses(:billing)
45
- shop_orders(:one_item).shipping.should === shop_addresses(:billing)
46
-
47
- result[:billing].should === shop_addresses(:billing).id
48
- result[:shipping].should === shop_addresses(:billing).id
44
+ shop_orders(:one_item).billing.attributes.reject{ |k,v| k == 'id' || k = 'addressable_id' }.should === shop_billings(:order_billing).attributes.reject{ |k,v| k == 'id' || k = 'addressable_id' }
45
+ shop_orders(:one_item).shipping.attributes.reject{ |k,v| k == 'id' || k = 'addressable_id' }.should === shop_shippings(:order_shipping).attributes.reject{ |k,v| k == 'id' || k = 'addressable_id' }
49
46
  end
50
47
  end
51
48
  end
52
49
 
53
- context 'sending ids without customer logged in' do
54
- before :each do
55
- @order = shop_orders(:one_item)
56
- mock_valid_form_address_request
57
- end
58
- context 'both billing and shipping' do
59
- it 'it should not assign those addresses' do
60
- @address = FormAddress.new(@form, @page, @form[:extensions][:addresses])
61
- result = @address.create
62
-
63
- shop_orders(:one_item).billing.should be_nil
64
- shop_orders(:one_item).shipping.should be_nil
65
-
66
- result[:billing].should === false
67
- result[:shipping].should === false
68
- end
69
- end
70
- end
71
-
72
- context 'sending ids as a bad customer' do
73
- before :each do
74
- login_as :bad_customer
75
-
76
- @order = shop_orders(:one_item)
77
- mock_valid_form_address_request
78
- end
79
- it 'should not assign those addresses' do
80
- @address = FormAddress.new(@form, @page, @form[:extensions][:addresses])
81
- result = @address.create
82
-
83
- shop_orders(:one_item).billing.should be_nil
84
- shop_orders(:one_item).shipping.should be_nil
85
-
86
- result[:billing].should === false
87
- result[:shipping].should === false
88
- end
89
- end
90
-
91
50
  context 'updating existing addresses' do
92
51
  before :each do
93
52
  login_as :customer
@@ -101,11 +60,8 @@ describe FormAddress do
101
60
  @address = FormAddress.new(@form, @page, @form[:extensions][:addresses])
102
61
  result = @address.create
103
62
 
104
- shop_addresses(:billing).name.should === 'new billing'
105
- shop_addresses(:shipping).name.should === 'new shipping'
106
-
107
- result[:billing].should === shop_addresses(:billing).id
108
- result[:shipping].should === shop_addresses(:shipping).id
63
+ shop_billings(:order_billing).name.should === 'new billing'
64
+ shop_shippings(:order_shipping).name.should === 'new shipping'
109
65
  end
110
66
  end
111
67
 
@@ -154,7 +110,7 @@ describe FormAddress do
154
110
  @address = FormAddress.new(@form, @page, @form[:extensions][:addresses])
155
111
  result = @address.create
156
112
 
157
- shop_orders(:one_item).shipping.should === shop_orders(:one_item).billing
113
+ shop_orders(:one_item).shipping.attributes.reject{ |k,v| k == 'id' || k = 'addressable_id' }.should === shop_orders(:one_item).billing.attributes.reject{ |k,v| k == 'id' || k = 'addressable_id' }
158
114
 
159
115
  result[:billing].should === shop_orders(:one_item).billing.id
160
116
  result[:shipping].should === shop_orders(:one_item).shipping.id
@@ -33,7 +33,7 @@ describe FormCheckout do
33
33
  result[:gateway].should be_true
34
34
  result[:card].should be_true
35
35
  result[:payment].should be_true
36
- result[:message].should === "Order successfully processed"
36
+ result[:message].should === "Bogus Gateway: Forced success"
37
37
  end
38
38
 
39
39
  it 'should assign a payment object' do
@@ -42,7 +42,7 @@ describe FormCheckout do
42
42
  result = @checkout.create
43
43
 
44
44
  @order.payment.card_number.should === "XXXX-XXXX-XXXX-1"
45
- @order.payment.card_type.should === @data[:card][:type]
45
+ @order.payment.card_type.should === @data[:credit_card][:type]
46
46
  @order.payment.amount.should === @order.price
47
47
  end
48
48
 
@@ -96,7 +96,7 @@ describe FormCheckout do
96
96
 
97
97
  context 'no card' do
98
98
  it 'should return card and payment false' do
99
- @data[:card] = nil
99
+ @data[:credit_card] = nil
100
100
 
101
101
  @checkout = FormCheckout.new(@form, @page, @form[:extensions][:bogus_checkout])
102
102
  result = @checkout.create
@@ -3,77 +3,63 @@ require File.dirname(__FILE__) + "/../spec_helper"
3
3
  describe ShopAddress do
4
4
 
5
5
  dataset :shop_addresses, :shop_orders
6
-
7
- describe 'relationships' do
8
- before :each do
9
- @address = shop_addresses(:billing)
10
- end
11
-
12
- context 'billing orders' do
13
- before :each do
14
- @order = shop_orders(:empty)
15
- end
16
- it 'should have many' do
17
- @address.billings << @order
18
- @address.billings.include?(@order).should === true
19
- end
20
- end
21
-
22
- context 'shipping orders' do
23
- before :each do
24
- @order = shop_orders(:empty)
25
- end
26
- it 'should have many' do
27
- @address.shippings << @order
28
- @address.shippings.include?(@order).should === true
29
- end
30
- end
31
- end
32
6
 
33
7
  describe 'validations' do
34
8
  before :each do
35
- @address = shop_addresses(:billing)
9
+ @address = shop_billings(:order_billing)
36
10
  end
37
11
  context 'unit' do
38
12
  it 'should not require' do
39
13
  @address.unit = nil
40
- @address.valid?.should === true
14
+ @address.valid?.should be_true
41
15
  end
42
16
  end
43
17
  context 'name' do
44
18
  it 'should require' do
45
19
  @address.name = nil
46
- @address.valid?.should === false
20
+ @address.valid?.should be_false
47
21
  end
48
22
  end
49
- context 'street' do
23
+ context 'street_1' do
50
24
  it 'should require' do
51
- @address.street = nil
52
- @address.valid?.should === false
25
+ @address.street_1 = nil
26
+ @address.valid?.should be_false
27
+ end
28
+ end
29
+ context 'street_2' do
30
+ it 'should not require' do
31
+ @address.street_2 = nil
32
+ @address.valid?.should be_true
53
33
  end
54
34
  end
55
35
  context 'city' do
56
36
  it 'should require' do
57
37
  @address.city = nil
58
- @address.valid?.should === false
38
+ @address.valid?.should be_false
59
39
  end
60
40
  end
61
41
  context 'postcode' do
62
42
  it 'should require' do
63
43
  @address.postcode = nil
64
- @address.valid?.should === false
44
+ @address.valid?.should be_false
65
45
  end
66
46
  end
67
47
  context 'state' do
68
48
  it 'should require' do
69
49
  @address.state = nil
70
- @address.valid?.should === false
50
+ @address.valid?.should be_false
71
51
  end
72
52
  end
73
53
  context 'country' do
74
54
  it 'should require' do
75
55
  @address.country = nil
76
- @address.valid?.should === false
56
+ @address.valid?.should be_false
57
+ end
58
+ end
59
+ context 'phone' do
60
+ it 'should not require' do
61
+ @address.phone = nil
62
+ @address.valid?.should be_true
77
63
  end
78
64
  end
79
65
  end
@@ -0,0 +1,30 @@
1
+ require File.dirname(__FILE__) + "/../spec_helper"
2
+
3
+ describe ShopBilling do
4
+
5
+ dataset :shop_addresses, :shop_orders
6
+
7
+ describe 'scope' do
8
+ before :each do
9
+ @address = ShopBilling.new
10
+ end
11
+
12
+ it 'should have a of_type of billing' do
13
+ @address.of_type.should == 'billing'
14
+ end
15
+
16
+ end
17
+
18
+ describe 'validations' do
19
+ before :each do
20
+ @address = shop_billings(:order_billing)
21
+ end
22
+ context 'email' do
23
+ it 'should require' do
24
+ @address.email = nil
25
+ @address.valid?.should be_false
26
+ end
27
+ end
28
+ end
29
+
30
+ end
@@ -24,6 +24,7 @@ describe ShopCustomer do
24
24
  @order = shop_orders(:several_items)
25
25
  end
26
26
  it 'should have many through orders' do
27
+ pending
27
28
  @customer.orders << @order
28
29
  @customer.billings.include?(@order.billing).should === true
29
30
  end
@@ -34,6 +35,7 @@ describe ShopCustomer do
34
35
  @order = shop_orders(:several_items)
35
36
  end
36
37
  it 'should have many through orders' do
38
+ pending
37
39
  @customer.orders << @order
38
40
  @customer.shippings.include?(@order.shipping).should === true
39
41
  end
@@ -0,0 +1,30 @@
1
+ require File.dirname(__FILE__) + "/../spec_helper"
2
+
3
+ describe ShopShipping do
4
+
5
+ dataset :shop_addresses, :shop_orders
6
+
7
+ describe 'scope' do
8
+ before :each do
9
+ @address = ShopShipping.new
10
+ end
11
+
12
+ it 'should have a of_type of shipping' do
13
+ @address.of_type.should == 'shipping'
14
+ end
15
+
16
+ end
17
+
18
+ describe 'validations' do
19
+ before :each do
20
+ @address = shop_shippings(:order_shipping)
21
+ end
22
+ context 'email' do
23
+ it 'should not require' do
24
+ @address.email = nil
25
+ @address.valid?.should be_true
26
+ end
27
+ end
28
+ end
29
+
30
+ end
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: 383
4
+ hash: 375
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 90
9
- - 4
10
- version: 0.90.4
8
+ - 91
9
+ - 2
10
+ version: 0.91.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Dirk Kelly
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2010-11-24 00:00:00 +08:00
20
+ date: 2010-12-08 00:00:00 +08:00
21
21
  default_executable:
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
@@ -191,6 +191,7 @@ files:
191
191
  - app/models/form_checkout.rb
192
192
  - app/models/form_line_item.rb
193
193
  - app/models/shop_address.rb
194
+ - app/models/shop_billing.rb
194
195
  - app/models/shop_category.rb
195
196
  - app/models/shop_category_page.rb
196
197
  - app/models/shop_customer.rb
@@ -201,6 +202,7 @@ files:
201
202
  - app/models/shop_product.rb
202
203
  - app/models/shop_product_attachment.rb
203
204
  - app/models/shop_product_page.rb
205
+ - app/models/shop_shipping.rb
204
206
  - app/views/.DS_Store
205
207
  - app/views/admin/.DS_Store
206
208
  - app/views/admin/shop/categories/edit.html.haml
@@ -295,6 +297,7 @@ files:
295
297
  - config/locales/en.yml
296
298
  - config/routes.rb
297
299
  - db/migrate/20101011063133_setup_shop.rb
300
+ - db/migrate/20101208045754_address_changes.rb
298
301
  - db/seed.rb
299
302
  - db/seeds/forms.rb
300
303
  - db/seeds/layouts.rb
@@ -367,6 +370,7 @@ files:
367
370
  - spec/models/form_address_spec.rb
368
371
  - spec/models/form_checkout_spec.rb
369
372
  - spec/models/shop_address_spec.rb
373
+ - spec/models/shop_billing_spec.rb
370
374
  - spec/models/shop_category_page_spec.rb
371
375
  - spec/models/shop_category_spec.rb
372
376
  - spec/models/shop_customer_spec.rb
@@ -376,6 +380,7 @@ files:
376
380
  - spec/models/shop_product_attachment_spec.rb
377
381
  - spec/models/shop_product_page_spec.rb
378
382
  - spec/models/shop_product_spec.rb
383
+ - spec/models/shop_shipping_spec.rb
379
384
  - spec/spec.opts
380
385
  - spec/spec_helper.rb
381
386
  has_rdoc: true
@@ -447,6 +452,7 @@ test_files:
447
452
  - spec/models/form_address_spec.rb
448
453
  - spec/models/form_checkout_spec.rb
449
454
  - spec/models/shop_address_spec.rb
455
+ - spec/models/shop_billing_spec.rb
450
456
  - spec/models/shop_category_page_spec.rb
451
457
  - spec/models/shop_category_spec.rb
452
458
  - spec/models/shop_customer_spec.rb
@@ -456,4 +462,5 @@ test_files:
456
462
  - spec/models/shop_product_attachment_spec.rb
457
463
  - spec/models/shop_product_page_spec.rb
458
464
  - spec/models/shop_product_spec.rb
465
+ - spec/models/shop_shipping_spec.rb
459
466
  - spec/spec_helper.rb