Module: UatActions::StaticRecords

Defined in:
app/uat_actions/uat_actions/static_records.rb

Overview

Provides simple consistent records where multiple records are not needed.

Constant Summary collapse

SWIPECARD_CODE =

Swipecard code of the test user. It gets hashed when persisted to the database, so we store it as a constant here to allow us to access it in the integration suite tools.

'__uat_test__'

Class Method Summary collapse

Class Method Details

.budget_divisionObject



68
69
70
# File 'app/uat_actions/uat_actions/static_records.rb', line 68

def self.budget_division
  BudgetDivision.find_or_create_by!(name: 'UAT TESTING')
end

.collection_siteObject



10
11
12
# File 'app/uat_actions/uat_actions/static_records.rb', line 10

def self.collection_site
  'Sanger'
end

.data_release_study_typeObject



52
53
54
# File 'app/uat_actions/uat_actions/static_records.rb', line 52

def self.data_release_study_type
  DataReleaseStudyType.default || DataReleaseStudyType.find_or_create_by(name: 'UAT')
end

.faculty_sponsorObject



85
86
87
# File 'app/uat_actions/uat_actions/static_records.rb', line 85

def self.faculty_sponsor
  FacultySponsor.find_or_create_by!(name: 'UAT Faculty Sponsor')
end

.order_roleObject



89
90
91
# File 'app/uat_actions/uat_actions/static_records.rb', line 89

def self.order_role
  OrderRole.find_or_create_by!(role: 'UAT Order Role')
end

.programObject



72
73
74
# File 'app/uat_actions/uat_actions/static_records.rb', line 72

def self.program
  Program.find_or_create_by!(name: 'UAT')
end

.projectObject



56
57
58
59
60
61
62
63
64
65
66
# File 'app/uat_actions/uat_actions/static_records.rb', line 56

def self.project
  Project.create_with(
    approved: true,
    state: 'active',
    project_metadata_attributes: {
      project_cost_code: 'FAKE1',
      project_funding_model: 'Internal',
      budget_division: budget_division
    }
  ).find_or_create_by!(name: 'UAT Project')
end

.studyObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'app/uat_actions/uat_actions/static_records.rb', line 31

def self.study
  Study.create_with(
    state: 'active',
    study_metadata_attributes: {
      data_access_group: 'dag',
      study_type: study_type,
      faculty_sponsor: faculty_sponsor,
      data_release_study_type: data_release_study_type,
      study_description: 'A study generated for UAT',
      contaminated_human_dna: 'No',
      contains_human_dna: 'No',
      commercially_available: 'No',
      program: program
    }
  ).find_or_create_by!(name: 'UAT Study')
end

.study_nameString

Returns the default study_name

Returns:

  • (String)

    the default study_name



17
18
19
# File 'app/uat_actions/uat_actions/static_records.rb', line 17

def self.study_name
  'UAT Study'
end

.study_typeObject



48
49
50
# File 'app/uat_actions/uat_actions/static_records.rb', line 48

def self.study_type
  StudyType.create_with(valid_type: true, valid_for_creation: true).find_or_create_by!(name: 'UAT')
end

.supplierObject



21
22
23
# File 'app/uat_actions/uat_actions/static_records.rb', line 21

def self.supplier
  Supplier.find_or_create_by!(name: 'UAT Supplier')
end

.tube_purposeObject



25
26
27
28
29
# File 'app/uat_actions/uat_actions/static_records.rb', line 25

def self.tube_purpose
  Purpose.create_with(target_type: 'SampleTube', type: 'Tube::Purpose', asset_shape_id: 1).find_or_create_by!(
    name: 'LCA Blood Vac'
  )
end

.userObject



76
77
78
79
80
81
82
83
# File 'app/uat_actions/uat_actions/static_records.rb', line 76

def self.user
  User.create_with(
    email: configatron.admin_email,
    first_name: 'Test',
    last_name: 'User',
    swipecard_code: SWIPECARD_CODE
  ).find_or_create_by(login: '__uat_test__')
end