Skip to content

Commit 67226db

Browse files
committed
Fix rails_application tests after adding price to pricing command/events
1 parent 4476fe5 commit 67226db

23 files changed

+62
-29
lines changed

rails_application/test/client_orders/discount_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def change_percentage_discount(order_id)
8686
end
8787

8888
def item_added_to_basket(order_id, product_id)
89-
run_command(Pricing::AddPriceItem.new(product_id: product_id, order_id: order_id))
89+
run_command(Pricing::AddPriceItem.new(product_id: product_id, order_id: order_id, price: 50))
9090
end
9191

9292
def prepare_product(product_id)

rails_application/test/client_orders/item_added_to_basket_test.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ def test_add_new_item
2828
data: {
2929
order_id: order_id,
3030
product_id: product_id,
31+
price: 49,
3132
}
3233
)
3334
)
@@ -70,6 +71,7 @@ def test_add_the_same_item_2nd_time
7071
data: {
7172
order_id: order_id,
7273
product_id: product_id,
74+
price: 49,
7375
}
7476
)
7577
)
@@ -79,6 +81,7 @@ def test_add_the_same_item_2nd_time
7981
data: {
8082
order_id: order_id,
8183
product_id: product_id,
84+
price: 49,
8285
}
8386
)
8487
)
@@ -137,6 +140,7 @@ def test_add_another_item
137140
data: {
138141
order_id: order_id,
139142
product_id: product_id,
143+
price: 20,
140144
}
141145
)
142146
)
@@ -146,6 +150,7 @@ def test_add_another_item
146150
data: {
147151
order_id: order_id,
148152
product_id: another_product_id,
153+
price: 20,
149154
}
150155
)
151156
)

rails_application/test/client_orders/item_removed_from_basket_test.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def test_remove_item_when_quantity_gt_1
3030
data: {
3131
order_id: order_id,
3232
product_id: product_id,
33+
price: 20,
3334
}
3435
)
3536
)
@@ -38,6 +39,7 @@ def test_remove_item_when_quantity_gt_1
3839
data: {
3940
order_id: order_id,
4041
product_id: product_id,
42+
price: 20,
4143
}
4244
)
4345
)
@@ -83,6 +85,7 @@ def test_remove_item_when_quantity_eq_1
8385
data: {
8486
order_id: order_id,
8587
product_id: product_id,
88+
price: 20,
8689
}
8790
)
8891
)
@@ -140,6 +143,7 @@ def test_remove_item_when_there_is_another_item
140143
data: {
141144
order_id: order_id,
142145
product_id: product_id,
146+
price: 20,
143147
}
144148
)
145149
)
@@ -148,6 +152,7 @@ def test_remove_item_when_there_is_another_item
148152
data: {
149153
order_id: order_id,
150154
product_id: product_id,
155+
price: 20,
151156
}
152157
)
153158
)
@@ -156,6 +161,7 @@ def test_remove_item_when_there_is_another_item
156161
data: {
157162
order_id: order_id,
158163
product_id: another_product_id,
164+
price: 20,
159165
}
160166
)
161167
)

rails_application/test/client_orders/order_cancelled_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def test_order_confirmed
1818
))
1919

2020
create_product(product_id, "Async Remote", 30)
21-
run_command(Pricing::AddPriceItem.new(order_id: order_id, product_id: product_id))
21+
run_command(Pricing::AddPriceItem.new(order_id: order_id, product_id: product_id, price: 30))
2222
run_command(Pricing::AcceptOffer.new(order_id: order_id))
2323

2424
event_store.publish(

rails_application/test/client_orders/order_expired_test.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def test_order_expired
3434
data: {
3535
order_id: order_id,
3636
product_id: product_id,
37+
price: 39
3738
}
3839
)
3940
)

rails_application/test/client_orders/order_paid_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def test_order_confirmed
1212

1313
run_command(Crm::RegisterCustomer.new(customer_id: customer_id, name: "John Doe"))
1414
create_product(product_id, "Async Remote", 30)
15-
run_command(Pricing::AddPriceItem.new(order_id: order_id, product_id: product_id))
15+
run_command(Pricing::AddPriceItem.new(order_id: order_id, product_id: product_id, price: 30))
1616

