spree 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of spree might be problematic. Click here for more details.
- data/CHANGELOG +30 -0
- data/CONTRIBUTORS +38 -20
- data/app/controllers/admin/creditcard_payments_controller.rb +10 -3
- data/app/controllers/admin/orders_controller.rb +17 -16
- data/app/controllers/admin/products_controller.rb +12 -14
- data/app/controllers/admin/reports_controller.rb +12 -14
- data/app/controllers/admin/users_controller.rb +10 -5
- data/app/controllers/admin/zones_controller.rb +4 -1
- data/app/controllers/application.rb +0 -1
- data/app/controllers/checkout_controller.rb +96 -0
- data/app/controllers/content_controller.rb +11 -1
- data/app/controllers/orders_controller.rb +12 -33
- data/app/controllers/products_controller.rb +12 -7
- data/app/controllers/spree/base_controller.rb +1 -1
- data/app/controllers/states_controller.rb +14 -2
- data/app/controllers/taxons_controller.rb +6 -2
- data/app/controllers/users_controller.rb +9 -6
- data/app/helpers/application_helper.rb +1 -11
- data/app/helpers/products_helper.rb +3 -1
- data/app/helpers/spree/base_helper.rb +0 -26
- data/app/models/address.rb +3 -3
- data/app/models/app_configuration.rb +1 -0
- data/app/models/country.rb +4 -0
- data/app/models/creditcard.rb +6 -1
- data/app/models/creditcard_payment.rb +1 -1
- data/app/models/inventory_unit.rb +4 -1
- data/app/models/order.rb +37 -21
- data/app/models/product.rb +19 -8
- data/{vendor/extensions/shipping/app → app}/models/shipment.rb +20 -4
- data/{vendor/extensions/shipping/app → app}/models/shipping_category.rb +0 -0
- data/{vendor/extensions/shipping/app → app}/models/shipping_method.rb +6 -4
- data/app/models/state.rb +5 -0
- data/app/models/user.rb +4 -2
- data/app/models/variant.rb +19 -1
- data/app/presenters/checkout_presenter.rb +58 -0
- data/app/views/admin/creditcard_payments/edit.html.erb +1 -1
- data/app/views/admin/option_types/available.html.erb +1 -1
- data/app/views/admin/orders/index.html.erb +28 -18
- data/app/views/admin/orders/show.html.erb +1 -1
- data/app/views/admin/payments/index.html.erb +1 -1
- data/app/views/admin/products/_images.html.erb +1 -1
- data/app/views/admin/products/index.html.erb +17 -13
- data/app/views/admin/users/index.html.erb +8 -8
- data/app/views/admin/zones/index.html.erb +5 -2
- data/app/views/checkout/_form.html.erb +165 -0
- data/app/views/{creditcards → checkout}/cvv.html.erb +1 -1
- data/app/views/checkout/new.html.erb +6 -0
- data/app/views/layouts/admin.html.erb +2 -3
- data/app/views/layouts/application.html.erb +1 -1
- data/app/views/orders/_form.html.erb +6 -4
- data/app/views/orders/_google_order.html.erb +24 -0
- data/app/views/orders/_line_item.html.erb +2 -1
- data/app/views/orders/show.html.erb +4 -1
- data/app/views/products/index.html.erb +2 -1
- data/app/views/products/show.html.erb +4 -4
- data/app/views/shared/_footer.html.erb +12 -1
- data/app/views/shared/_login.html.erb +1 -1
- data/app/views/shared/_order_details.html.erb +8 -9
- data/app/views/shared/_products.html.erb +1 -1
- data/app/views/shared/_report_criteria.html.erb +28 -28
- data/app/views/states/index.js.erb +10 -1
- data/config/environment.rb +10 -4
- data/config/initializers/searchlogic.rb +6 -0
- data/config/locales/de.yml +14 -0
- data/config/locales/en-GB.yml +20 -6
- data/config/locales/en-US.yml +20 -4
- data/config/locales/es.yml +14 -0
- data/config/locales/fr-FR.yml +463 -0
- data/config/locales/fr-FR_rails.yml +115 -0
- data/config/locales/it.yml +14 -0
- data/config/locales/nb-NO.yml +457 -0
- data/config/locales/nb-NO_rails.yml +105 -0
- data/config/locales/pl.yml +14 -0
- data/config/locales/pt-BR.yml +14 -0
- data/config/locales/pt-PT.yml +14 -0
- data/config/locales/ru-RU.yml +458 -0
- data/config/locales/ru-RU_rails.yml +154 -0
- data/config/routes.rb +11 -4
- data/db/migrate/20090204200045_add_order_permalink.rb +13 -0
- data/db/migrate/20090225231119_add_more_needed_keys_items_and_conf.rb +19 -0
- data/db/migrate/20090302221152_give_all_users_user_role.rb +13 -0
- data/db/sample/orders.yml +1 -1
- data/lib/generators/instance/instance_generator.rb +1 -1
- data/lib/spree.rb +1 -1
- data/lib/spree/setup.rb +1 -1
- data/lib/tasks/database.rake +5 -2
- data/lib/tasks/release.rake +1 -1
- data/lib/tasks/upgrade.rake +11 -0
- data/public/assets/products/1009/mini/sean.jpg +0 -0
- data/public/assets/products/1009/original/sean.jpg +0 -0
- data/public/assets/products/1009/product/sean.jpg +0 -0
- data/public/assets/products/1009/small/sean.jpg +0 -0
- data/public/images/ajax_loader.gif +0 -0
- data/public/javascripts/checkout.js +284 -0
- data/public/javascripts/jquery-1.3.2.min.js +19 -0
- data/public/javascripts/jquery.validate.pack.js +15 -0
- data/public/stylesheets/checkout.css +25 -0
- data/public/stylesheets/spree-admin.css +6 -2
- data/public/stylesheets/spree.css +419 -432
- data/spec/controllers/countries_controller_spec.rb +3 -2
- data/spec/controllers/orders_controller_spec.rb +7 -5
- data/spec/controllers/states_controller_spec.rb +4 -2
- data/spec/models/creditcard_payment_spec.rb +6 -2
- data/spec/models/order_spec.rb +164 -157
- data/spec/models/product_spec.rb +2 -2
- data/vendor/extensions/payment_gateway/db/migrate/20090218091936_create_protx_gateway.rb +18 -0
- data/vendor/extensions/payment_gateway/lib/spree/payment_gateway.rb +7 -5
- data/vendor/extensions/shipping/app/controllers/admin/shipments_controller.rb +6 -5
- data/vendor/extensions/shipping/app/views/admin/shipments/index.html.erb +1 -1
- data/vendor/extensions/shipping/config/locales/nb-NO.yml +25 -0
- data/vendor/extensions/shipping/config/locales/ru-RU.yml +25 -0
- data/vendor/extensions/shipping/db/sample/shipping_methods.yml +5 -1
- data/vendor/extensions/shipping/db/sample/zone_members.yml +9 -1
- data/vendor/extensions/shipping/db/sample/zones.yml +4 -1
- data/vendor/extensions/shipping/lib/spree/shipping_calculator.rb +0 -16
- data/vendor/extensions/shipping/shipping_extension.rb +0 -15
- data/vendor/extensions/shipping/spec/models/shipping_method_spec.rb +16 -10
- data/vendor/extensions/shipping/spec/models/shipping_order_spec.rb +3 -17
- data/vendor/extensions/tax_calculator/config/locales/nb-NO.yml +30 -0
- data/vendor/extensions/tax_calculator/spec/models/{order_spec.rb → order_tax_calc_spec.rb} +2 -2
- data/vendor/gems/{active_presenter-0.0.4 → active_presenter-0.0.6}/.specification +3 -5
- data/vendor/gems/{active_presenter-0.0.4 → active_presenter-0.0.6}/LICENSE +0 -0
- data/vendor/gems/{active_presenter-0.0.4 → active_presenter-0.0.6}/README +9 -2
- data/vendor/gems/{active_presenter-0.0.4 → active_presenter-0.0.6}/Rakefile +0 -0
- data/vendor/gems/{active_presenter-0.0.4 → active_presenter-0.0.6}/lib/active_presenter.rb +0 -0
- data/vendor/gems/{active_presenter-0.0.4 → active_presenter-0.0.6}/lib/active_presenter/base.rb +38 -8
- data/vendor/gems/{active_presenter-0.0.4 → active_presenter-0.0.6}/lib/active_presenter/version.rb +1 -1
- data/vendor/gems/{active_presenter-0.0.4 → active_presenter-0.0.6}/lib/tasks/doc.rake +0 -0
- data/vendor/gems/{active_presenter-0.0.4 → active_presenter-0.0.6}/lib/tasks/gem.rake +0 -0
- data/vendor/gems/{active_presenter-0.0.4 → active_presenter-0.0.6}/test/base_test.rb +66 -30
- data/vendor/gems/{active_presenter-0.0.4 → active_presenter-0.0.6}/test/test_helper.rb +36 -0
- data/vendor/plugins/attribute_fu/lib/attribute_fu/associated_form_helper.rb +12 -4
- data/vendor/plugins/find_by_param/MIT-LICENSE +1 -1
- data/vendor/plugins/find_by_param/{README → README.markdown} +7 -1
- data/vendor/plugins/find_by_param/init.rb +0 -1
- data/vendor/plugins/find_by_param/lib/find_by_param.rb +23 -87
- data/vendor/plugins/find_by_param/test/find_by_param_test.rb +22 -8
- data/vendor/plugins/find_by_param/test/test_helper.rb +0 -1
- metadata +65 -193
- data/app/controllers/creditcards_controller.rb +0 -73
- data/app/models/order_filter.rb +0 -28
- data/app/models/user_filter.rb +0 -6
- data/app/views/creditcards/_form_credit_card.html.erb +0 -30
- data/app/views/creditcards/new.html.erb +0 -25
- data/app/views/shared/_paginate.html.erb +0 -34
- data/lib/plugins/paginating_find/CHANGELOG +0 -120
- data/lib/plugins/paginating_find/README +0 -89
- data/lib/plugins/paginating_find/init.rb +0 -2
- data/lib/plugins/paginating_find/lib/paginating_find.rb +0 -138
- data/lib/plugins/paginating_find/lib/paging_enumerator.rb +0 -158
- data/lib/plugins/paginating_find/lib/paging_helper.rb +0 -47
- data/lib/plugins/paginating_find/test_app/Rakefile +0 -10
- data/lib/plugins/paginating_find/test_app/app/controllers/application.rb +0 -2
- data/lib/plugins/paginating_find/test_app/config/boot.rb +0 -44
- data/lib/plugins/paginating_find/test_app/config/database.yml +0 -6
- data/lib/plugins/paginating_find/test_app/config/environment.rb +0 -53
- data/lib/plugins/paginating_find/test_app/config/environments/test.rb +0 -19
- data/lib/plugins/paginating_find/test_app/config/routes.rb +0 -22
- data/lib/plugins/paginating_find/test_app/script/breakpointer +0 -3
- data/lib/plugins/paginating_find/test_app/script/console +0 -3
- data/lib/plugins/paginating_find/test_app/test/fixtures/articles.yml +0 -19
- data/lib/plugins/paginating_find/test_app/test/fixtures/authors.yml +0 -7
- data/lib/plugins/paginating_find/test_app/test/fixtures/edits.yml +0 -11
- data/lib/plugins/paginating_find/test_app/test/fixtures/models.rb +0 -18
- data/lib/plugins/paginating_find/test_app/test/test_helper.rb +0 -33
- data/lib/plugins/paginating_find/test_app/test/unit/abstract_test.rb +0 -7
- data/lib/plugins/paginating_find/test_app/test/unit/group_test.rb +0 -40
- data/lib/plugins/paginating_find/test_app/test/unit/paginating_find_test.rb +0 -194
- data/lib/plugins/paginating_find/test_app/test/unit/paging_enumerator_test.rb +0 -143
- data/public/assets/products/1012/mini/bt.jpg +0 -0
- data/public/assets/products/1012/original/bt.jpg +0 -0
- data/public/assets/products/1012/product/bt.jpg +0 -0
- data/public/assets/products/1012/small/bt.jpg +0 -0
- data/spec/views/products/index.html.erb_spec.rb +0 -46
- data/spec/views/products/show.html.erb_spec.rb +0 -46
- data/vendor/extensions/shipping/app/controllers/shipments_controller.rb +0 -96
- data/vendor/extensions/shipping/app/helpers/shipments_helper.rb +0 -20
- data/vendor/extensions/shipping/app/views/orders/fatal_shipping.html.erb +0 -6
- data/vendor/extensions/shipping/app/views/shipments/_form.html.erb +0 -46
- data/vendor/extensions/shipping/app/views/shipments/edit.html.erb +0 -57
- data/vendor/extensions/shipping/app/views/shipments/new.html.erb +0 -10
@@ -11,8 +11,9 @@ describe CountriesController do
|
|
11
11
|
it "should include AuthenticatedSystem" do
|
12
12
|
controller.class.included_modules.should include(AuthenticatedSystem)
|
13
13
|
end
|
14
|
-
|
15
|
-
|
14
|
+
it "should not allow deletion of a county from a default rails route"
|
15
|
+
=begin
|
16
|
+
do
|
16
17
|
lambda {
|
17
18
|
get :destroy, :id => countries(:united_states).id
|
18
19
|
}.should raise_error(ActionController::RoutingError)
|
@@ -3,18 +3,20 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
3
3
|
describe OrdersController do
|
4
4
|
before(:each) do
|
5
5
|
Variant.stub!(:find).with(any_args).and_return(@variant = mock_model(Variant, :price => 10, :on_hand => 50))
|
6
|
-
|
6
|
+
@order = Order.new
|
7
|
+
@order.stub!(:number).and_return("R100")
|
8
|
+
controller.stub!(:find_order).and_return(@order)
|
7
9
|
end
|
8
10
|
|
9
11
|
describe "create" do
|
10
12
|
it "should add the variant to the order" do
|
11
|
-
@order.should_receive(:add_variant).with(@variant)
|
12
|
-
|
13
|
+
@order.should_receive(:add_variant).with(@variant,2)
|
14
|
+
post :create, :id => "345", :quantities => {456 => "123=2"}
|
13
15
|
end
|
14
16
|
|
15
17
|
it "should not set the state" do
|
16
18
|
@order.should_not_receive(:state=)
|
17
|
-
post :create, :id => "345", :
|
19
|
+
post :create, :id => "345", :quantities => {456 => "123=1"}, :order => {:state => "paid"}
|
18
20
|
end
|
19
21
|
end
|
20
22
|
|
@@ -27,4 +29,4 @@ describe OrdersController do
|
|
27
29
|
end
|
28
30
|
end
|
29
31
|
end
|
30
|
-
end
|
32
|
+
end
|
@@ -6,8 +6,10 @@ describe StatesController do
|
|
6
6
|
it "should include AuthenticatedSystem" do
|
7
7
|
controller.class.included_modules.should include(AuthenticatedSystem)
|
8
8
|
end
|
9
|
-
|
10
|
-
it "should not allow deletion of a state from a default rails route"
|
9
|
+
|
10
|
+
it "should not allow deletion of a state from a default rails route"
|
11
|
+
=begin
|
12
|
+
do
|
11
13
|
lambda {
|
12
14
|
get :destroy, :id => states(:new_york).id
|
13
15
|
}.should raise_error(ActionController::RoutingError)
|
@@ -2,12 +2,16 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
2
2
|
|
3
3
|
describe CreditcardPayment do
|
4
4
|
before(:each) {@creditcard_payment = CreditcardPayment.create(:order => Order.new)}
|
5
|
-
it "#can_capture? should return
|
5
|
+
it "#can_capture? should return false if there is no response code" do
|
6
6
|
@creditcard_payment.txns.create(:txn_type => CreditcardTxn::TxnType::AUTHORIZE)
|
7
|
+
@creditcard_payment.can_capture?.should == false
|
8
|
+
end
|
9
|
+
it "#can_capture? should return true if the last transaction was an authorization" do
|
10
|
+
@creditcard_payment.txns.create(:txn_type => CreditcardTxn::TxnType::AUTHORIZE, :response_code => "123")
|
7
11
|
@creditcard_payment.can_capture?.should == true
|
8
12
|
end
|
9
13
|
it "#can_capture? should return false if the last transaction is not an authorization" do
|
10
|
-
@creditcard_payment.txns.create(:txn_type => CreditcardTxn::TxnType::CAPTURE)
|
14
|
+
@creditcard_payment.txns.create(:txn_type => CreditcardTxn::TxnType::CAPTURE, :response_code => "123")
|
11
15
|
@creditcard_payment.can_capture?.should == false
|
12
16
|
end
|
13
17
|
end
|
data/spec/models/order_spec.rb
CHANGED
@@ -1,158 +1,165 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../spec_helper.rb'
|
2
|
-
|
3
|
-
describe Order do
|
4
|
-
before(:each) do
|
5
|
-
@variant = Variant.new(:id => "1234", :price => 7.99)
|
6
|
-
@inventory_unit = mock_model(InventoryUnit, :null_object => true)
|
7
|
-
@creditcard_payment = mock_model(CreditcardPayment, :null_object => true)
|
8
|
-
@user = mock_model(User, :email => "foo@exampl.com")
|
9
|
-
|
10
|
-
@order = Order.new
|
11
|
-
@order.checkout_complete = true
|
12
|
-
@order.creditcard_payments = [@creditcard_payment]
|
13
|
-
@order.number = '#TEST1010'
|
14
|
-
@order.user = @user
|
15
|
-
|
16
|
-
@order.stub!(:save => true, :inventory_units => [@inventory_unit])
|
17
|
-
@line_item = LineItem.new(:variant => @variant, :quantity => 1, :price => 7.99)
|
18
|
-
@order.line_items << @line_item
|
19
|
-
InventoryUnit.stub!(:retrieve_on_hand).with(@variant, 1).and_return [@inventory_unit]
|
20
|
-
OrderMailer.stub!(:deliver_confirm).with(any_args)
|
21
|
-
OrderMailer.stub!(:deliver_cancel).with(any_args)
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
describe "create" do
|
26
|
-
it "should generate an order number"
|
27
|
-
end
|
28
|
-
|
29
|
-
describe "next" do
|
30
|
-
describe "from creditcard_payment" do
|
31
|
-
before(:each) do
|
32
|
-
@order.state = 'creditcard'
|
33
|
-
end
|
34
|
-
it "should transition to new" do
|
35
|
-
@order.next
|
36
|
-
@order.state.should == "new"
|
37
|
-
end
|
38
|
-
it "should mark inventory as sold" do
|
39
|
-
@inventory_unit.should_receive(:sell!)
|
40
|
-
@order.next
|
41
|
-
end
|
42
|
-
it "should send a confirmation email" do
|
43
|
-
OrderMailer.should_receive(:deliver_confirm).with(@order)
|
44
|
-
@order.next
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
describe "cancel" do
|
50
|
-
it "should mark inventory as on_hand" do
|
51
|
-
@order.state = "captured"
|
52
|
-
@inventory_unit.stub!(:state).and_return('sold')
|
53
|
-
@inventory_unit.should_receive(:restock!)
|
54
|
-
@order.cancel
|
55
|
-
end
|
56
|
-
it "should send a cancellation email" do
|
57
|
-
OrderMailer.should_receive(:deliver_cancel).with(@order)
|
58
|
-
@order.cancel
|
59
|
-
end
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
@
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
@
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
@order.
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
@order.
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
@
|
124
|
-
@line_item2.
|
125
|
-
|
126
|
-
|
127
|
-
@
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
@order.
|
149
|
-
@order.
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
@order.state_events = [StateEvent.new(:name => 'cancel')]
|
154
|
-
@order.
|
155
|
-
|
156
|
-
|
157
|
-
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper.rb'
|
2
|
+
|
3
|
+
describe Order do
|
4
|
+
before(:each) do
|
5
|
+
@variant = Variant.new(:id => "1234", :price => 7.99)
|
6
|
+
@inventory_unit = mock_model(InventoryUnit, :null_object => true)
|
7
|
+
@creditcard_payment = mock_model(CreditcardPayment, :null_object => true)
|
8
|
+
@user = mock_model(User, :email => "foo@exampl.com")
|
9
|
+
|
10
|
+
@order = Order.new
|
11
|
+
@order.checkout_complete = true
|
12
|
+
@order.creditcard_payments = [@creditcard_payment]
|
13
|
+
@order.number = '#TEST1010'
|
14
|
+
@order.user = @user
|
15
|
+
|
16
|
+
@order.stub!(:save => true, :inventory_units => [@inventory_unit])
|
17
|
+
@line_item = LineItem.new(:variant => @variant, :quantity => 1, :price => 7.99)
|
18
|
+
@order.line_items << @line_item
|
19
|
+
InventoryUnit.stub!(:retrieve_on_hand).with(@variant, 1).and_return [@inventory_unit]
|
20
|
+
OrderMailer.stub!(:deliver_confirm).with(any_args)
|
21
|
+
OrderMailer.stub!(:deliver_cancel).with(any_args)
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "create" do
|
26
|
+
it "should generate an order number"
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "next" do
|
30
|
+
describe "from creditcard_payment" do
|
31
|
+
before(:each) do
|
32
|
+
@order.state = 'creditcard'
|
33
|
+
end
|
34
|
+
it "should transition to new" do
|
35
|
+
@order.next
|
36
|
+
@order.state.should == "new"
|
37
|
+
end
|
38
|
+
it "should mark inventory as sold" do
|
39
|
+
@inventory_unit.should_receive(:sell!)
|
40
|
+
@order.next
|
41
|
+
end
|
42
|
+
it "should send a confirmation email" do
|
43
|
+
OrderMailer.should_receive(:deliver_confirm).with(@order)
|
44
|
+
@order.next
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "cancel" do
|
50
|
+
it "should mark inventory as on_hand" do
|
51
|
+
@order.state = "captured"
|
52
|
+
@inventory_unit.stub!(:state).and_return('sold')
|
53
|
+
@inventory_unit.should_receive(:restock!)
|
54
|
+
@order.cancel
|
55
|
+
end
|
56
|
+
it "should send a cancellation email" do
|
57
|
+
OrderMailer.should_receive(:deliver_cancel).with(@order)
|
58
|
+
@order.cancel
|
59
|
+
end
|
60
|
+
%w{in_progress creditcard}.each do |state|
|
61
|
+
it "should be available in the #{state} state" do
|
62
|
+
@order.state = state
|
63
|
+
@order.checkout_complete = false
|
64
|
+
@order.can_cancel?.should be_true
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe "return" do
|
70
|
+
it "should mark inventory as on_hand" do
|
71
|
+
@order.state = "shipped"
|
72
|
+
@inventory_unit.stub!(:state).and_return('shipped')
|
73
|
+
@inventory_unit.should_receive(:restock!)
|
74
|
+
@order.return
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe "add_variant" do
|
79
|
+
it "should add new line item if product does not currently existing in order" do
|
80
|
+
@variant2 = mock_model(Variant, :id => "5678", :price => 9.99)
|
81
|
+
|
82
|
+
@order.line_items.should_receive(:in_order).with(@variant2).and_return(nil)
|
83
|
+
@order.line_items.size.should == 1
|
84
|
+
|
85
|
+
@order.add_variant(@variant2)
|
86
|
+
|
87
|
+
@order.line_items.size.should == 2
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should increment the quantity of line_item by 1 when product already exists in order, and no specific quantity is supplied" do
|
91
|
+
|
92
|
+
@order.line_items.should_receive(:in_order).with(@variant).and_return(@line_item)
|
93
|
+
@line_item.should_receive(:save).and_return(true)
|
94
|
+
|
95
|
+
@order.line_items[0].quantity.should == 1
|
96
|
+
@order.add_variant(@variant)
|
97
|
+
|
98
|
+
@order.line_items[0].quantity.should == 2
|
99
|
+
end
|
100
|
+
|
101
|
+
it "should increment the quantity of line_item by x when product already exists in order, and a specific quantity is supplied"do
|
102
|
+
|
103
|
+
@order.line_items.should_receive(:in_order).with(@variant).and_return(@line_item)
|
104
|
+
@line_item.should_receive(:save).and_return(true)
|
105
|
+
|
106
|
+
@order.line_items[0].quantity.should == 1
|
107
|
+
@order.add_variant(@variant, 5)
|
108
|
+
|
109
|
+
@order.line_items[0].quantity.should == 6
|
110
|
+
end
|
111
|
+
|
112
|
+
it "should populate additional fields on line_item when additional_fields is present" do
|
113
|
+
Variant.stub!(:additional_fields).and_return([
|
114
|
+
{:name => 'Weight', :only => [:product]},
|
115
|
+
{:name => 'Height', :only => [:product, :variant], :format => "%.2f"},
|
116
|
+
{:name => 'Width', :only => [:variant], :format => "%.2f", :populate => [:line_item]},
|
117
|
+
{:name => 'Depth', :only => [:variant], :populate => [:line_item]}
|
118
|
+
])
|
119
|
+
|
120
|
+
#build / mock second line item to be returned, when we add the new variant
|
121
|
+
@line_item2 = LineItem.new(:variant => @variant, :quantity => 1)
|
122
|
+
@line_item2.should_receive(:save).exactly(3).times.and_return(true)
|
123
|
+
@line_item2.stub!(:width=)
|
124
|
+
@line_item2.stub!(:depth=)
|
125
|
+
|
126
|
+
#mock new variant to add to order
|
127
|
+
@variant2 = mock_model(Variant, :id => "5678", :price => 9.99, :width => 19, :depth => 79)
|
128
|
+
|
129
|
+
#this is what we expect to happen
|
130
|
+
@order.line_items.should_receive(:in_order).with(@variant2).and_return(@line_item2)
|
131
|
+
@line_item2.should_receive(:width=).with(@variant2.width)
|
132
|
+
@line_item2.should_receive(:depth=).with(@variant2.depth)
|
133
|
+
|
134
|
+
@order.add_variant(@variant2)
|
135
|
+
|
136
|
+
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
describe "resume" do
|
141
|
+
%w{in_progress shipment shipping_method creditcard charged }.each do |state|
|
142
|
+
it "should not be available in #{state} state" do
|
143
|
+
@order.state = state
|
144
|
+
@order.send("can_resume?").should == false
|
145
|
+
end
|
146
|
+
end
|
147
|
+
it "should be available in canceled state" do
|
148
|
+
@order.state = 'canceled'
|
149
|
+
@order.state_events = [StateEvent.new(:name => 'cancel', :previous_state => 'charged')]
|
150
|
+
@order.send("can_resume?").should == true
|
151
|
+
end
|
152
|
+
it "should restore the order to the previous state" do
|
153
|
+
@order.state_events = [StateEvent.new(:name => 'cancel', :previous_state => 'charged')]
|
154
|
+
@order.state = 'canceled'
|
155
|
+
@order.resume!
|
156
|
+
@order.state.should == 'charged'
|
157
|
+
end
|
158
|
+
it "should not be available for legacy orders wtih no prior state information" do
|
159
|
+
@order.state = 'canceled'
|
160
|
+
@order.state_events = [StateEvent.new(:name => 'cancel')]
|
161
|
+
@order.send("can_resume?").should == false
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
158
165
|
end
|
data/spec/models/product_spec.rb
CHANGED
@@ -83,8 +83,8 @@ describe Product do
|
|
83
83
|
end
|
84
84
|
|
85
85
|
describe "permalinks" do
|
86
|
-
before(:each) do
|
87
|
-
@product.name
|
86
|
+
before(:each) do
|
87
|
+
@product = Product.new(:name => "Air force ones", :description => "Whatever", :master_price => 10.00)
|
88
88
|
end
|
89
89
|
|
90
90
|
it "should not have a nil permalink with a saved name" do
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class CreateProtxGateway < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
protx = Gateway.create(
|
4
|
+
:clazz => 'ActiveMerchant::Billing::ProtxGateway',
|
5
|
+
:name => 'Protx',
|
6
|
+
:description => "Active Merchant's Protx Gateway (IE/UK)"
|
7
|
+
)
|
8
|
+
|
9
|
+
GatewayOption.create(:name => 'login', :description => 'Your Protx Login', :gateway_id => protx.id, :textarea => false)
|
10
|
+
GatewayOption.create(:name => 'password', :description => 'Your Protx Password', :gateway_id => protx.id, :textarea => false)
|
11
|
+
GatewayOption.create(:name => 'account', :description => 'Protx sub account name (optional)', :gateway_id => protx.id, :textarea => false)
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.down
|
15
|
+
protx = Gateway.find_by_name('Protx')
|
16
|
+
protx.destroy
|
17
|
+
end
|
18
|
+
end
|
@@ -7,7 +7,7 @@ module Spree
|
|
7
7
|
gateway_error(response) unless response.success?
|
8
8
|
|
9
9
|
# create a creditcard_payment for the amount that was authorized
|
10
|
-
creditcard_payment = order.creditcard_payments.create(:amount =>
|
10
|
+
creditcard_payment = order.creditcard_payments.create(:amount => 0, :creditcard => self)
|
11
11
|
# create a transaction to reflect the authorization
|
12
12
|
creditcard_payment.creditcard_txns << CreditcardTxn.new(
|
13
13
|
:amount => amount,
|
@@ -51,14 +51,16 @@ module Spree
|
|
51
51
|
end
|
52
52
|
|
53
53
|
def gateway_error(response)
|
54
|
-
text = response.params['message'] ||
|
55
|
-
|
54
|
+
text = response.params['message'] ||
|
55
|
+
response.params['response_reason_text'] ||
|
56
|
+
response.message
|
57
|
+
msg = "#{I18n.t('gateway_error')} ... #{text}"
|
56
58
|
logger.error(msg)
|
57
59
|
raise Spree::GatewayError.new(msg)
|
58
60
|
end
|
59
61
|
|
60
62
|
def gateway_options
|
61
|
-
options = {:billing_address => generate_address_hash(
|
63
|
+
options = {:billing_address => generate_address_hash(address),
|
62
64
|
:shipping_address => generate_address_hash(order.ship_address)}
|
63
65
|
options.merge minimal_gateway_options
|
64
66
|
end
|
@@ -99,4 +101,4 @@ module Spree
|
|
99
101
|
return gateway
|
100
102
|
end
|
101
103
|
end
|
102
|
-
end
|
104
|
+
end
|