Skip to content

Commit 046ab93

Browse files
Simplify ReleasePaymentProcess state to match actual decisions
The state tracked 5 transitions across 3 fields but only 2 drove behavior — mutant confirmed the rest were dead state. Replacing symbolic values with booleans removes the mutant ignore entirely.
1 parent 551ca91 commit 046ab93

2 files changed

Lines changed: 9 additions & 17 deletions

File tree

apps/rails_application/.mutant.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ matcher:
5555
- Processes::Configuration*
5656
- Processes::OrderConfirmation#stream_name
5757
- Processes::Test*
58-
- Processes::ReleasePaymentProcess#apply
5958
- Processes::Invoices::MoneySplitter*
6059
- Processes::SyncShipmentFromPricing*
6160
- Processes::SyncInventoryFromOrdering*

apps/rails_application/app/processes/processes/release_payment_process.rb

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,36 +22,29 @@ def act
2222
def apply(event)
2323
case event
2424
when Payments::PaymentAuthorized
25-
state.with(payment: :authorized)
25+
state.with(payment_authorized: true)
2626
when Payments::PaymentReleased
27-
state.with(payment: :released)
28-
when Fulfillment::OrderRegistered
29-
state.with(
30-
order: :placed,
31-
order_id: event.data.fetch(:order_id)
32-
)
27+
state.with(payment_authorized: false)
3328
when Pricing::OfferExpired
34-
state.with(order: :expired)
35-
when Fulfillment::OrderConfirmed
36-
state.with(order: :confirmed)
29+
state.with(order_expired: true)
30+
else
31+
state
3732
end
3833
end
3934

4035
def release_payment
41-
command_bus.call(Payments::ReleasePayment.new(order_id: state.order_id))
36+
command_bus.call(Payments::ReleasePayment.new(order_id: id))
4237
end
4338

4439
def fetch_id(event)
4540
event.data.fetch(:order_id)
4641
end
4742

48-
ProcessState = Data.define(:order, :payment, :order_id) do
49-
def initialize(order: :draft, payment: :none, order_id: nil)
50-
super
51-
end
43+
ProcessState = Data.define(:payment_authorized, :order_expired) do
44+
def initialize(payment_authorized: false, order_expired: false) = super
5245

5346
def release?
54-
payment.eql?(:authorized) && order.eql?(:expired)
47+
payment_authorized && order_expired
5548
end
5649
end
5750
end

0 commit comments

Comments
 (0)