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



61
62
63
# File 'app/uat_actions/uat_actions/static_records.rb', line 61

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



45
46
47
# File 'app/uat_actions/uat_actions/static_records.rb', line 45

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

.faculty_sponsorObject



78
79
80
# File 'app/uat_actions/uat_actions/static_records.rb', line 78

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

.programObject



65
66
67
# File 'app/uat_actions/uat_actions/static_records.rb', line 65

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

.projectObject



49
50
51
52
53
54
55
56
57
58
59
# File 'app/uat_actions/uat_actions/static_records.rb', line 49

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



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/uat_actions/uat_actions/static_records.rb', line 24

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_typeObject



41
42
43
# File 'app/uat_actions/uat_actions/static_records.rb', line 41

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

.supplierObject



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

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

.tube_purposeObject



18
19
20
21
22
# File 'app/uat_actions/uat_actions/static_records.rb', line 18

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



69
70
71
72
73
74
75
76
# File 'app/uat_actions/uat_actions/static_records.rb', line 69

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