spree_shipping_matrix 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/app/models/spree/shipping_matrix.rb +1 -1
- data/app/models/spree/shipping_matrix_rule.rb +1 -1
- data/lib/generators/spree_shipping_matrix/install/install_generator.rb +1 -1
- data/lib/spree_shipping_matrix/engine.rb +0 -1
- data/lib/spree_shipping_matrix/version.rb +1 -1
- data/spec/features/shipping_matrix_checkout_spec.rb +44 -25
- data/spec/spec_helper.rb +1 -1
- data/spec/unit/models/shipping_matrix_rule_spec.rb +6 -4
- metadata +3 -3
@@ -1,7 +1,7 @@
|
|
1
1
|
module SpreeShippingMatrix
|
2
2
|
module Generators
|
3
3
|
class InstallGenerator < Rails::Generators::Base
|
4
|
-
class_option :auto_run_migrations, :
|
4
|
+
class_option :auto_run_migrations, type: :boolean, default: false
|
5
5
|
|
6
6
|
def add_javascripts
|
7
7
|
append_file 'vendor/assets/javascripts/spree/backend/all.js', "//= require spree/backend/spree_shipping_matrix\n"
|
@@ -2,34 +2,41 @@ feature 'Shipping Matrix in checkout flow' do
|
|
2
2
|
before(:each) do
|
3
3
|
given_there_are_many_spree_roles
|
4
4
|
and_there_are_payment_methods_and_zones
|
5
|
-
|
5
|
+
and_there_is_1_shipping_matrix_with_rules [['entry', 26, '6.99'],
|
6
|
+
['entry', 52, '5.99'],
|
7
|
+
['vip', 26, '4.99'],
|
8
|
+
['vip', 52, '3.00'],
|
9
|
+
['ultra_vip', 26, '2.00'],
|
10
|
+
['ultra_vip', 52, '1.00'],
|
11
|
+
['press', 26, '0.00'],
|
12
|
+
['press', 52, '0.00']]
|
6
13
|
and_there_is_1_shipping_method_with_matrix_calculator
|
7
14
|
end
|
8
15
|
|
9
|
-
[['entry', 26, '
|
10
|
-
['entry', 52, '
|
11
|
-
['vip', 26, '
|
12
|
-
['vip', 52, '
|
13
|
-
['ultra_vip', 26, '
|
14
|
-
['ultra_vip', 52, '
|
16
|
+
[['entry', 26, '6.99'],
|
17
|
+
['entry', 52, '5.99'],
|
18
|
+
['vip', 26, '4.99'],
|
19
|
+
['vip', 52, '3.00'],
|
20
|
+
['ultra_vip', 26, '2.00'],
|
21
|
+
['ultra_vip', 52, '1.00'],
|
15
22
|
['press', 26, '0.00'],
|
16
23
|
['press', 52, '0.00']].each do |role, order_value, price|
|
17
24
|
scenario "Delivery price as #{role}" do
|
18
25
|
given_i_am_logged_in_as_user_with(role)
|
19
|
-
|
20
|
-
|
26
|
+
when_my_basket_value_is(order_value)
|
27
|
+
and_i_have_reached_the_delivery_stage_of_checkout
|
21
28
|
then_i_should_see_the_delivery_price_of(price)
|
22
29
|
end
|
23
30
|
|
24
31
|
scenario "Cheapest shipping method for #{role}" do
|
25
32
|
given_i_am_logged_in_as_user_with(role)
|
26
|
-
|
27
|
-
|
33
|
+
when_my_basket_value_is(order_value)
|
34
|
+
and_there_is_more_than_one_shipping_method
|
28
35
|
then_i_should_see_the_cheapest_delivery_price_of(price)
|
29
36
|
end
|
30
37
|
end
|
31
38
|
|
32
|
-
scenario
|
39
|
+
scenario 'Free shipping method always wins' do
|
33
40
|
given_i_am_logged_in
|
34
41
|
when_there_is_a_free_delivery_method
|
35
42
|
then_the_delivery_should_be_free
|
@@ -45,12 +52,18 @@ end
|
|
45
52
|
def and_there_are_payment_methods_and_zones
|
46
53
|
FactoryGirl.create(:check_payment_method)
|
47
54
|
country = FactoryGirl.create(:country)
|
48
|
-
Spree::Zone.global.members << Spree::ZoneMember.create(:
|
49
|
-
country.states << FactoryGirl.create(:state, :
|
55
|
+
Spree::Zone.global.members << Spree::ZoneMember.create(zoneable: country)
|
56
|
+
country.states << FactoryGirl.create(:state, country: country)
|
50
57
|
end
|
51
58
|
|
52
|
-
def
|
53
|
-
|
59
|
+
def and_there_is_1_shipping_matrix_with_rules(rules)
|
60
|
+
@matrix = create(:shipping_matrix)
|
61
|
+
|
62
|
+
rules.each do |role, min_line_item_total, amount|
|
63
|
+
@matrix.rules.create(role: Spree::Role.find_by(name: role),
|
64
|
+
min_line_item_total: min_line_item_total,
|
65
|
+
amount: amount)
|
66
|
+
end
|
54
67
|
end
|
55
68
|
|
56
69
|
def and_there_is_1_shipping_method_with_matrix_calculator
|
@@ -58,24 +71,30 @@ def and_there_is_1_shipping_method_with_matrix_calculator
|
|
58
71
|
create(:shipping_method, calculator: calc)
|
59
72
|
end
|
60
73
|
|
61
|
-
def
|
62
|
-
order =
|
63
|
-
|
64
|
-
|
74
|
+
def when_my_basket_value_is(value)
|
75
|
+
@order = Spree::Order.create!(user: @user)
|
76
|
+
line_item = create(:line_item, price: value, order: @order)
|
77
|
+
line_item.variant.update!(price: value)
|
78
|
+
@order.reload
|
65
79
|
end
|
66
80
|
|
67
|
-
def
|
68
|
-
Spree::
|
81
|
+
def and_i_have_reached_the_delivery_stage_of_checkout
|
82
|
+
@order.bill_address = FactoryGirl.create(:address, :country_id => Spree::Zone.global.members.first.zoneable.id)
|
83
|
+
@order.ship_address = FactoryGirl.create(:address, :country_id => Spree::Zone.global.members.first.zoneable.id)
|
84
|
+
@order.next!
|
85
|
+
@order.next!
|
86
|
+
Spree::CheckoutController.any_instance.stub(:current_order => @order)
|
69
87
|
end
|
70
88
|
|
71
|
-
def
|
89
|
+
def and_there_is_more_than_one_shipping_method
|
72
90
|
create(:shipping_method)
|
73
|
-
|
91
|
+
and_i_have_reached_the_delivery_stage_of_checkout
|
74
92
|
end
|
75
93
|
|
76
94
|
def when_there_is_a_free_delivery_method
|
77
95
|
create(:free_shipping_method)
|
78
|
-
|
96
|
+
when_my_basket_value_is(10)
|
97
|
+
and_i_have_reached_the_delivery_stage_of_checkout
|
79
98
|
end
|
80
99
|
|
81
100
|
def then_i_should_see_the_delivery_price_of(expected_delivery)
|
data/spec/spec_helper.rb
CHANGED
@@ -2,10 +2,12 @@ describe Spree::ShippingMatrixRule do
|
|
2
2
|
context 'when created' do
|
3
3
|
subject { described_class.create(attrs) }
|
4
4
|
|
5
|
-
let(:attrs)
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
let(:attrs) do
|
6
|
+
{ role: create(:role),
|
7
|
+
min_line_item_total: 50,
|
8
|
+
amount: 2.99,
|
9
|
+
matrix: create(:shipping_matrix) }
|
10
|
+
end
|
9
11
|
|
10
12
|
context 'and all required parameters are provided' do
|
11
13
|
it { is_expected.to be_valid }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree_shipping_matrix
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-09-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: spree_core
|
@@ -278,7 +278,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
278
278
|
version: '0'
|
279
279
|
segments:
|
280
280
|
- 0
|
281
|
-
hash: -
|
281
|
+
hash: -1089415386179746999
|
282
282
|
requirements:
|
283
283
|
- none
|
284
284
|
rubyforge_project:
|