1717
event_store.publish(
1818
Pricing::OrderTotalValueCalculated.new(

rails_application/test/client_orders/time_promotion_discount_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def set_percentage_discount(order_id)
6060
end
6161

6262
def item_added_to_basket(order_id, product_id)
63-
run_command(Pricing::AddPriceItem.new(product_id: product_id, order_id: order_id))
63+
run_command(Pricing::AddPriceItem.new(product_id: product_id, order_id: order_id, price: 50))
6464
end
6565

6666
def prepare_product(product_id)

rails_application/test/client_orders/update_paid_orders_summary_test.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ def test_update_orders_summary
1515
set_price_to_product(product_id, 3)
1616
register_customer(other_customer_id)
1717
register_customer(customer_id)
18-
add_item_to_basket(order_id, product_id)
18+
add_item_to_basket(order_id, product_id, 3)
1919
confirm_order(customer_id, order_id, 3)
2020

2121
customer = Client.find_by(uid: customer_id)
2222
assert_equal 3.to_d, customer.paid_orders_summary
2323

2424
order_id = SecureRandom.uuid
25-
add_item_to_basket(order_id, product_id)
26-
add_item_to_basket(order_id, product_id)
25+
add_item_to_basket(order_id, product_id, 3)
26+
add_item_to_basket(order_id, product_id, 3)
2727
confirm_order(customer_id, order_id, 6)
2828

2929
customer = Client.find_by(uid: customer_id)
@@ -53,8 +53,8 @@ def set_price_to_product(product_id, price)
5353
run_command(Pricing::SetPrice.new(product_id: product_id, price: price))
5454
end
5555

56-
def add_item_to_basket(order_id, product_id)
57-
run_command(Pricing::AddPriceItem.new(order_id: order_id, product_id: product_id))
56+
def add_item_to_basket(order_id, product_id, price)
57+
run_command(Pricing::AddPriceItem.new(order_id: order_id, product_id: product_id, price: price))
5858
end
5959

6060
def confirm_order(customer_id, order_id, total_amount)

rails_application/test/customers/update_paid_orders_summary_test.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ def test_update_orders_summary
1515
register_product(product_id)
1616
name_product(product_id, "Async Remote")
1717
set_price_to_product(product_id, 3)
18-
add_item_to_basket(order_id, product_id)
18+
add_item_to_basket(order_id, product_id, 3)
1919
confirm_order(customer_id, order_id, 3)
2020

2121
customer = Customer.find(customer_id)
2222
assert_equal 3.to_d, customer.paid_orders_summary
2323

2424
order_id = SecureRandom.uuid
25-
add_item_to_basket(order_id, product_id)
26-
add_item_to_basket(order_id, product_id)
25+
add_item_to_basket(order_id, product_id, 3)
26+
add_item_to_basket(order_id, product_id, 3)
2727
confirm_order(customer_id, order_id, 6)
2828

2929
customer = Customer.find(customer_id)
@@ -48,8 +48,8 @@ def set_price_to_product(product_id, price)
4848
run_command(Pricing::SetPrice.new(product_id: product_id, price: price))
4949
end
5050

51-
def add_item_to_basket(order_id, product_id)
52-
run_command(Pricing::AddPriceItem.new(order_id: order_id, product_id: product_id))
51+
def add_item_to_basket(order_id, product_id, price)
52+
run_command(Pricing::AddPriceItem.new(order_id: order_id, product_id: product_id, price: price))
5353
end
5454

5555
def confirm_order(customer_id, order_id, total_amount)

rails_application/test/orders/broadcast_test.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ def test_broadcast_add_item_to_basket
5050
data: {
5151
order_id: order_id,
5252
product_id: product_id,
53+
price: 20,
5354
}
5455
)
5556
)
@@ -83,6 +84,7 @@ def test_broadcast_remove_item_from_basket
8384
data: {
8485
order_id: order_id,
8586
product_id: product_id,
87+
price: 20,
8688
}
8789
)
8890
)
@@ -128,6 +130,7 @@ def test_broadcast_update_order_value
128130
data: {
129131
order_id: order_id,
130132
product_id: product_id,
133+
price: 20,
131134
}
132135
)
133136
)
@@ -136,6 +139,7 @@ def test_broadcast_update_order_value
136139
data: {
137140
order_id: order_1_id,
138141
product_id: product_id,
142+
price: 20,
139143
}
140144
)
141145
)
@@ -194,6 +198,7 @@ def test_broadcast_update_discount
194198
data: {
195199
order_id: order_id,
196200
product_id: product_id,
201+
price: 20,
197202
}
198203
)
199204
)
@@ -202,6 +207,7 @@ def test_broadcast_update_discount
202207
data: {
203208
order_id: order_1_id,
204209
product_id: product_id,
210+
price: 20,
205211
}
206212
)
207213
)

0 commit comments

Comments
 (0)