Class: SpreeCmCommissioner::LoadTest::GenerateVotingFixtureData

Inherits:
Object
  • Object
show all
Includes:
Spree::ServiceModule::Base
Defined in:
app/services/spree_cm_commissioner/load_test/generate_voting_fixture_data.rb

Overview

Generates a load-test fixture for one of the tenant voting-related k6 flows, scoped to a single voting session, so it can be copied into load_testing/config/fixture/tenant/. An organizer opens a voting session, picks a flow (voting_flow / aba_topup_vote_flow / cash_on_topup_vote_flow), and this resolves show_slug + voting_session_id straight off the models, plus (for the topup flows) the tenant's active payment method for that gateway.

Mirrors GenerateBookingTicketData's shape: success({ data:, issues: }). issues lists why the flow isn't ready to load-test (e.g. no ABA payment method configured yet); the same issues are duplicated into data so they travel with the copied JSON.

Constant Summary collapse

FLOWS =
%w[voting_flow aba_topup_vote_flow cash_on_topup_vote_flow].freeze
PAYWAY_CHECKOUT_PATH =

ABA's checkout endpoint is fixed regardless of tenant/environment — only host (sandbox vs production) differs, and that comes off the payment method. See Vpago::PaywayV2::Checkout#checkout_url in gems/spree_vpago.

'/api/payment-gateway/v1/payments/purchase'.freeze

Instance Method Summary collapse

Instance Method Details

#call(voting_session:, flow:) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'app/services/spree_cm_commissioner/load_test/generate_voting_fixture_data.rb', line 22

def call(voting_session:, flow:)
  unless FLOWS.include?(flow)
    raise ArgumentError, I18n.t('load_test.generate_voting_fixture_data.unknown_flow', flow: flow, flows: FLOWS.join(', '))
  end

  show = voting_session.show
  issues = []
  issues << I18n.t('load_test.generate_voting_fixture_data.no_show') if show.nil?

  data = { show_slug: show&.slug, voting_session_id: voting_session.id }

  if flow == 'voting_flow'
    issues.concat(voting_readiness_issues(voting_session))
  else
    issues.concat(topup_flow_issues(flow, voting_session, data))
  end

  data[:metadata] = { ready: issues.empty?, issues: issues }

  success(data: data, issues: issues)
rescue StandardError => e
  failure(nil, e.message)
end