proclaimer 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/app/models/spree/product_decorator.rb +14 -0
- data/lib/proclaimer/version.rb +1 -1
- data/spec/models/spree/order_spec.rb +25 -23
- data/spec/models/spree/order_updater_spec.rb +2 -2
- data/spec/models/spree/payment_spec.rb +13 -11
- data/spec/models/spree/product_spec.rb +36 -0
- data/spec/models/spree/refund_spec.rb +23 -21
- data/spec/models/spree/shipment_spec.rb +43 -40
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 52c69df73835fe00be8d56f7f7deeee774ad6a5e
|
4
|
+
data.tar.gz: 0c6b1b232a4c32c4886576acde714c3bc29e917d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dce7f586aabe933a013d6c905588839a739886a6181c0e6c61db22e8fc7d6c8835de4d3a97e3589c8693690aa98865cbfa7626f374d0c4d77a1e5c411da71308
|
7
|
+
data.tar.gz: fcfde9c493ee65e6b3dd47864b6a667539cbf8eb7d14fd8594050ff4c181a67b81951f4d87ea814888f830652ed0ac081bddf1eaafd3a4dd1c09235d50c32969
|
data/Gemfile.lock
CHANGED
data/lib/proclaimer/version.rb
CHANGED
@@ -1,36 +1,38 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
module Spree
|
4
|
+
RSpec.describe Order, type: :model do
|
5
|
+
before { stub_const("EMPTY_PAYLOAD", Object.new) }
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
7
|
+
context "when order is first created" do
|
8
|
+
it "does not instrument any order event" do
|
9
|
+
payload = EMPTY_PAYLOAD
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
ActiveSupport::Notifications.subscribed(
|
12
|
+
-> (*args) { payload = args.last },
|
13
|
+
/^spree\.order/
|
14
|
+
) do
|
15
|
+
create(:order)
|
15
16
|
|
16
|
-
|
17
|
+
expect(payload).to eq EMPTY_PAYLOAD
|
18
|
+
end
|
17
19
|
end
|
18
20
|
end
|
19
|
-
end
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
|
22
|
+
context "when order is complete" do
|
23
|
+
it "instruments order.complete event" do
|
24
|
+
payload = EMPTY_PAYLOAD
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
26
|
+
ActiveSupport::Notifications.subscribed(
|
27
|
+
-> (*args) { payload = args.last },
|
28
|
+
"spree.order.complete"
|
29
|
+
) do
|
30
|
+
order = create(:order_with_line_items, state: "confirm")
|
31
|
+
create(:payment, amount: order.total, order: order)
|
32
|
+
order.next!
|
32
33
|
|
33
|
-
|
34
|
+
expect(payload[:order]).to eq order
|
35
|
+
end
|
34
36
|
end
|
35
37
|
end
|
36
38
|
end
|
@@ -6,8 +6,8 @@ module Spree
|
|
6
6
|
describe "#update_shipments_with_status_tracking" do
|
7
7
|
it "calls shipment#broadcast on shipments that have changed state" do
|
8
8
|
fake_shipments = [
|
9
|
-
fake_shipment_with_state(
|
10
|
-
fake_shipment_with_state(
|
9
|
+
fake_shipment_with_state("pending", "ready"),
|
10
|
+
fake_shipment_with_state("pending")
|
11
11
|
]
|
12
12
|
fake_order = double(Order, shipments: fake_shipments)
|
13
13
|
updater = described_class.new(fake_order)
|
@@ -1,18 +1,20 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
module Spree
|
4
|
+
RSpec.describe Payment, type: :model do
|
5
|
+
context "when payment is complete" do
|
6
|
+
it "instruments payment.complete event" do
|
7
|
+
payload = nil
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
ActiveSupport::Notifications.subscribed(
|
10
|
+
-> (*args) { payload = args.last },
|
11
|
+
"spree.payment.complete"
|
12
|
+
) do
|
13
|
+
payment = create(:payment)
|
14
|
+
payment.complete
|
14
15
|
|
15
|
-
|
16
|
+
expect(payload[:payment]).to eq payment
|
17
|
+
end
|
16
18
|
end
|
17
19
|
end
|
18
20
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module Spree
|
4
|
+
RSpec.describe Product, type: :model do
|
5
|
+
context "when changes are present" do
|
6
|
+
it "instruments spree.product.updated event" do
|
7
|
+
product = build_product
|
8
|
+
|
9
|
+
product.run_callbacks(:save)
|
10
|
+
|
11
|
+
expect(ActiveSupport::Notifications).
|
12
|
+
to have_received(:instrument).
|
13
|
+
with("spree.product.updated", product: product)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
context "when no changes are present" do
|
18
|
+
it "instruments spree.product.updated event" do
|
19
|
+
product = build_product
|
20
|
+
allow(product).to receive(:anything_changed?) { false }
|
21
|
+
|
22
|
+
product.run_callbacks(:save)
|
23
|
+
|
24
|
+
expect(ActiveSupport::Notifications).
|
25
|
+
not_to have_received(:instrument).
|
26
|
+
with("spree.product.updated", product: product)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def build_product
|
31
|
+
build(:product).tap do
|
32
|
+
allow(ActiveSupport::Notifications).to receive(:instrument)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -1,34 +1,36 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
module Spree
|
4
|
+
RSpec.describe Refund, type: :model do
|
5
|
+
before { stub_const("EMPTY_PAYLOAD", Object.new) }
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
7
|
+
context "when refund have not been processed" do
|
8
|
+
it "does not instrument any refund event" do
|
9
|
+
payload = EMPTY_PAYLOAD
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
ActiveSupport::Notifications.subscribed(
|
12
|
+
-> (*args) { payload = args.last },
|
13
|
+
/^spree\.refund/
|
14
|
+
) do
|
15
|
+
build(:refund)
|
15
16
|
|
16
|
-
|
17
|
+
expect(payload).to eq EMPTY_PAYLOAD
|
18
|
+
end
|
17
19
|
end
|
18
20
|
end
|
19
|
-
end
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
|
22
|
+
context "when the refund has been processed" do
|
23
|
+
it "instruments refund.complete event" do
|
24
|
+
payload = EMPTY_PAYLOAD
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
ActiveSupport::Notifications.subscribed(
|
27
|
+
-> (*args) { payload = args.last },
|
28
|
+
"spree.refund.complete"
|
29
|
+
) do
|
30
|
+
refund = create(:refund, payment: create(:payment, amount: 100))
|
30
31
|
|
31
|
-
|
32
|
+
expect(payload[:refund]).to eq refund
|
33
|
+
end
|
32
34
|
end
|
33
35
|
end
|
34
36
|
end
|
@@ -1,58 +1,61 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
3
|
+
module Spree
|
4
|
+
RSpec.describe Shipment, type: :model do
|
5
|
+
context "when shipment is pending" do
|
6
|
+
it "instruments shipment.pending event" do
|
7
|
+
payload = nil
|
8
|
+
|
9
|
+
ActiveSupport::Notifications.subscribed(
|
10
|
+
-> (*args) { payload = args.last },
|
11
|
+
"spree.shipment.pending"
|
12
|
+
) do
|
13
|
+
shipment = create(:shipment)
|
14
|
+
|
15
|
+
expect(payload[:shipment]).to eq shipment
|
16
|
+
end
|
15
17
|
end
|
16
18
|
end
|
17
|
-
end
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
context "when shipment is ready" do
|
21
|
+
it "instruments shipment.ready event" do
|
22
|
+
shipment = create(:shipment)
|
23
|
+
allow(shipment).to receive(:determine_state) { 'ready' }
|
24
|
+
allow(ActiveSupport::Notifications).to receive(:instrument)
|
24
25
|
|
25
|
-
|
26
|
+
shipment.ready
|
26
27
|
|
27
|
-
|
28
|
-
|
29
|
-
|
28
|
+
expect(ActiveSupport::Notifications).
|
29
|
+
to have_received(:instrument).
|
30
|
+
with("spree.shipment.ready", shipment: shipment)
|
31
|
+
end
|
30
32
|
end
|
31
|
-
end
|
32
33
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
34
|
+
context "when shipment is canceled" do
|
35
|
+
it "instruments shipment.canceled event" do
|
36
|
+
shipment = create(:shipment)
|
37
|
+
allow(ActiveSupport::Notifications).to receive(:instrument)
|
37
38
|
|
38
|
-
|
39
|
+
shipment.cancel
|
39
40
|
|
40
|
-
|
41
|
-
|
42
|
-
|
41
|
+
expect(ActiveSupport::Notifications).
|
42
|
+
to have_received(:instrument).
|
43
|
+
with("spree.shipment.canceled", shipment: shipment)
|
44
|
+
end
|
43
45
|
end
|
44
|
-
end
|
45
46
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
47
|
+
describe "#broadcast_state" do
|
48
|
+
it "instruments shipment.STATE event" do
|
49
|
+
shipment = build(:shipment, state: 'pending')
|
50
|
+
allow(ActiveSupport::Notifications).to receive(:instrument)
|
50
51
|
|
51
|
-
|
52
|
+
shipment.broadcast_state
|
52
53
|
|
53
|
-
|
54
|
-
|
55
|
-
|
54
|
+
expect(ActiveSupport::Notifications).
|
55
|
+
to have_received(:instrument).
|
56
|
+
with("spree.shipment.pending", shipment: shipment)
|
57
|
+
end
|
56
58
|
end
|
57
59
|
end
|
58
60
|
end
|
61
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: proclaimer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Prem Sichanugrist
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2015-10-
|
13
|
+
date: 2015-10-07 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: spree_backend
|
@@ -168,6 +168,7 @@ files:
|
|
168
168
|
- app/models/spree/order_decorator.rb
|
169
169
|
- app/models/spree/order_updater_decorator.rb
|
170
170
|
- app/models/spree/payment_decorator.rb
|
171
|
+
- app/models/spree/product_decorator.rb
|
171
172
|
- app/models/spree/refund_decorator.rb
|
172
173
|
- app/models/spree/shipment_decorator.rb
|
173
174
|
- bin/rails
|
@@ -181,6 +182,7 @@ files:
|
|
181
182
|
- spec/models/spree/order_spec.rb
|
182
183
|
- spec/models/spree/order_updater_spec.rb
|
183
184
|
- spec/models/spree/payment_spec.rb
|
185
|
+
- spec/models/spree/product_spec.rb
|
184
186
|
- spec/models/spree/refund_spec.rb
|
185
187
|
- spec/models/spree/shipment_spec.rb
|
186
188
|
- spec/proclaimer_spec.rb
|
@@ -214,6 +216,7 @@ test_files:
|
|
214
216
|
- spec/models/spree/order_spec.rb
|
215
217
|
- spec/models/spree/order_updater_spec.rb
|
216
218
|
- spec/models/spree/payment_spec.rb
|
219
|
+
- spec/models/spree/product_spec.rb
|
217
220
|
- spec/models/spree/refund_spec.rb
|
218
221
|
- spec/models/spree/shipment_spec.rb
|
219
222
|
- spec/proclaimer_spec.rb
|