Include autenticazione, progetti isolati, mail marketing HTML con SMTP, test A/B e editor WYSIWYG. Co-authored-by: Cursor <cursoragent@cursor.com>
36 lines
881 B
Ruby
36 lines
881 B
Ruby
require "test_helper"
|
|
|
|
class OpportunityTest < ActiveSupport::TestCase
|
|
setup do
|
|
@opp = opportunities(:deal)
|
|
@user = users(:marco)
|
|
Current.user = @user
|
|
Current.project = projects(:matchlivetv)
|
|
end
|
|
|
|
teardown do
|
|
Current.user = nil
|
|
Current.project = nil
|
|
end
|
|
|
|
test "move to won sets won_at and activates customer" do
|
|
@opp.move_to_stage!("won", user: @user)
|
|
assert @opp.won?
|
|
assert_not_nil @opp.won_at
|
|
assert_equal "active_customer", @opp.organization.reload.status
|
|
end
|
|
|
|
test "move to lost requires reason" do
|
|
assert_raises(ActiveRecord::RecordInvalid) do
|
|
@opp.move_to_stage!("lost", user: @user)
|
|
end
|
|
end
|
|
|
|
test "move to lost with reason" do
|
|
@opp.move_to_stage!("lost", lost_reason: "price", user: @user)
|
|
assert @opp.lost?
|
|
assert_equal "price", @opp.lost_reason
|
|
assert_not_nil @opp.lost_at
|
|
end
|
|
end
|