master
1FactoryGirl.define do
2 factory :exercise do
3 name { FFaker::Internet.user_name }
4 factory :squat do
5 name 'Squat'
6 end
7 end
8 factory :exercise_set do
9 association :exercise
10 association :workout
11 target_repetitions { rand(12) }
12 target_weight { rand(400) }
13 factory :work_set, class: "WorkSet"
14 end
15 factory :program do
16 name { FFaker::Internet.user_name }
17 end
18 factory :workout do
19 association :user
20 association :routine
21 occurred_at { DateTime.now }
22 body_weight { rand(250) }
23 end
24 factory :user do
25 username { FFaker::Internet.user_name }
26 email { FFaker::Internet.email }
27 password "password"
28 password_confirmation "password"
29 terms_and_conditions "1"
30 end
31 factory :routine do
32 association :program
33 name { FFaker::Internet.user_name }
34 end
35 factory :email, class: OpenStruct do
36 to [{
37 full: "cf9b756e-789d-4bbb-aee7-2c8298bb69a7@stronglifters.com",
38 email: "cf9b756e-789d-4bbb-aee7-2c8298bb69a7@stronglifters.com",
39 token: "cf9b756e-789d-4bbb-aee7-2c8298bb69a7",
40 host: "stronglifters.com",
41 name: nil
42 }]
43 from({
44 token: "from_user",
45 host: "email.com",
46 email: "from_email@email.com",
47 full: "From User <from_user@email.com>",
48 name: "From User"
49 })
50 subject "email subject"
51 body "Hello!"
52 attachments { [] }
53
54 trait :with_attachment do
55 attachments {[
56 ActionDispatch::Http::UploadedFile.new({
57 filename: "spreadsheet-stronglifts.csv",
58 type: "text/plain",
59 tempfile: File.new(
60 "#{File.expand_path(File.dirname(__FILE__))}/fixtures/spreadsheet-stronglifts.csv"
61 )
62 })
63 ]}
64 end
65 end
66 factory :gym do
67 name { FFaker::Internet.user_name }
68 association :location
69 factory :calgary_gym do
70 location { create(:calgary) }
71 end
72 factory :edmonton_gym do
73 location { create(:edmonton) }
74 end
75 factory :portland_gym do
76 location { create(:portland) }
77 end
78 end
79
80 factory :user_session, class: UserSession do
81 association :user
82 ip FFaker::Internet.ip_v4_address
83 factory :active_session do
84 accessed_at Time.current
85 end
86 end
87
88 factory :location do
89 latitude { rand(90.0) }
90 longitude { rand(180.0) }
91 address { FFaker::Address.street_address }
92 city { FFaker::AddressCA.city }
93 region { FFaker::AddressCA.province }
94 postal_code { FFaker::AddressCA.postal_code }
95 country { FFaker::Address.country }
96 factory :calgary do
97 latitude { 51.0130333 }
98 longitude { -114.2142365 }
99 city { "Calgary" }
100 region { "AB" }
101 country { "CA" }
102 end
103 factory :edmonton do
104 latitude { 53.5557956 }
105 longitude { -113.6340292 }
106 city { "Edmonton" }
107 region { "AB" }
108 country { "CA" }
109 end
110 factory :portland do
111 latitude { 45.542415 }
112 longitude { -122.7244614 }
113 city { "Portland" }
114 region { "OR" }
115 country { "US" }
116 end
117 factory :no_where do
118 latitude { 0.0 }
119 longitude { 0.0 }
120 city { "" }
121 region { "" }
122 country { "" }
123 postal_code { "" }
124 end
125 end
126end