Skip to content

Commit cecd654

Browse files
committed
fix tests
align command field name with event payload attribute name
1 parent 6d0b619 commit cecd654

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

ecommerce/pricing/lib/pricing/commands.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ class AcceptOffer < Infra::Command
112112
class RejectOffer < Infra::Command
113113
attribute :order_id, Infra::Types::UUID
114114
attribute :reason, Infra::Types::String
115-
attribute? :unavailable_products, Infra::Types::Array.of(Infra::Types::UUID)
115+
attribute? :unavailable_product_ids, Infra::Types::Array.of(Infra::Types::UUID)
116116

117117
alias aggregate_id order_id
118118
end

ecommerce/pricing/lib/pricing/services.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ def initialize(event_store)
228228

229229
def call(command)
230230
@repository.with_aggregate(Offer, command.aggregate_id) do |order|
231-
order.reject(command.reason, command.unavailable_products)
231+
order.reject(command.reason, command.unavailable_product_ids)
232232
end
233233
end
234234
end

ecommerce/pricing/test/offer_lifecycle_test.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,11 @@ def test_accepted_offer_can_be_rejected
4848
OfferRejected.new(
4949
data: {
5050
order_id: order_id,
51+
reason: "Some products were unavailable",
52+
unavailable_product_ids: [product_id]
5153
}
5254
)
53-
) { reject_offer(order_id) }
55+
) { reject_offer(order_id, product_id) }
5456

5557
end
5658

@@ -62,7 +64,7 @@ def test_draft_offer_cant_be_rejected
6264
add_item(order_id, product_id)
6365

6466
exp = assert_raises(Pricing::Offer::InvalidState, "Only accepted offer can be rejected") do
65-
reject_offer(order_id)
67+
reject_offer(order_id, product_id)
6668
end
6769
assert_equal("Only accepted offer can be rejected", exp.message)
6870
end
@@ -119,8 +121,8 @@ def accept_offer(order_id)
119121
run_command(AcceptOffer.new(order_id:))
120122
end
121123

122-
def reject_offer(order_id)
123-
run_command(RejectOffer.new(order_id:))
124+
def reject_offer(order_id, *product_ids)
125+
run_command(RejectOffer.new(order_id:, reason: "Some products were unavailable", unavailable_product_ids: product_ids))
124126
end
125127

126128
def expire_offer(order_id)

0 commit comments

Comments
 (0)