semester_processes.rb 726 Bytes
Newer Older
1
FactoryBot.define do
Chrysanthi Lagodimou's avatar
Chrysanthi Lagodimou committed
2
  current_semester = Semester.new
3 4
  factory :semester_process do
    association :creator, factory: :user
5 6
    mail_subject_template 'mail subject template'
    mail_body_template 'mail body template'
Chrysanthi Lagodimou's avatar
Chrysanthi Lagodimou committed
7
    semester { current_semester.previous }
Kaspar Vollenweider's avatar
Kaspar Vollenweider committed
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22

    transient do
      build_volunteers { false }
    end

    trait :with_volunteers do
      transient do
        build_volunteers { true }
        volunteers_count { 1 }
      end
    end

    after(:create) do |sem_proc, evaluator|
      if evaluator.build_volunteers
        evaluator.volunteers_count.times do
23
          create :semester_process_volunteer, :with_mission, :with_feedbacks, semester_process: sem_proc
Kaspar Vollenweider's avatar
Kaspar Vollenweider committed
24 25 26
        end
      end
    end
27 28
  end
end