-
Notifications
You must be signed in to change notification settings - Fork 82
/
workouts.rb
52 lines (49 loc) · 1.47 KB
/
workouts.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# == Schema Information
#
# Table name: workouts
#
# id :integer not null, primary key
# description :text(65535)
# is_public :boolean
# name :string(255) default(""), not null
# points_multiplier :integer
# scrambled :boolean default(FALSE)
# created_at :datetime
# updated_at :datetime
# creator_id :integer
# external_id :string(255)
#
# Indexes
#
# index_workouts_on_external_id (external_id) UNIQUE
# index_workouts_on_is_public (is_public)
# workouts_creator_id_fk (creator_id)
#
# Foreign Keys
#
# workouts_creator_id_fk (creator_id => users.id)
#
# Read about factories at https://github.com/thoughtbot/factory_bot
FactoryBot.define do
factory :workout do
name { 'Workout from Factory' }
scrambled { true }
description { 'Created by Factory Girl for testing.' }
language_list { 'Java' }
tag_list { 'factorial, function, multiplication' }
style_list { 'code writing' }
factory :workout_with_exercises do
after :create do |w|
FactoryBot.create :exercise_workout,
workout_id: w.id,
exercise: FactoryBot.create(:coding_exercise)
FactoryBot.create :exercise_workout,
workout_id: w.id,
exercise: FactoryBot.create(:mc_exercise)
FactoryBot.create :exercise_workout,
workout_id: w.id,
exercise: FactoryBot.create(:coding_exercise)
end
end
end
end