spree_repeat_order 2.1.5 → 2.1.6
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23d04d79d2b954afbfe23147331f9bf51452e4e0
|
4
|
+
data.tar.gz: d86789bd49ffeb0f086b67f45cc5d8a1ccc097dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c0f286aa13040aa5d4acd92704f5ffd13ac3ca4adeb5cc542b27d044e08cf48ab0ac9b961b26e5888e86afb7c64a59c2729dc199639781a0c87ce3b69bdcf040
|
7
|
+
data.tar.gz: 3a080db2e8c0d044ef1ede5041a805d5870c70e032d853818bd79701b54b082899a35fb01e87668312f7aa0d46cc77f406c651ba0fae971036834f14d41e45a5
|
@@ -11,8 +11,7 @@ module Spree
|
|
11
11
|
success = true
|
12
12
|
success = success && !past_order.completed_at.blank?
|
13
13
|
success = success && new_order.save
|
14
|
-
success = success && new_order
|
15
|
-
success = success && new_order.next #DELIVERY
|
14
|
+
success = success && merge_with_current_order(new_order)
|
16
15
|
|
17
16
|
if success
|
18
17
|
flash[:success] = "The order has been duplicated. The new order id is #{new_order.number}"
|
@@ -26,8 +25,17 @@ module Spree
|
|
26
25
|
|
27
26
|
private
|
28
27
|
|
28
|
+
def merge_with_current_order(new_order)
|
29
|
+
user = new_order.user
|
30
|
+
|
31
|
+
user_last_incomplete_order = user.last_incomplete_spree_order
|
32
|
+
new_order.merge!(user_last_incomplete_order, user) if user_last_incomplete_order
|
33
|
+
new_order.save
|
34
|
+
end
|
35
|
+
|
29
36
|
def duplicate_order(past_order, new_order)
|
30
37
|
new_order.email = past_order.email
|
38
|
+
new_order.user = past_order.user
|
31
39
|
|
32
40
|
new_line_items = []
|
33
41
|
past_order.line_items.each do |line_item|
|
@@ -40,6 +48,12 @@ module Spree
|
|
40
48
|
new_order.ship_address = new_ship_address
|
41
49
|
new_bill_address = past_order.bill_address.dup
|
42
50
|
new_order.bill_address = new_bill_address
|
51
|
+
|
52
|
+
duplicate_extension(past_order, new_order)
|
53
|
+
end
|
54
|
+
|
55
|
+
def duplicate_extension(past_order, new_order)
|
56
|
+
#do nothing - only here so it can be overriden
|
43
57
|
end
|
44
58
|
|
45
59
|
end
|
@@ -3,6 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe Spree::Admin::RepeatedOrdersController do
|
4
4
|
|
5
5
|
let(:user) { mock_model Spree::User, :last_incomplete_spree_order => nil, :has_spree_role? => true, :spree_api_key => 'fake' }
|
6
|
+
let(:order_user) { mock_model(Spree::User, :last_incomplete_spree_order => nil, :has_spree_role? => true, :spree_api_key => 'fake').as_null_object }
|
6
7
|
|
7
8
|
let(:ship_address){ FactoryGirl.build(:address) }
|
8
9
|
let(:bill_address){ FactoryGirl.build(:address) }
|
@@ -13,7 +14,8 @@ describe Spree::Admin::RepeatedOrdersController do
|
|
13
14
|
ship_address: ship_address,
|
14
15
|
bill_address: bill_address,
|
15
16
|
completed_at: Date.yesterday,
|
16
|
-
number: 'ABC1'
|
17
|
+
number: 'ABC1',
|
18
|
+
user: order_user
|
17
19
|
}) }
|
18
20
|
|
19
21
|
let(:new_order){ double(Spree::Order).as_null_object }
|
@@ -53,6 +55,7 @@ describe Spree::Admin::RepeatedOrdersController do
|
|
53
55
|
ship_address.should_receive(:dup).and_return(new_ship_address)
|
54
56
|
bill_address.should_receive(:dup).and_return(new_bill_address)
|
55
57
|
|
58
|
+
new_order.should_receive(:user=).with(order_user)
|
56
59
|
new_order.should_receive(:ship_address=).with(new_ship_address)
|
57
60
|
new_order.should_receive(:bill_address=).with(new_bill_address)
|
58
61
|
|
@@ -66,6 +69,32 @@ describe Spree::Admin::RepeatedOrdersController do
|
|
66
69
|
response.should redirect_to('/admin/orders/ABC1')
|
67
70
|
end
|
68
71
|
|
72
|
+
describe 'merging with current order' do
|
73
|
+
|
74
|
+
before :each do
|
75
|
+
@new_order = Spree::Order.new
|
76
|
+
@new_order.stub(:merge!)
|
77
|
+
Spree::Order.stub(:new).and_return(@new_order)
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'should merge last incomplete order with new order' do
|
81
|
+
incomplete_order = double(Spree::Order)
|
82
|
+
order_user.stub(:last_incomplete_spree_order).and_return(incomplete_order)
|
83
|
+
@new_order.should_receive(:merge!).with(incomplete_order, order_user)
|
84
|
+
|
85
|
+
spree_post :create, number: "ABC1"
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'should not merge if user doesnt have a last incomplete order' do
|
89
|
+
order_user.stub(:last_incomplete_spree_order).and_return(nil)
|
90
|
+
@new_order.should_not_receive(:merge!)
|
91
|
+
|
92
|
+
spree_post :create, number: "ABC1"
|
93
|
+
end
|
94
|
+
|
95
|
+
|
96
|
+
end
|
97
|
+
|
69
98
|
end
|
70
99
|
|
71
100
|
describe 'integration' do
|
@@ -76,6 +105,7 @@ describe Spree::Admin::RepeatedOrdersController do
|
|
76
105
|
end
|
77
106
|
|
78
107
|
it 'should create new order with same line items' do
|
108
|
+
user = FactoryGirl.create(:user)
|
79
109
|
ship_address = FactoryGirl.create(:address)
|
80
110
|
bill_address = FactoryGirl.create(:address)
|
81
111
|
past_order = FactoryGirl.create(:completed_order_with_totals, ship_address: ship_address, bill_address: bill_address)
|
@@ -85,7 +115,7 @@ describe Spree::Admin::RepeatedOrdersController do
|
|
85
115
|
|
86
116
|
last_order = Spree::Order.last
|
87
117
|
last_order.line_items.count.should == past_order.line_items.count
|
88
|
-
last_order.state.should == '
|
118
|
+
last_order.state.should == 'cart'
|
89
119
|
last_order.ship_address.firstname = past_order.ship_address.firstname
|
90
120
|
last_order.bill_address.firstname = past_order.bill_address.firstname
|
91
121
|
end
|
data/spree_repeat_order.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
Gem::Specification.new do |s|
|
3
3
|
s.platform = Gem::Platform::RUBY
|
4
4
|
s.name = 'spree_repeat_order'
|
5
|
-
s.version = '2.1.
|
5
|
+
s.version = '2.1.6'
|
6
6
|
s.summary = 'Makes it possible to repeat an existing order with one click'
|
7
7
|
s.description = ''
|
8
8
|
s.required_ruby_version = '>= 2.0.0'
|
@@ -16,9 +16,9 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.require_path = 'lib'
|
17
17
|
s.requirements << 'none'
|
18
18
|
|
19
|
-
s.add_dependency 'spree_core', '~> 2.1.
|
20
|
-
s.add_dependency 'spree_frontend', '~> 2.1.
|
21
|
-
s.add_dependency 'spree_backend', '~> 2.1.
|
19
|
+
s.add_dependency 'spree_core', '~> 2.1.4'
|
20
|
+
s.add_dependency 'spree_frontend', '~> 2.1.4'
|
21
|
+
s.add_dependency 'spree_backend', '~> 2.1.4'
|
22
22
|
|
23
23
|
s.add_development_dependency 'capybara', '~> 2.1'
|
24
24
|
s.add_development_dependency 'coffee-rails'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree_repeat_order
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Francisco Trindade
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: spree_core
|
@@ -16,42 +16,42 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.1.
|
19
|
+
version: 2.1.4
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.1.
|
26
|
+
version: 2.1.4
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: spree_frontend
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 2.1.
|
33
|
+
version: 2.1.4
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 2.1.
|
40
|
+
version: 2.1.4
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: spree_backend
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 2.1.
|
47
|
+
version: 2.1.4
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 2.1.
|
54
|
+
version: 2.1.4
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: capybara
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|