Class: UatActions::GenerateSupplier
- Inherits:
-
UatActions
- Object
- UatActions
- UatActions::GenerateSupplier
- 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
Class Method Summary collapse
-
.default ⇒ Object
The default supplier name is used if no supplier name is provided.
Instance Method Summary collapse
-
#create_supplier ⇒ Supplier
Creates the supplier with the provided name if it does not already exist.
-
#perform ⇒ Boolean
Creates the supplier and prints the supplier ID to the report.
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
.default ⇒ Object
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_supplier ⇒ Supplier
Creates the supplier with the provided name if it does not already exist.
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 |
#perform ⇒ Boolean
Creates the supplier and prints the supplier ID to the report.
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 |