FactoryInitializer.test_assessment()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
c 1
b 0
f 1
dl 0
loc 3
rs 10
1
# frozen_string_literal: true
2
3
# Passes find_or_create associations to Factory bot
4
class FactoryInitializer
5
  def self.test_arm
6
    Arm.find_or_create_by!(name: TestConstants::TEST_ARM, schedule: test_schedule, number: 1)
7
  end
8
9
  def self.test_assessment
10
    Assessment.find_or_create_by! visit: test_visit
11
  end
12
  
13
  def self.test_instrument
14
    Instrument.find_by name: TestConstants::TEST_INSTRUMENT 
15
  end
16
17
  def self.test_journal
18
    Journal.find_or_create_by! name: TestConstants::TEST_JOURNAL
19
  end
20
21
  def self.test_participant
22
    Participant.find_or_create_by! email: TestConstants::TEST_PARTICIPANT_EMAIL
23
  end
24
25
  def self.test_response_scale
26
    ResponseScale.find_or_create_by! name: TestConstants::TEST_RESPONSE_SCALE
27
  end 
28
29
  def self.test_schedule
30
    Schedule.find_or_create_by!(name: TestConstants::TEST_SCHEDULE, study: test_study)
31
  end
32
33
  def self.test_study
34
    Study.find_or_create_by! name: TestConstants::TEST_STUDY
35
  end
36
  
37
  def self.test_study_event
38
    StudyEvent.find_or_create_by! name: TestConstants::TEST_STUDY_EVENT, arm: test_arm
39
  end
40
  
41
  def self.test_survey
42
    Survey.find_or_create_by! name: TestConstants::TEST_SURVEY 
43
  end    
44
    
45
  def self.test_user
46
    User.find_or_create_by! username: TestConstants::TEST_USER 
47
  end    
48
49
  def self.test_visit
50
    Visit.find_or_create_by!(name: TestConstants::TEST_VISIT, survey: test_survey, user: test_user)
51
  end
52
end
53