Class: UatActions::GenerateSupplier

Inherits:
UatActions show all
Defined in:
app/uat_actions/uat_actions/generate_supplier.rb

Overview

This UAT action creates a supplier with the provided name if it does not already exist. It can be used when custom suppliers are needed for testing.

Constant Summary

Constants inherited from UatActions

CATEGORY_LIST

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from UatActions

all, category, find, form_field, form_fields, grouped_and_sorted_uat_actions, id, inherited, permitted, #report, #save, to_partial_path, uat_actions

Class Method Details

.defaultObject

The default supplier name is used if no supplier name is provided.



14
15
16
# File 'app/uat_actions/uat_actions/generate_supplier.rb', line 14

def self.default
  new(supplier_name: UatActions::StaticRecords.supplier.name)
end

Instance Method Details

#create_supplierSupplier

Creates the supplier with the provided name if it does not already exist.

Returns:



28
29
30
# File 'app/uat_actions/uat_actions/generate_supplier.rb', line 28

def create_supplier
  Supplier.find_or_create_by!(name: supplier_name)
end

#performBoolean

Creates the supplier and prints the supplier ID to the report.

Returns:

  • (Boolean)

    true if the UAT action was successful



20
21
22
23
24
# File 'app/uat_actions/uat_actions/generate_supplier.rb', line 20

def perform
  supplier = create_supplier
  print_report(supplier)
  true
end