all passing
mar 26, 2026 · 12:14 utc branch feature/add-services sha 6d3cbbc
Diff Coverage
70.1%
96/137 changed lines · below 90%
Coverage
77.0%
branch: 43.4% · threshold: 80%
Suite Duration
0s
40 examples · 0 pending
Slowest Test
0.05s
OrderItem#subtotal_cents multiplies quantity by uni
Factory Creates
67
4 unique factories
Diff Coverage
Coverage
Performance
Factory Health
Insights
70.1%
of changed lines are covered
96 covered · 41 uncovered · 137 executable · 240 total changed
compared against main at d58e5eb
below 90% threshold
Per-File Diff Coverage
File Diff Cov Changed Covered Uncovered
app/services/pricing_engine.rb
29.2%
37 7 17
app/services/payment_service.rb
60.0%
43 15 10
app/models/order.rb
70.0%
38 14 6
app/services/cart_optimizer.rb
71.4%
51 20 8
app/jobs/inventory_sync_job.rb
100.0%
20 11 0
app/models/order_item.rb
100.0%
8 4 0
app/services/shipping_calculator.rb
100.0%
43 25 0
Uncovered Changed Lines
app/services/pricing_engine.rb 17 uncovered lines
2
def initialize(product, pharmacy = nil)
3
@product = product
4
@pharmacy = pharmacy
5
end
7
def calculate
8
base = @product.price_cents
9
base = apply_pharmacy_markup(base) if @pharmacy
10
base = apply_volume_discount(base)
11
base = apply_seasonal_adjustment(base)
12
{ final_price: base, currency: "EUR" }
13
end
17
def apply_pharmacy_markup(price)
18
markup = @pharmacy.auto_accept_orders? ? 1.05 : 1.08
19
(price * markup).round
20
end
22
def apply_volume_discount(price)
23
return price if @product.stock.to_i < 100
24
(price * 0.96).round
25
end
27
def apply_seasonal_adjustment(price)
28
month = Time.current.month
29
if [11, 12, 1].include?(month)
30
(price * 1.08).round # winter markup
31
elsif [6, 7, 8].include?(month)
32
(price * 0.95).round # summer discount
33
else
34
price
35
end
app/services/payment_service.rb 10 uncovered lines
19
def refund!
20
raise PaymentError, "Cannot refund pending order" if @order.status == "pending"
21
{ status: :refunded, amount: @order.total_cents }
22
end
24
def handle_timeout
25
if @order.cod?
26
@order.cancel!(reason: "payment_timeout")
27
else
28
retry_capture
29
end
34
def retry_capture
35
3.times do |attempt|
36
result = capture!
37
return result if result[:status] == :captured
38
rescue PaymentError
39
next
40
end
41
@order.cancel!(reason: "capture_failed_after_retries")
42
end
app/models/order.rb 6 uncovered lines
24
def cancel!(reason: nil)
25
update!(status: "cancelled", notes: reason)
26
end
28
def cod?
29
payment_method == "cod"
30
end
36
def awaiting_cod_confirmation?
37
cod? && status == "pending"
38
end
40
def handle_cod_timeout
41
return unless payment_method == "cod"
42
cancel!(reason: "cod_timeout") if awaiting_cod_confirmation?
43
notify_cs_team(:cod_timeout_alert)
44
end
app/services/cart_optimizer.rb 8 uncovered lines
29
def calculate_absorption(pharmacy, product)
30
ratio = pharmacy.id.to_f / (product.price_cents + 1)
31
ratio > max_absorption ? max_absorption : ratio
32
end
34
def max_absorption
35
0.15
36
end
38
def apply_discounts(items)
39
items.map do |item|
40
if item[:price] > 4000
41
item.merge(discount: (item[:price] * 0.05).round)
42
else
43
item
44
end
48
def validate_availability(pharmacy, products)
49
products.all? { |p| p.in_stock? }
50
end
files changed
7
100% covered
3
partially covered
4
not loaded by tests
0
File Coverage Breakdown
click a file to view line-by-line coverage
File Line Cov Branch Cov Uncovered Churn (90d) Risk
29.2%
0.0% 17 1 71
78.6%
37.5% 6 2 43
60.0%
35.7% 10 1 40
71.4%
33.3% 8 1 29
Slowest Examples (top 20)
Example File Duration Status
OrderItem#subtotal_cents multiplies quantity by unit price spec/models/order_item_spec.rb:5 0.05s pass
InventorySyncJob#perform syncs products for active pharmacy spec/jobs/inventory_sync_job_spec.rb:13 0.03s pass
ShippingCalculator#calculate adds weight surcharge for large orders spec/services/shipping_calculator_spec.rb:26 0.03s pass
OrderItem callback recalculates order total on save spec/models/order_item_spec.rb:13 0.02s pass
Order#recalculate_total! sums order item subtotals spec/models/order_spec.rb:51 0.01s pass
InventorySyncJob#perform skips inactive pharmacies spec/jobs/inventory_sync_job_spec.rb:17 0.01s pass
CartOptimizer#optimize returns the cheapest pharmacy spec/services/cart_optimizer_spec.rb:6 0.01s pass
Order#confirm! sets status to confirmed spec/models/order_spec.rb:18 0.01s pass
CartOptimizer#optimize raises when no pharmacies available spec/services/cart_optimizer_spec.rb:16 0.01s pass
Product#reserve! decrements stock spec/models/product_spec.rb:69 0.0s pass
Order#ship! ships confirmed orders spec/models/order_spec.rb:26 0.0s pass
Product scopes .by_category filters by category spec/models/product_spec.rb:44 0.0s pass
Product scopes .in_stock returns products with stock > 0 spec/models/product_spec.rb:38 0.0s pass
Product scopes .active returns only active products spec/models/product_spec.rb:32 0.0s pass
Order validations validates status inclusion spec/models/order_spec.rb:11 0.0s pass
Order#deliver! delivers shipped orders spec/models/order_spec.rb:40 0.0s pass
Product validations requires unique minsan_code spec/models/product_spec.rb:19 0.0s pass
Pharmacy validations requires unique code spec/models/pharmacy_spec.rb:14 0.0s pass
ShippingCalculator#calculate returns standard shipping cost spec/services/shipping_calculator_spec.rb:7 0.0s pass
Order validations requires customer_email spec/models/order_spec.rb:6 0.0s pass
Factory Usage Ranking
Factory Creates Top-Level Cascade Ratio Time
:product 35 24 1.5x 0.1s
:order 15 14 1.1x 0.0s
:order_item 11 11 1.0x 0.1s
:pharmacy 6 6 1.0x 0.0s
🔥
High-Risk Files
high churn + low coverage
No high-risk files detected.
⏱️
Over-Tested Files
high coverage + very slow
No over-tested files detected.
🎭
False Security
>70% time in hooks
No false security issues detected.
⚠️
Untested Hot Paths
active development + low coverage
No untested hot paths detected.