Allinea il conteggio clienti della dashboard alle società, non ai deal vinti.
CI / scan_ruby (push) Failing after 14m57s
CI / scan_js (push) Successful in 11m7s
CI / lint (push) Failing after 12m34s

Neumarkt aveva due opportunità WON e gonfiava banner e card a 3, mentre la lista Solo clienti mostra 2 società.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-16 07:52:03 +02:00
co-authored by Cursor
parent 3f7794959e
commit 47c4308815
5 changed files with 34 additions and 5 deletions
+26 -1
View File
@@ -82,12 +82,37 @@ class DashboardMetricsTest < ActiveSupport::TestCase
assert_equal 0, metrics.demo_to_won_conversion
end
test "customers acquired counts unique organizations not duplicate won deals" do
org = Organization.create!(
name: "Cliente doppio #{SecureRandom.hex(3)}",
status: "prospect",
organization_type: "societa_sportiva"
)
2.times { |i| add_opp("won", organization: org, name: "Deal #{i}") }
add_opp("won")
assert_equal 3, metrics.stage_counts["won"]
assert_equal 2, metrics.customers_count
end
test "goal progress" do
goal = sales_goals(:september)
assert_equal 0, goal.current_value
assert_equal 0, goal.progress_percentage
end
test "customers_acquired goal counts distinct organizations in the period" do
org = Organization.create!(
name: "Cliente goal #{SecureRandom.hex(3)}",
status: "prospect",
organization_type: "societa_sportiva"
)
2.times { |i| add_opp("won", organization: org, name: "Goal deal #{i}") }
add_opp("won")
assert_equal 2, sales_goals(:september).current_value
end
private
def metrics
@@ -95,7 +120,7 @@ class DashboardMetricsTest < ActiveSupport::TestCase
end
def add_opp(stage, **attrs)
org = Organization.create!(
org = attrs.delete(:organization) || Organization.create!(
name: "Soc #{stage} #{SecureRandom.hex(3)}",
status: "prospect",
organization_type: "societa_sportiva"