Skip to content

Commit 393429c

Browse files
committed
CR remarks
1 parent 788d189 commit 393429c

File tree

7 files changed

+12
-12
lines changed

7 files changed

+12
-12
lines changed

ecommerce/ordering/lib/ordering.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
require_relative "ordering/service"
2323
require_relative "ordering/order"
2424
require_relative "ordering/refund"
25-
require_relative "ordering/projections"
25+
require_relative "ordering/product_quantity_available_to_refund"
2626

2727
module Ordering
2828
class Configuration

ecommerce/ordering/lib/ordering/projections.rb renamed to ecommerce/ordering/lib/ordering/product_quantity_available_to_refund.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module Ordering
2-
class Projections
3-
def self.product_quantity_available_to_refund(order_id, product_id)
2+
class ProductQuantityAvailableToRefund
3+
def self.call(order_id, product_id)
44
RubyEventStore::Projection
55
.from_stream("Ordering::Order$#{order_id}")
66
.init(-> { { available: 0 } })

ecommerce/ordering/lib/ordering/refund.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ class Refund
33
include AggregateRoot
44

55
ExceedsOrderQuantityError = Class.new(StandardError)
6-
ProductNotFoundError = Class.new(StandardError)
6+
RefundHaveNotBeenRequestedForThisProductError = Class.new(StandardError)
77

88
def initialize(id)
99
@id = id
@@ -20,7 +20,7 @@ def add_item(product_id, available_quantity_to_refund)
2020
end
2121

2222
def remove_item(product_id)
23-
raise ProductNotFoundError unless @refund_items.quantity(product_id).positive?
23+
raise RefundHaveNotBeenRequestedForThisProductError unless @refund_items.quantity(product_id).positive?
2424
apply ItemRemovedFromRefund.new(data: { refund_id: @id, order_id: @order_id, product_id: product_id })
2525
end
2626

ecommerce/ordering/lib/ordering/service.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ def call(command)
103103
private
104104

105105
def available_quantity_to_refund(order_id, product_id)
106-
Projections
107-
.product_quantity_available_to_refund(order_id, product_id)
106+
ProductQuantityAvailableToRefund
107+
.call(order_id, product_id)
108108
.run(@event_store)
109109
.fetch(:available)
110110
end

ecommerce/ordering/test/projections_test.rb renamed to ecommerce/ordering/test/product_quantity_available_to_refund_test.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
require_relative "test_helper"
22

33
module Ordering
4-
class ProjectionsTest < Test
5-
cover "Ordering::Projections"
4+
class ProductQuantityAvailableToRefundTest < Test
5+
cover "Ordering::ProductQuantityAvailableToRefund"
66

77
def test_product_quantity_available_to_refund
88
order_id = SecureRandom.uuid
99
product_id = SecureRandom.uuid
1010
another_product_id = SecureRandom.uuid
1111
stream_name = "Ordering::Order$#{order_id}"
12-
projection = Projections.product_quantity_available_to_refund(order_id, product_id)
12+
projection = ProductQuantityAvailableToRefund.call(order_id, product_id)
1313

1414
event_store = RubyEventStore::Client.new(repository: RubyEventStore::InMemoryRepository.new)
1515

ecommerce/ordering/test/remove_item_from_refund_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def test_cant_remove_item_with_0_quantity
6767
)
6868
)
6969

70-
assert_raises(Refund::ProductNotFoundError) do
70+
assert_raises(Refund::RefundHaveNotBeenRequestedForThisProductError) do
7171
act(
7272
RemoveItemFromRefund.new(
7373
refund_id: aggregate_id,

rails_application/app/controllers/refunds_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def add_item
2323
def remove_item
2424
remove_item_from_refund
2525
redirect_to edit_order_refund_path(params[:id], order_id: params[:order_id])
26-
rescue Ordering::Refund::ProductNotFoundError
26+
rescue Ordering::Refund::RefundHaveNotBeenRequestedForThisProductError
2727
flash[:alert] = "This product is not added to the refund."
2828
redirect_to edit_order_refund_path(params[:id], order_id: params[:order_id])
2929
end

0 commit comments

Comments
 (0)