How to use each method of FactoryBot Package

Best Factory_bot_ruby code snippet using FactoryBot.each

service_spec.rb

Source:service_spec.rb Github

copy

Full Screen

...4 context 'with no Responses' do5 it 'does not update any CLUes' do6 expect { subject.process }.to not_change { Response.count }7 .and not_change { StudentClueCalculation.count }8 .and not_change { TeacherClueCalculation.count }9 .and not_change { AlgorithmStudentClueCalculation.count }10 .and not_change { AlgorithmTeacherClueCalculation.count }11 end12 end13 context 'with existing Ecosystems, Course, Students, Responses,14 Exercises, AssignedExercises and Assignments' do15 context 'with no Ecosystem updates' do16 before(:all) do17 DatabaseCleaner.start18 ecosystem = FactoryBot.create :ecosystem19 @course = FactoryBot.create :course, ecosystem_uuid: ecosystem.uuid20 @cc_1 = FactoryBot.create :course_container, course_uuid: @course.uuid,21 student_uuids: []22 @cc_2 = FactoryBot.create :course_container, course_uuid: @course.uuid,23 student_uuids: []24 @student_1 = FactoryBot.create :student, course_uuid: @course.uuid,25 course_container_uuids: [ @cc_1.uuid ]26 @student_2 = FactoryBot.create :student, course_uuid: @course.uuid,27 course_container_uuids: [ @cc_1.uuid ]28 @cc_1.update_attribute :student_uuids, [ @student_1.uuid, @student_2.uuid ]29 @exercise_1 = FactoryBot.create :exercise30 @exercise_2 = FactoryBot.create :exercise31 @exercise_3 = FactoryBot.create :exercise32 @exercise_4 = FactoryBot.create :exercise33 @exercise_5 = FactoryBot.create :exercise34 @exercise_6 = FactoryBot.create :exercise35 @exercise_7 = FactoryBot.create :exercise36 @exercise_8 = FactoryBot.create :exercise37 @exercise_9 = FactoryBot.create :exercise38 @exercise_10 = FactoryBot.create :exercise39 assignment_1 = FactoryBot.create :assignment, student_uuid: @student_1.uuid40 assignment_2 = FactoryBot.create :assignment, student_uuid: @student_1.uuid,41 feedback_at: Time.current42 assignment_3 = FactoryBot.create :assignment, student_uuid: @student_1.uuid43 assignment_4 = FactoryBot.create :assignment, student_uuid: @student_1.uuid,44 feedback_at: Time.current.tomorrow45 assignment_5 = FactoryBot.create :assignment, student_uuid: @student_1.uuid46 assignment_6 = FactoryBot.create :assignment, student_uuid: @student_2.uuid47 assignment_7 = FactoryBot.create :assignment, student_uuid: @student_2.uuid,48 feedback_at: Time.current49 assignment_8 = FactoryBot.create :assignment, student_uuid: @student_2.uuid50 assignment_9 = FactoryBot.create :assignment, student_uuid: @student_2.uuid,51 feedback_at: Time.current.tomorrow52 assignment_10 = FactoryBot.create :assignment, student_uuid: @student_2.uuid53 @response_1 = FactoryBot.create :response,54 is_correct: true,55 ecosystem_uuid: ecosystem.uuid,56 student_uuid: @student_1.uuid,57 exercise_uuid: @exercise_1.uuid,58 is_used_in_clue_calculations: true59 @response_2 = FactoryBot.create :response,60 is_correct: false,61 ecosystem_uuid: ecosystem.uuid,62 student_uuid: @student_1.uuid,63 exercise_uuid: @exercise_2.uuid,64 is_used_in_clue_calculations: true65 @response_3 = FactoryBot.create :response,66 is_correct: true,67 ecosystem_uuid: ecosystem.uuid,68 student_uuid: @student_1.uuid,69 exercise_uuid: @exercise_3.uuid,70 is_used_in_clue_calculations: true71 @response_4 = FactoryBot.create :response,72 is_correct: false,73 ecosystem_uuid: ecosystem.uuid,74 student_uuid: @student_1.uuid,75 exercise_uuid: @exercise_4.uuid,76 is_used_in_clue_calculations: true77 @response_5 = FactoryBot.create :response,78 is_correct: true,79 ecosystem_uuid: ecosystem.uuid,80 student_uuid: @student_1.uuid,81 exercise_uuid: @exercise_5.uuid,82 is_used_in_clue_calculations: false83 @response_6 = FactoryBot.create :response,84 is_correct: false,85 ecosystem_uuid: ecosystem.uuid,86 student_uuid: @student_1.uuid,87 exercise_uuid: @exercise_6.uuid,88 is_used_in_clue_calculations: false89 @response_7 = FactoryBot.create :response,90 is_correct: true,91 ecosystem_uuid: ecosystem.uuid,92 student_uuid: @student_1.uuid,93 exercise_uuid: @exercise_7.uuid,94 is_used_in_clue_calculations: false95 @response_8 = FactoryBot.create :response,96 is_correct: false,97 ecosystem_uuid: ecosystem.uuid,98 student_uuid: @student_1.uuid,99 exercise_uuid: @exercise_8.uuid,100 is_used_in_clue_calculations: false101 @response_9 = FactoryBot.create :response,102 is_correct: true,103 ecosystem_uuid: ecosystem.uuid,104 student_uuid: @student_2.uuid,105 exercise_uuid: @exercise_1.uuid,106 is_used_in_clue_calculations: true107 @response_10 = FactoryBot.create :response,108 is_correct: false,109 ecosystem_uuid: ecosystem.uuid,110 student_uuid: @student_2.uuid,111 exercise_uuid: @exercise_2.uuid,112 is_used_in_clue_calculations: true113 @response_11 = FactoryBot.create :response,114 is_correct: true,115 ecosystem_uuid: ecosystem.uuid,116 student_uuid: @student_2.uuid,117 exercise_uuid: @exercise_3.uuid,118 is_used_in_clue_calculations: true119 @response_12 = FactoryBot.create :response,120 is_correct: false,121 ecosystem_uuid: ecosystem.uuid,122 student_uuid: @student_2.uuid,123 exercise_uuid: @exercise_4.uuid,124 is_used_in_clue_calculations: true125 @response_13 = FactoryBot.create :response,126 is_correct: true,127 ecosystem_uuid: ecosystem.uuid,128 student_uuid: @student_2.uuid,129 exercise_uuid: @exercise_5.uuid,130 is_used_in_clue_calculations: false131 @response_14 = FactoryBot.create :response,132 is_correct: false,133 ecosystem_uuid: ecosystem.uuid,134 student_uuid: @student_2.uuid,135 exercise_uuid: @exercise_6.uuid,136 is_used_in_clue_calculations: false137 @response_15 = FactoryBot.create :response,138 is_correct: true,139 ecosystem_uuid: ecosystem.uuid,140 student_uuid: @student_2.uuid,141 exercise_uuid: @exercise_7.uuid,142 is_used_in_clue_calculations: false143 @response_16 = FactoryBot.create :response,144 is_correct: false,145 ecosystem_uuid: ecosystem.uuid,146 student_uuid: @student_2.uuid,147 exercise_uuid: @exercise_8.uuid,148 is_used_in_clue_calculations: false149 @unprocessed_responses = [150 @response_5, @response_6, @response_7, @response_8,151 @response_13, @response_14, @response_15, @response_16152 ]153 [ @response_1, @response_2 ].each do |response|154 FactoryBot.create :assigned_exercise, uuid: response.trial_uuid,155 assignment_uuid: assignment_1.uuid156 end157 [ @response_3, @response_4 ].each do |response|158 FactoryBot.create :assigned_exercise, uuid: response.trial_uuid,159 assignment_uuid: assignment_2.uuid160 end161 [ @response_5, @response_6 ].each do |response|162 FactoryBot.create :assigned_exercise, uuid: response.trial_uuid,163 assignment_uuid: assignment_3.uuid164 end165 [ @response_7, @response_8 ].each do |response|166 FactoryBot.create :assigned_exercise, uuid: response.trial_uuid,167 assignment_uuid: assignment_4.uuid168 end169 [ @response_9, @response_10 ].each do |response|170 FactoryBot.create :assigned_exercise, uuid: response.trial_uuid,171 assignment_uuid: assignment_6.uuid172 end173 [ @response_11, @response_12 ].each do |response|174 FactoryBot.create :assigned_exercise, uuid: response.trial_uuid,175 assignment_uuid: assignment_7.uuid176 end177 [ @response_13, @response_14 ].each do |response|178 FactoryBot.create :assigned_exercise, uuid: response.trial_uuid,179 assignment_uuid: assignment_8.uuid180 end181 [ @response_15, @response_16 ].each do |response|182 FactoryBot.create :assigned_exercise, uuid: response.trial_uuid,183 assignment_uuid: assignment_9.uuid184 end185 @ep_1 = FactoryBot.create :exercise_pool, ecosystem_uuid: ecosystem.uuid,186 use_for_clue: true,187 exercise_uuids: [ @exercise_1.uuid,188 @exercise_2.uuid ]189 @ep_2 = FactoryBot.create :exercise_pool, ecosystem_uuid: ecosystem.uuid,190 use_for_clue: true,191 exercise_uuids: [ @exercise_3.uuid,192 @exercise_4.uuid ]193 @ep_3 = FactoryBot.create :exercise_pool, ecosystem_uuid: ecosystem.uuid,194 use_for_clue: true,195 exercise_uuids: [ @exercise_5.uuid,196 @exercise_6.uuid ]197 @ep_4 = FactoryBot.create :exercise_pool, ecosystem_uuid: ecosystem.uuid,198 use_for_clue: true,199 exercise_uuids: [ @exercise_7.uuid,200 @exercise_8.uuid ]201 @ep_5 = FactoryBot.create :exercise_pool, ecosystem_uuid: ecosystem.uuid,202 use_for_clue: true,203 exercise_uuids: [ @exercise_9.uuid,204 @exercise_10.uuid ]205 # Not used for CLUes, so ignored206 FactoryBot.create :exercise_pool, ecosystem_uuid: ecosystem.uuid,207 book_container_uuid: @ep_1.book_container_uuid,208 use_for_clue: false,209 exercise_uuids: [210 @exercise_1.uuid, @exercise_2.uuid, @exercise_3.uuid, @exercise_4.uuid, @exercise_5.uuid,211 @exercise_6.uuid, @exercise_7.uuid, @exercise_8.uuid, @exercise_9.uuid, @exercise_10.uuid212 ]213 book_container_uuids_1 = [ SecureRandom.uuid, @ep_1.book_container_uuid ]214 book_container_uuids_2 = [ SecureRandom.uuid, @ep_2.book_container_uuid ]215 book_container_uuids_3 = [ SecureRandom.uuid, @ep_3.book_container_uuid ]216 book_container_uuids_4 = [ SecureRandom.uuid, @ep_4.book_container_uuid ]217 book_container_uuids_5 = [ SecureRandom.uuid, @ep_5.book_container_uuid ]218 FactoryBot.create :ecosystem_exercise, ecosystem_uuid: ecosystem.uuid,219 exercise: @exercise_1,220 book_container_uuids: book_container_uuids_1221 FactoryBot.create :ecosystem_exercise, ecosystem_uuid: ecosystem.uuid,222 exercise: @exercise_2,223 book_container_uuids: book_container_uuids_1224 FactoryBot.create :ecosystem_exercise, ecosystem_uuid: ecosystem.uuid,225 exercise: @exercise_3,226 book_container_uuids: book_container_uuids_2227 FactoryBot.create :ecosystem_exercise, ecosystem_uuid: ecosystem.uuid,228 exercise: @exercise_4,229 book_container_uuids: book_container_uuids_2230 FactoryBot.create :ecosystem_exercise, ecosystem_uuid: ecosystem.uuid,231 exercise: @exercise_5,232 book_container_uuids: book_container_uuids_3233 FactoryBot.create :ecosystem_exercise, ecosystem_uuid: ecosystem.uuid,234 exercise: @exercise_6,235 book_container_uuids: book_container_uuids_3236 FactoryBot.create :ecosystem_exercise, ecosystem_uuid: ecosystem.uuid,237 exercise: @exercise_7,238 book_container_uuids: book_container_uuids_4239 FactoryBot.create :ecosystem_exercise, ecosystem_uuid: ecosystem.uuid,240 exercise: @exercise_8,241 book_container_uuids: book_container_uuids_4242 FactoryBot.create :ecosystem_exercise, ecosystem_uuid: ecosystem.uuid,243 exercise: @exercise_9,244 book_container_uuids: book_container_uuids_5245 FactoryBot.create :ecosystem_exercise, ecosystem_uuid: ecosystem.uuid,246 exercise: @exercise_10,247 book_container_uuids: book_container_uuids_5248 # Will not be updated (no activity)249 @scc_1 = FactoryBot.create :student_clue_calculation,250 student_uuid: @student_1.uuid,251 book_container_uuid: @ep_1.book_container_uuid252 FactoryBot.create :algorithm_student_clue_calculation, student_clue_calculation: @scc_1253 # Will be updated (recalculate_at)254 @scc_2 = FactoryBot.create :student_clue_calculation,255 student_uuid: @student_1.uuid,256 book_container_uuid: @ep_2.book_container_uuid,257 recalculate_at: assignment_2.feedback_at258 FactoryBot.create :algorithm_student_clue_calculation, student_clue_calculation: @scc_2259 # Will be updated (new responses)260 @scc_3 = FactoryBot.create :student_clue_calculation,261 student_uuid: @student_1.uuid,262 book_container_uuid: @ep_3.book_container_uuid263 FactoryBot.create :algorithm_student_clue_calculation, student_clue_calculation: @scc_3264 # Will be updated (anti-cheating sets recalculate_at)265 @scc_4 = FactoryBot.create :student_clue_calculation,266 student_uuid: @student_1.uuid,267 book_container_uuid: @ep_4.book_container_uuid268 FactoryBot.create :algorithm_student_clue_calculation, student_clue_calculation: @scc_4269 # Will not be updated (no responses)270 @scc_5 = FactoryBot.create :student_clue_calculation,271 student_uuid: @student_1.uuid,272 book_container_uuid: @ep_5.book_container_uuid273 FactoryBot.create :algorithm_student_clue_calculation, student_clue_calculation: @scc_5274 # Will not be updated (no activity)275 @tcc_1 = FactoryBot.create :teacher_clue_calculation,276 book_container_uuid: @ep_1.book_container_uuid,277 course_container_uuid: @cc_1.uuid,278 student_uuids: [ @student_1.uuid, @student_2.uuid ]279 FactoryBot.create :algorithm_teacher_clue_calculation, teacher_clue_calculation: @tcc_1280 # Will be updated (recalculate_at)281 @tcc_2 = FactoryBot.create :teacher_clue_calculation,282 book_container_uuid: @ep_2.book_container_uuid,283 course_container_uuid: @cc_1.uuid,284 student_uuids: [ @student_1.uuid, @student_2.uuid ],285 recalculate_at: assignment_2.feedback_at286 FactoryBot.create :algorithm_teacher_clue_calculation, teacher_clue_calculation: @tcc_2287 # Will be updated (new responses)288 @tcc_3 = FactoryBot.create :teacher_clue_calculation,289 book_container_uuid: @ep_3.book_container_uuid,290 course_container_uuid: @cc_1.uuid,291 student_uuids: [ @student_1.uuid, @student_2.uuid ]292 FactoryBot.create :algorithm_teacher_clue_calculation, teacher_clue_calculation: @tcc_3293 end294 after(:all) { DatabaseCleaner.clean }295 it 'creates the StudentClueCalculation and TeacherClueCalculation records' +296 ' and marks the Responses as processed' do297 expect do298 subject.process299 end.to not_change { Response.count }300 .and change { StudentClueCalculation.count }.by(2)301 .and change { TeacherClueCalculation.count }.by(1)302 .and change { AlgorithmStudentClueCalculation.count }.by(-3)303 .and change { AlgorithmTeacherClueCalculation.count }.by(-2)304 .and not_change { @scc_1.reload.uuid }305 .and change { @scc_2.reload.uuid }306 .and change { @scc_3.reload.uuid }307 .and change { @scc_4.reload.uuid }308 .and not_change { @scc_5.reload.uuid }309 .and not_change { @tcc_1.reload.uuid }310 .and change { @tcc_2.reload.uuid }311 .and change { @tcc_3.reload.uuid }312 @unprocessed_responses.each do |response|313 expect(response.reload.is_used_in_clue_calculations).to eq true314 end315 expect(@scc_2.exercise_uuids).to match_array [ @exercise_3, @exercise_4 ].map(&:uuid)316 expect(@scc_2.responses.map { |response| response['response_uuid'] }).to(317 match_array [ @response_3, @response_4 ].map(&:uuid)318 )319 expect(@scc_2.recalculate_at).to be_nil320 expect(@scc_3.exercise_uuids).to match_array [ @exercise_5, @exercise_6 ].map(&:uuid)321 expect(@scc_3.responses.map { |response| response['response_uuid'] }).to(322 match_array [ @response_5, @response_6 ].map(&:uuid)323 )324 expect(@scc_3.recalculate_at).to be_nil325 expect(@scc_4.exercise_uuids).to match_array [ @exercise_7, @exercise_8 ].map(&:uuid)326 expect(@scc_4.responses).to be_empty327 expect(@scc_4.recalculate_at).not_to be_nil328 new_sccs = StudentClueCalculation.order(:created_at).last(2)329 new_sccs.each do |new_scc|330 expect(new_scc.student_uuid).to eq @student_2.uuid331 expect(new_scc.book_container_uuid).to(332 be_in [ @ep_3.book_container_uuid, @ep_4.book_container_uuid ]333 )334 if new_scc.book_container_uuid == @ep_3.book_container_uuid335 expect(new_scc.responses.map { |response| response['response_uuid'] }).to(336 match_array [ @response_13, @response_14 ].map(&:uuid)337 )338 else339 expect(new_scc.responses).to be_empty340 end341 end342 expect(@tcc_2.exercise_uuids).to match_array [ @exercise_3, @exercise_4 ].map(&:uuid)343 expect(@tcc_2.responses.map { |response| response['response_uuid'] }).to(344 match_array [ @response_3, @response_4, @response_11, @response_12 ].map(&:uuid)345 )346 expect(@tcc_2.recalculate_at).to be_nil347 expect(@tcc_3.exercise_uuids).to match_array [ @exercise_5, @exercise_6 ].map(&:uuid)348 expect(@tcc_3.responses.map { |response| response['response_uuid'] }).to(349 match_array [ @response_5, @response_6, @response_13, @response_14 ].map(&:uuid)350 )351 expect(@tcc_3.recalculate_at).to be_nil352 new_tcc = TeacherClueCalculation.order(:created_at).last353 expect(new_tcc.exercise_uuids).to match_array [ @exercise_7, @exercise_8 ].map(&:uuid)354 expect(new_tcc.responses.map { |response| response['response_uuid'] }).to(355 match_array [ @response_7, @response_8, @response_15, @response_16 ].map(&:uuid)356 )357 end358 end359 context 'after an Ecosystem update' do360 before(:all) do361 DatabaseCleaner.start362 ecosystem_1 = FactoryBot.create :ecosystem363 ecosystem_2 = FactoryBot.create :ecosystem364 @course = FactoryBot.create :course, ecosystem_uuid: ecosystem_2.uuid365 @cc_1 = FactoryBot.create :course_container, course_uuid: @course.uuid,366 student_uuids: []367 @cc_2 = FactoryBot.create :course_container, course_uuid: @course.uuid,368 student_uuids: []369 @student_1 = FactoryBot.create :student, course_uuid: @course.uuid,370 course_container_uuids: [ @cc_1.uuid ]371 @student_2 = FactoryBot.create :student, course_uuid: @course.uuid,372 course_container_uuids: [ @cc_1.uuid ]373 @cc_1.update_attribute :student_uuids, [ @student_1.uuid, @student_2.uuid ]374 @exercise_1 = FactoryBot.create :exercise375 @exercise_2 = FactoryBot.create :exercise376 @exercise_3 = FactoryBot.create :exercise377 @exercise_4 = FactoryBot.create :exercise378 @exercise_5 = FactoryBot.create :exercise379 @exercise_6 = FactoryBot.create :exercise380 @exercise_7 = FactoryBot.create :exercise381 @exercise_8 = FactoryBot.create :exercise382 @exercise_9 = FactoryBot.create :exercise383 @exercise_10 = FactoryBot.create :exercise384 @exercise_11 = FactoryBot.create :exercise385 @exercise_12 = FactoryBot.create :exercise386 @exercise_13 = FactoryBot.create :exercise387 @exercise_14 = FactoryBot.create :exercise388 @exercise_15 = FactoryBot.create :exercise389 assignment_1 = FactoryBot.create :assignment, student_uuid: @student_1.uuid390 assignment_2 = FactoryBot.create :assignment, student_uuid: @student_1.uuid,391 feedback_at: Time.current392 assignment_3 = FactoryBot.create :assignment, student_uuid: @student_1.uuid393 assignment_4 = FactoryBot.create :assignment, student_uuid: @student_1.uuid,394 feedback_at: Time.current.tomorrow395 assignment_5 = FactoryBot.create :assignment, student_uuid: @student_1.uuid396 assignment_6 = FactoryBot.create :assignment, student_uuid: @student_2.uuid397 assignment_7 = FactoryBot.create :assignment, student_uuid: @student_2.uuid,398 feedback_at: Time.current399 assignment_8 = FactoryBot.create :assignment, student_uuid: @student_2.uuid400 assignment_9 = FactoryBot.create :assignment, student_uuid: @student_2.uuid,401 feedback_at: Time.current.tomorrow402 assignment_10 = FactoryBot.create :assignment, student_uuid: @student_2.uuid403 @response_1 = FactoryBot.create :response,404 is_correct: true,405 ecosystem_uuid: ecosystem_1.uuid,406 student_uuid: @student_1.uuid,407 exercise_uuid: @exercise_1.uuid,408 is_used_in_clue_calculations: true409 @response_2 = FactoryBot.create :response,410 is_correct: false,411 ecosystem_uuid: ecosystem_2.uuid,412 student_uuid: @student_1.uuid,413 exercise_uuid: @exercise_12.uuid,414 is_used_in_clue_calculations: true415 @response_3 = FactoryBot.create :response,416 is_correct: true,417 ecosystem_uuid: ecosystem_1.uuid,418 student_uuid: @student_1.uuid,419 exercise_uuid: @exercise_3.uuid,420 is_used_in_clue_calculations: true421 @response_4 = FactoryBot.create :response,422 is_correct: false,423 ecosystem_uuid: ecosystem_2.uuid,424 student_uuid: @student_1.uuid,425 exercise_uuid: @exercise_14.uuid,426 is_used_in_clue_calculations: true427 @response_5 = FactoryBot.create :response,428 is_correct: true,429 ecosystem_uuid: ecosystem_1.uuid,430 student_uuid: @student_1.uuid,431 exercise_uuid: @exercise_5.uuid,432 is_used_in_clue_calculations: false433 @response_6 = FactoryBot.create :response,434 is_correct: false,435 ecosystem_uuid: ecosystem_2.uuid,436 student_uuid: @student_1.uuid,437 exercise_uuid: @exercise_6.uuid,438 is_used_in_clue_calculations: false439 @response_7 = FactoryBot.create :response,440 is_correct: true,441 ecosystem_uuid: ecosystem_1.uuid,442 student_uuid: @student_1.uuid,443 exercise_uuid: @exercise_7.uuid,444 is_used_in_clue_calculations: false445 @response_8 = FactoryBot.create :response,446 is_correct: false,447 ecosystem_uuid: ecosystem_2.uuid,448 student_uuid: @student_1.uuid,449 exercise_uuid: @exercise_8.uuid,450 is_used_in_clue_calculations: false451 @response_9 = FactoryBot.create :response,452 is_correct: true,453 ecosystem_uuid: ecosystem_1.uuid,454 student_uuid: @student_2.uuid,455 exercise_uuid: @exercise_1.uuid,456 is_used_in_clue_calculations: true457 @response_10 = FactoryBot.create :response,458 is_correct: false,459 ecosystem_uuid: ecosystem_2.uuid,460 student_uuid: @student_2.uuid,461 exercise_uuid: @exercise_12.uuid,462 is_used_in_clue_calculations: true463 @response_11 = FactoryBot.create :response,464 is_correct: true,465 ecosystem_uuid: ecosystem_1.uuid,466 student_uuid: @student_2.uuid,467 exercise_uuid: @exercise_3.uuid,468 is_used_in_clue_calculations: true469 @response_12 = FactoryBot.create :response,470 is_correct: false,471 ecosystem_uuid: ecosystem_2.uuid,472 student_uuid: @student_2.uuid,473 exercise_uuid: @exercise_14.uuid,474 is_used_in_clue_calculations: true475 @response_13 = FactoryBot.create :response,476 is_correct: true,477 ecosystem_uuid: ecosystem_1.uuid,478 student_uuid: @student_2.uuid,479 exercise_uuid: @exercise_5.uuid,480 is_used_in_clue_calculations: false481 @response_14 = FactoryBot.create :response,482 is_correct: false,483 ecosystem_uuid: ecosystem_2.uuid,484 student_uuid: @student_2.uuid,485 exercise_uuid: @exercise_6.uuid,486 is_used_in_clue_calculations: false487 @response_15 = FactoryBot.create :response,488 is_correct: true,489 ecosystem_uuid: ecosystem_1.uuid,490 student_uuid: @student_2.uuid,491 exercise_uuid: @exercise_7.uuid,492 is_used_in_clue_calculations: false493 @response_16 = FactoryBot.create :response,494 is_correct: false,495 ecosystem_uuid: ecosystem_2.uuid,496 student_uuid: @student_2.uuid,497 exercise_uuid: @exercise_8.uuid,498 is_used_in_clue_calculations: false499 @unprocessed_responses = [500 @response_5, @response_6, @response_7, @response_8,501 @response_13, @response_14, @response_15, @response_16502 ]503 [ @response_1, @response_2 ].each do |response|504 FactoryBot.create :assigned_exercise, uuid: response.trial_uuid,505 assignment_uuid: assignment_1.uuid506 end507 [ @response_3, @response_4 ].each do |response|508 FactoryBot.create :assigned_exercise, uuid: response.trial_uuid,509 assignment_uuid: assignment_2.uuid510 end511 [ @response_5, @response_6 ].each do |response|512 FactoryBot.create :assigned_exercise, uuid: response.trial_uuid,513 assignment_uuid: assignment_3.uuid514 end515 [ @response_7, @response_8 ].each do |response|516 FactoryBot.create :assigned_exercise, uuid: response.trial_uuid,517 assignment_uuid: assignment_4.uuid518 end519 [ @response_9, @response_10 ].each do |response|520 FactoryBot.create :assigned_exercise, uuid: response.trial_uuid,521 assignment_uuid: assignment_6.uuid522 end523 [ @response_11, @response_12 ].each do |response|524 FactoryBot.create :assigned_exercise, uuid: response.trial_uuid,525 assignment_uuid: assignment_7.uuid526 end527 [ @response_13, @response_14 ].each do |response|528 FactoryBot.create :assigned_exercise, uuid: response.trial_uuid,529 assignment_uuid: assignment_8.uuid530 end531 [ @response_15, @response_16 ].each do |response|532 FactoryBot.create :assigned_exercise, uuid: response.trial_uuid,533 assignment_uuid: assignment_9.uuid534 end535 # Old ecosystem536 old_ep_1 = FactoryBot.create :exercise_pool, ecosystem_uuid: ecosystem_1.uuid,537 use_for_clue: true,538 exercise_uuids: [ @exercise_1.uuid,539 @exercise_2.uuid ]540 old_ep_2 = FactoryBot.create :exercise_pool, ecosystem_uuid: ecosystem_1.uuid,541 use_for_clue: true,542 exercise_uuids: [ @exercise_3.uuid,543 @exercise_4.uuid ]544 old_ep_3 = FactoryBot.create :exercise_pool, ecosystem_uuid: ecosystem_1.uuid,545 use_for_clue: true,546 exercise_uuids: [ @exercise_5.uuid,547 @exercise_6.uuid ]548 old_ep_4 = FactoryBot.create :exercise_pool, ecosystem_uuid: ecosystem_1.uuid,549 use_for_clue: true,550 exercise_uuids: [ @exercise_7.uuid,551 @exercise_8.uuid ]552 old_ep_5 = FactoryBot.create :exercise_pool, ecosystem_uuid: ecosystem_1.uuid,553 use_for_clue: true,554 exercise_uuids: [ @exercise_9.uuid,555 @exercise_10.uuid ]556 # New ecosystem557 @ep_1 = FactoryBot.create :exercise_pool, ecosystem_uuid: ecosystem_2.uuid,558 use_for_clue: true,559 exercise_uuids: [ @exercise_11.uuid,560 @exercise_12.uuid ]561 @ep_2 = FactoryBot.create :exercise_pool, ecosystem_uuid: ecosystem_2.uuid,562 use_for_clue: true,563 exercise_uuids: [ @exercise_13.uuid,564 @exercise_14.uuid ]565 @ep_3 = FactoryBot.create :exercise_pool, ecosystem_uuid: ecosystem_2.uuid,566 use_for_clue: true,567 exercise_uuids: [ @exercise_15.uuid,568 @exercise_6.uuid ]569 @ep_4 = FactoryBot.create :exercise_pool, ecosystem_uuid: ecosystem_2.uuid,570 use_for_clue: true,571 exercise_uuids: [ @exercise_7.uuid,572 @exercise_8.uuid ]573 @ep_5 = FactoryBot.create :exercise_pool, ecosystem_uuid: ecosystem_2.uuid,574 use_for_clue: true,575 exercise_uuids: [ @exercise_9.uuid,576 @exercise_10.uuid ]577 # Not used for CLUes, so ignored578 unused_ep_1 = FactoryBot.create :exercise_pool,579 ecosystem_uuid: ecosystem_1.uuid,580 use_for_clue: false,581 exercise_uuids: [582 @exercise_1.uuid, @exercise_2.uuid, @exercise_3.uuid, @exercise_4.uuid, @exercise_5.uuid,583 @exercise_6.uuid, @exercise_7.uuid, @exercise_8.uuid, @exercise_9.uuid, @exercise_10.uuid584 ]585 unused_ep_2 = FactoryBot.create :exercise_pool,586 ecosystem_uuid: ecosystem_2.uuid,587 use_for_clue: false,588 exercise_uuids: [589 @exercise_11.uuid, @exercise_12.uuid, @exercise_13.uuid, @exercise_14.uuid,590 @exercise_15.uuid, @exercise_6.uuid, @exercise_7.uuid,591 @exercise_8.uuid, @exercise_9.uuid, @exercise_10.uuid592 ]593 # Mappings594 FactoryBot.create :book_container_mapping,595 from_ecosystem_uuid: ecosystem_1.uuid,596 to_ecosystem_uuid: ecosystem_2.uuid,597 from_book_container_uuid: old_ep_1.book_container_uuid,598 to_book_container_uuid: @ep_1.book_container_uuid599 FactoryBot.create :book_container_mapping,600 from_ecosystem_uuid: ecosystem_1.uuid,601 to_ecosystem_uuid: ecosystem_2.uuid,602 from_book_container_uuid: old_ep_2.book_container_uuid,603 to_book_container_uuid: @ep_2.book_container_uuid604 FactoryBot.create :book_container_mapping,605 from_ecosystem_uuid: ecosystem_1.uuid,606 to_ecosystem_uuid: ecosystem_2.uuid,607 from_book_container_uuid: old_ep_3.book_container_uuid,608 to_book_container_uuid: @ep_3.book_container_uuid609 FactoryBot.create :book_container_mapping,610 from_ecosystem_uuid: ecosystem_1.uuid,611 to_ecosystem_uuid: ecosystem_2.uuid,612 from_book_container_uuid: old_ep_4.book_container_uuid,613 to_book_container_uuid: @ep_4.book_container_uuid614 FactoryBot.create :book_container_mapping,615 from_ecosystem_uuid: ecosystem_1.uuid,616 to_ecosystem_uuid: ecosystem_2.uuid,617 from_book_container_uuid: old_ep_5.book_container_uuid,618 to_book_container_uuid: @ep_5.book_container_uuid619 FactoryBot.create :book_container_mapping,620 from_ecosystem_uuid: ecosystem_1.uuid,621 to_ecosystem_uuid: ecosystem_2.uuid,622 from_book_container_uuid: unused_ep_1.book_container_uuid,623 to_book_container_uuid: unused_ep_2.book_container_uuid624 # Reverse mappings625 FactoryBot.create :book_container_mapping,626 from_ecosystem_uuid: ecosystem_2.uuid,627 to_ecosystem_uuid: ecosystem_1.uuid,628 from_book_container_uuid: @ep_1.book_container_uuid,629 to_book_container_uuid: old_ep_1.book_container_uuid630 FactoryBot.create :book_container_mapping,631 from_ecosystem_uuid: ecosystem_2.uuid,632 to_ecosystem_uuid: ecosystem_1.uuid,633 from_book_container_uuid: @ep_2.book_container_uuid,634 to_book_container_uuid: old_ep_2.book_container_uuid635 FactoryBot.create :book_container_mapping,636 from_ecosystem_uuid: ecosystem_2.uuid,637 to_ecosystem_uuid: ecosystem_1.uuid,638 from_book_container_uuid: @ep_3.book_container_uuid,639 to_book_container_uuid: old_ep_3.book_container_uuid640 FactoryBot.create :book_container_mapping,641 from_ecosystem_uuid: ecosystem_2.uuid,642 to_ecosystem_uuid: ecosystem_1.uuid,643 from_book_container_uuid: @ep_4.book_container_uuid,644 to_book_container_uuid: old_ep_4.book_container_uuid645 FactoryBot.create :book_container_mapping,646 from_ecosystem_uuid: ecosystem_2.uuid,647 to_ecosystem_uuid: ecosystem_1.uuid,648 from_book_container_uuid: @ep_5.book_container_uuid,649 to_book_container_uuid: old_ep_5.book_container_uuid650 FactoryBot.create :book_container_mapping,651 from_ecosystem_uuid: ecosystem_2.uuid,652 to_ecosystem_uuid: ecosystem_1.uuid,653 from_book_container_uuid: unused_ep_2.book_container_uuid,654 to_book_container_uuid: unused_ep_1.book_container_uuid655 old_book_container_uuids_1 = [ SecureRandom.uuid, old_ep_1.book_container_uuid ]656 old_book_container_uuids_2 = [ SecureRandom.uuid, old_ep_2.book_container_uuid ]657 old_book_container_uuids_3 = [ SecureRandom.uuid, old_ep_3.book_container_uuid ]658 old_book_container_uuids_4 = [ SecureRandom.uuid, old_ep_4.book_container_uuid ]659 old_book_container_uuids_5 = [ SecureRandom.uuid, old_ep_5.book_container_uuid ]660 book_container_uuids_1 = [ SecureRandom.uuid, @ep_1.book_container_uuid ]661 book_container_uuids_2 = [ SecureRandom.uuid, @ep_2.book_container_uuid ]662 book_container_uuids_3 = [ SecureRandom.uuid, @ep_3.book_container_uuid ]663 book_container_uuids_4 = [ SecureRandom.uuid, @ep_4.book_container_uuid ]664 book_container_uuids_5 = [ SecureRandom.uuid, @ep_5.book_container_uuid ]665 FactoryBot.create :ecosystem_exercise, ecosystem_uuid: ecosystem_1.uuid,666 exercise: @exercise_1,667 book_container_uuids: old_book_container_uuids_1668 FactoryBot.create :ecosystem_exercise, ecosystem_uuid: ecosystem_1.uuid,669 exercise: @exercise_2,670 book_container_uuids: old_book_container_uuids_1671 FactoryBot.create :ecosystem_exercise, ecosystem_uuid: ecosystem_1.uuid,672 exercise: @exercise_3,673 book_container_uuids: old_book_container_uuids_2674 FactoryBot.create :ecosystem_exercise, ecosystem_uuid: ecosystem_1.uuid,675 exercise: @exercise_4,676 book_container_uuids: old_book_container_uuids_2677 FactoryBot.create :ecosystem_exercise, ecosystem_uuid: ecosystem_1.uuid,678 exercise: @exercise_5,679 book_container_uuids: old_book_container_uuids_3680 FactoryBot.create :ecosystem_exercise, ecosystem_uuid: ecosystem_1.uuid,681 exercise: @exercise_6,682 book_container_uuids: old_book_container_uuids_3683 FactoryBot.create :ecosystem_exercise, ecosystem_uuid: ecosystem_1.uuid,684 exercise: @exercise_7,685 book_container_uuids: old_book_container_uuids_4686 FactoryBot.create :ecosystem_exercise, ecosystem_uuid: ecosystem_1.uuid,687 exercise: @exercise_8,688 book_container_uuids: old_book_container_uuids_4689 FactoryBot.create :ecosystem_exercise, ecosystem_uuid: ecosystem_1.uuid,690 exercise: @exercise_9,691 book_container_uuids: old_book_container_uuids_5692 FactoryBot.create :ecosystem_exercise, ecosystem_uuid: ecosystem_1.uuid,693 exercise: @exercise_10,694 book_container_uuids: old_book_container_uuids_5695 FactoryBot.create :ecosystem_exercise, ecosystem_uuid: ecosystem_2.uuid,696 exercise: @exercise_11,697 book_container_uuids: book_container_uuids_1698 FactoryBot.create :ecosystem_exercise, ecosystem_uuid: ecosystem_2.uuid,699 exercise: @exercise_12,700 book_container_uuids: book_container_uuids_1701 FactoryBot.create :ecosystem_exercise, ecosystem_uuid: ecosystem_2.uuid,702 exercise: @exercise_13,703 book_container_uuids: book_container_uuids_2704 FactoryBot.create :ecosystem_exercise, ecosystem_uuid: ecosystem_2.uuid,705 exercise: @exercise_14,706 book_container_uuids: book_container_uuids_2707 FactoryBot.create :ecosystem_exercise, ecosystem_uuid: ecosystem_2.uuid,708 exercise: @exercise_15,709 book_container_uuids: book_container_uuids_3710 FactoryBot.create :ecosystem_exercise, ecosystem_uuid: ecosystem_2.uuid,711 exercise: @exercise_6,712 book_container_uuids: book_container_uuids_3713 FactoryBot.create :ecosystem_exercise, ecosystem_uuid: ecosystem_2.uuid,714 exercise: @exercise_7,715 book_container_uuids: book_container_uuids_4716 FactoryBot.create :ecosystem_exercise, ecosystem_uuid: ecosystem_2.uuid,717 exercise: @exercise_8,718 book_container_uuids: book_container_uuids_4719 FactoryBot.create :ecosystem_exercise, ecosystem_uuid: ecosystem_2.uuid,720 exercise: @exercise_9,721 book_container_uuids: book_container_uuids_5722 FactoryBot.create :ecosystem_exercise, ecosystem_uuid: ecosystem_2.uuid,723 exercise: @exercise_10,724 book_container_uuids: book_container_uuids_5725 # Will not be updated (no activity)726 @scc_1 = FactoryBot.create :student_clue_calculation,727 student_uuid: @student_1.uuid,728 book_container_uuid: @ep_1.book_container_uuid729 FactoryBot.create :algorithm_student_clue_calculation, student_clue_calculation: @scc_1730 # Will be updated (recalculate_at)731 @scc_2 = FactoryBot.create :student_clue_calculation,732 student_uuid: @student_1.uuid,733 book_container_uuid: @ep_2.book_container_uuid,734 recalculate_at: assignment_2.feedback_at735 FactoryBot.create :algorithm_student_clue_calculation, student_clue_calculation: @scc_2736 # Will be updated (new responses)737 @scc_3 = FactoryBot.create :student_clue_calculation,738 student_uuid: @student_1.uuid,739 book_container_uuid: @ep_3.book_container_uuid740 FactoryBot.create :algorithm_student_clue_calculation, student_clue_calculation: @scc_3741 # Will be updated (anti-cheating sets recalculate_at)742 @scc_4 = FactoryBot.create :student_clue_calculation,743 student_uuid: @student_1.uuid,744 book_container_uuid: @ep_4.book_container_uuid745 FactoryBot.create :algorithm_student_clue_calculation, student_clue_calculation: @scc_4746 # Will not be updated (no responses)747 @scc_5 = FactoryBot.create :student_clue_calculation,748 student_uuid: @student_1.uuid,749 book_container_uuid: @ep_5.book_container_uuid750 FactoryBot.create :algorithm_student_clue_calculation, student_clue_calculation: @scc_5751 # Will not be updated (no activity)752 @tcc_1 = FactoryBot.create :teacher_clue_calculation,753 book_container_uuid: @ep_1.book_container_uuid,754 course_container_uuid: @cc_1.uuid,755 student_uuids: [ @student_1.uuid, @student_2.uuid ]756 FactoryBot.create :algorithm_teacher_clue_calculation, teacher_clue_calculation: @tcc_1757 # Will be updated (new responses)758 @tcc_2 = FactoryBot.create :teacher_clue_calculation,759 book_container_uuid: @ep_3.book_container_uuid,760 course_container_uuid: @cc_1.uuid,761 student_uuids: [ @student_1.uuid, @student_2.uuid ]762 FactoryBot.create :algorithm_teacher_clue_calculation, teacher_clue_calculation: @tcc_2763 end764 after(:all) { DatabaseCleaner.clean }765 it 'creates the StudentClueCalculation and TeacherClueCalculation records' +766 ' and marks the Responses as processed' do767 expect do768 subject.process769 end.to not_change { Response.count }770 .and change { StudentClueCalculation.count }.by(2)771 .and change { TeacherClueCalculation.count }.by(1)772 .and change { AlgorithmStudentClueCalculation.count }.by(-3)773 .and change { AlgorithmTeacherClueCalculation.count }.by(-1)774 .and not_change { @scc_1.reload.uuid }775 .and change { @scc_2.reload.uuid }776 .and change { @scc_3.reload.uuid }777 .and change { @scc_4.reload.uuid }778 .and not_change { @scc_5.reload.uuid }779 .and not_change { @tcc_1.reload.uuid }780 .and change { @tcc_2.reload.uuid }781 @unprocessed_responses.each do |response|782 expect(response.reload.is_used_in_clue_calculations).to eq true783 end784 expect(@scc_2.exercise_uuids).to(785 match_array [ @exercise_3, @exercise_4, @exercise_13, @exercise_14 ].map(&:uuid)786 )787 expect(@scc_2.responses.map { |response| response['response_uuid'] }).to(788 match_array [ @response_3, @response_4 ].map(&:uuid)789 )790 expect(@scc_2.recalculate_at).to be_nil791 expect(@scc_3.exercise_uuids).to(792 match_array [ @exercise_5, @exercise_6, @exercise_15 ].map(&:uuid)793 )794 expect(@scc_3.responses.map { |response| response['response_uuid'] }).to(795 match_array [ @response_5, @response_6 ].map(&:uuid)796 )797 expect(@scc_3.recalculate_at).to be_nil798 expect(@scc_4.exercise_uuids).to match_array [ @exercise_7, @exercise_8 ].map(&:uuid)799 expect(@scc_4.responses).to be_empty800 expect(@scc_4.recalculate_at).not_to be_nil801 new_sccs = StudentClueCalculation.order(:created_at).last(2)802 new_sccs.each do |new_scc|803 expect(new_scc.student_uuid).to eq @student_2.uuid804 expect(new_scc.book_container_uuid).to(805 be_in [ @ep_3.book_container_uuid, @ep_4.book_container_uuid ]806 )807 if new_scc.book_container_uuid == @ep_3.book_container_uuid808 expect(new_scc.responses.map { |response| response['response_uuid'] }).to(809 match_array [ @response_13, @response_14 ].map(&:uuid)810 )811 else812 expect(new_scc.responses).to be_empty813 end814 end815 expect(@tcc_2.exercise_uuids).to(816 match_array [ @exercise_5, @exercise_6, @exercise_15 ].map(&:uuid)817 )818 expect(@tcc_2.responses.map { |response| response['response_uuid'] }).to(819 match_array [ @response_5, @response_6, @response_13, @response_14 ].map(&:uuid)820 )821 new_tcc = TeacherClueCalculation.order(:created_at).last822 expect(new_tcc.exercise_uuids).to match_array [ @exercise_7, @exercise_8 ].map(&:uuid)823 expect(new_tcc.responses.map { |response| response['response_uuid'] }).to(824 match_array [ @response_7, @response_8, @response_15, @response_16 ].map(&:uuid)825 )826 end827 end828 end829end...

Full Screen

Full Screen

seeds.rb

Source:seeds.rb Github

copy

Full Screen

...8RubricTemplate.destroy_all9RubricCategory.destroy_all10User.destroy_all11#reset pk sequences back to 112ActiveRecord::Base.connection.tables.each do |t|13 ActiveRecord::Base.connection.reset_pk_sequence!(t)14end15#students16students = FactoryBot.create_list(:user, 105, role: 0)17#BE student user profiles18profiles_mod1_be = Array(94..105).each do |n|19 FactoryBot.create(:user_profile, user_id: n, current_mod: "1", starting_cohort: "2105", current_cohort: "2105", status: 0, program: "BE")20end21profiles_mod2_be = Array(68..82).each do |n|22 FactoryBot.create(:user_profile, user_id: n, current_mod: "2", starting_cohort: "2103", current_cohort: "2103", status: 0, program: "BE")23end24profiles_mod3_be = Array(41..53).each do |n|25 FactoryBot.create(:user_profile, user_id: n, current_mod: "3", starting_cohort: "2102", current_cohort: "2102", status: 0, program: "BE")26end27profiles_mod4_be = Array(14..28).each do |n|28 FactoryBot.create(:user_profile, user_id: n, current_mod: "4", starting_cohort: "2011", current_cohort: "2011", status: 0, program: "BE")29end30#FE student user profiles31profiles_mod1_fe = Array(83..93).each do |n|32 FactoryBot.create(:user_profile, user_id: n, current_mod: "1", starting_cohort: "2105", current_cohort: "2105", status: 0, program: "FE")33end34profiles_mod2_fe = Array(54..67).each do |n|35 FactoryBot.create(:user_profile, user_id: n, current_mod: "2", starting_cohort: "2103", current_cohort: "2103", status: 0, program: "FE")36end37profiles_mod3_fe = Array(29..40).each do |n|38 FactoryBot.create(:user_profile, user_id: n, current_mod: "3", starting_cohort: "2102", current_cohort: "2102", status: 0, program: "FE")39end40profiles_mod4_fe = Array(1..13).each do |n|41 FactoryBot.create(:user_profile, user_id: n, current_mod: "4", starting_cohort: "2011", current_cohort: "2011", status: 0, program: "FE")42end43#instructors44instructors = FactoryBot.create_list(:user, 20, role: 1)45#BE instructor user profiles46profiles_mod1_be_instr = Array(122..124).each do |n|47 FactoryBot.create(:user_profile, user_id: n, current_mod: "1", program: "BE")48end49profiles_mod2_be_instr = Array(116..118).each do |n|50 FactoryBot.create(:user_profile, user_id: n, current_mod: "2", program: "BE")51end52profiles_mod3_be_instr = Array(112..113).each do |n|53 FactoryBot.create(:user_profile, user_id: n, current_mod: "3", program: "BE")54end55profiles_mod4_instr = Array(106..109).each do |n|56 FactoryBot.create(:user_profile, user_id: n, current_mod: "4", program: "Combined")57end58#FE instructor user profiles59profiles_mod1_fe_instr = Array(119..121).each do |n|60 FactoryBot.create(:user_profile, user_id: n, current_mod: "1", program: "FE")61end62profiles_mod2_fe_instr = Array(114..115).each do |n|63 FactoryBot.create(:user_profile, user_id: n, current_mod: "2", program: "FE")64end65profiles_mod3_fe_instr = Array(110..111).each do |n|66 FactoryBot.create(:user_profile, user_id: n, current_mod: "3", program: "FE")67end68profiles_mod1_be_instr.each do |instructor|69 profiles_mod1_be.each do |student|70 FactoryBot.create(:instructor_student, instructor_id: instructor, student_id: student)71 end72end73profiles_mod2_be_instr.each do |instructor|74 profiles_mod2_be.each do |student|75 FactoryBot.create(:instructor_student, instructor_id: instructor, student_id: student)76 end77end78profiles_mod3_be_instr.each do |instructor|79 profiles_mod3_be.each do |student|80 FactoryBot.create(:instructor_student, instructor_id: instructor, student_id: student)81 end82end83profiles_mod4_instr.each do |instructor|84 profiles_mod4_be.each do |student|85 FactoryBot.create(:instructor_student, instructor_id: instructor, student_id: student)86 end87end88profiles_mod1_fe_instr.each do |instructor|89 profiles_mod1_fe.each do |student|90 FactoryBot.create(:instructor_student, instructor_id: instructor, student_id: student)91 end92end93profiles_mod2_fe_instr.each do |instructor|94 profiles_mod2_fe.each do |student|95 FactoryBot.create(:instructor_student, instructor_id: instructor, student_id: student)96 end97end98profiles_mod3_fe_instr.each do |instructor|99 profiles_mod3_fe.each do |student|100 FactoryBot.create(:instructor_student, instructor_id: instructor, student_id: student)101 end102end103profiles_mod4_instr.each do |instructor|104 profiles_mod4_fe.each do |student|105 FactoryBot.create(:instructor_student, instructor_id: instructor, student_id: student)106 end107end108test = FactoryBot.create(:rubric_category, name: "Testing/​Test Driven Development")109c_and_m = FactoryBot.create(:rubric_category, name: "Conventions & Mechanics")110vcs = FactoryBot.create(:rubric_category, name: "Version Control")111completion = FactoryBot.create(:rubric_category, name: "Functionality/​Completion")112oop = FactoryBot.create(:rubric_category, name: "Object Oriented Principles")113js = FactoryBot.create(:rubric_category, name: "JavaScript")114design = FactoryBot.create(:rubric_category, name: "CSS /​ Design")115ar = FactoryBot.create(:rubric_category, name: "Active Record")116schema = FactoryBot.create(:rubric_category, name: "Database Design")117p_and_p = FactoryBot.create(:rubric_category, name: "Professionalism/​Presentation")118ui = FactoryBot.create(:rubric_category, name: "UI/​UX")119pm = FactoryBot.create(:rubric_category, name: "Project Management")120stretch = FactoryBot.create(:rubric_category, name: "Stretch Tech/​Goal")121rails = FactoryBot.create(:rubric_category, name: "Rails")122ci_deploy = FactoryBot.create(:rubric_category, name: "Continuous Integration & Deployment")123api = FactoryBot.create(:rubric_category, name: "API Consumption")124docs = FactoryBot.create(:rubric_category, name: "Documentation")125react = FactoryBot.create(:rubric_category, name: "React")126routing = FactoryBot.create(:rubric_category, name: "Routing")127code = FactoryBot.create(:rubric_category, name: "Code Quality")128agile = FactoryBot.create(:rubric_category, name: "Agile Process")129#BE rubric templates130rubric_1 = FactoryBot.create(:rubric_template)131rubric_1.rubric_categories << [completion, test, c_and_m, vcs]132rubric_2 = FactoryBot.create(:rubric_template)133rubric_2.rubric_categories << [completion, test, c_and_m, oop]134rubric_3 = FactoryBot.create(:rubric_template)135rubric_3.rubric_categories << [completion, test, rails, ar, schema]136rubric_4 = FactoryBot.create(:rubric_template)137rubric_4.rubric_categories << [completion, test, rails, ar, api]138rubric_5 = FactoryBot.create(:rubric_template)139rubric_5.rubric_categories << [completion, test, code, oop, p_and_p]140rubric_6 = FactoryBot.create(:rubric_template)141rubric_6.rubric_categories << [completion, test, code, oop]142rubric_7 = FactoryBot.create(:rubric_template)143rubric_7.rubric_categories << [completion, test, ci_deploy, stretch, agile, docs]144#FE rubric templates145rubric_8 = FactoryBot.create(:rubric_template)146rubric_8.rubric_categories << [completion, test, js, p_and_p]147rubric_9 = FactoryBot.create(:rubric_template)148rubric_9.rubric_categories << [completion, test, js, p_and_p, design]149rubric_10 = FactoryBot.create(:rubric_template)150rubric_10.rubric_categories << [completion, test, js, p_and_p, ui]151rubric_11 = FactoryBot.create(:rubric_template)152rubric_11.rubric_categories << [completion, test, react, p_and_p, routing]153rubric_12 = FactoryBot.create(:rubric_template)154rubric_12.rubric_categories << [completion, test, react, p_and_p, stretch]155rubric_13 = FactoryBot.create(:rubric_template)156rubric_13.rubric_categories << [completion, test, ci_deploy, ui, agile, docs]157# projects158#BE Mod 1 projects159war_and_peace = FactoryBot.create(:project_template, mod: "1", project_number: "1", rubric_template_id: rubric_1.id, name: "War and Peace", program: "BE", project_type: 0)160battleship = FactoryBot.create(:project_template, mod: "1", project_number: "2", rubric_template_id: rubric_1.id, name: "Battleship", program: "BE", project_type: 1)161mastermind = FactoryBot.create(:project_template, mod: "1", project_number: "2", rubric_template_id: rubric_1.id, name: "Mastermind", program: "BE", project_type: 1)162black_thursday = FactoryBot.create(:project_template, mod: "1", project_number: "3", rubric_template_id: rubric_2.id, name: "Black Thursday", program: "BE", project_type: 2)163futbol = FactoryBot.create(:project_template, mod: "1", project_number: "3", rubric_template_id: rubric_2.id, name: "Futbol", program: "BE", project_type: 2)164enigma = FactoryBot.create(:project_template, mod: "1", project_number: "4", rubric_template_id: rubric_2.id, name: "Enigma", program: "BE", is_final: true, project_type: 0)165nightwriter = FactoryBot.create(:project_template, mod: "1", project_number: "4", rubric_template_id: rubric_2.id, name: "Night Writer", program: "BE", is_final: true, project_type: 0)166#FE Mod 1167js_fun_library = FactoryBot.create(:project_template, mod: "1", project_number: "1", rubric_template_id: rubric_8.id, name: "JS Fun at the Library", program: "FE", project_type: 0)168rom_com = FactoryBot.create(:project_template, mod: "1", project_number: "2", rubric_template_id: rubric_8.id, name: "RomCom", program: "FE", project_type: 1)169intention = FactoryBot.create(:project_template, mod: "1", project_number: "3", rubric_template_id: rubric_8.id, name: "Intention Timer", program: "FE", project_type: 2)170tic_tac_toe = FactoryBot.create(:project_template, mod: "1", project_number: "4", rubric_template_id: rubric_9.id, name: "Tic Tac Toe", program: "FE", is_final: true, project_type: 0)171#BE Mod 2172relational = FactoryBot.create(:project_template, mod: "2", project_number: "1", rubric_template_id: rubric_3.id, name: "Relational Rails", program: "BE", project_type: 1)173adopt = FactoryBot.create(:project_template, mod: "2", project_number: "2", rubric_template_id: rubric_3.id, name: "Adopt don't Shop", program: "BE", project_type: 0)174black_rails = FactoryBot.create(:project_template, mod: "2", project_number: "3", rubric_template_id: rubric_4.id, name: "Black Thursday on Rails", program: "BE", project_type: 2)175discounts = FactoryBot.create(:project_template, mod: "2", project_number: "4", rubric_template_id: rubric_3.id, name: "Bulk Discounts", program: "BE", is_final: true, project_type: 0)176#FE Mod 2177js_fun = FactoryBot.create(:project_template, mod: "2", project_number: "1", rubric_template_id: rubric_10.id, name: "JSFun", program: "FE", project_type: 0)178fit = FactoryBot.create(:project_template, mod: "2", project_number: "2", rubric_template_id: rubric_10.id, name: "FitLit", program: "FE", project_type: 1)179game_time = FactoryBot.create(:project_template, mod: "2", project_number: "3", rubric_template_id: rubric_10.id, name: "Game Time", program: "FE", project_type: 2)180travel_tracker = FactoryBot.create(:project_template, mod: "2", project_number: "4", rubric_template_id: rubric_10.id, name: "Travel Tracker", program: "FE", is_final: true, project_type: 0)181#BE Mod 3182viewing_party = FactoryBot.create(:project_template, mod: "3", project_number: "1", rubric_template_id: rubric_6.id, name: "Relational Rails", program: "BE", project_type: 0)183black_api_edition = FactoryBot.create(:project_template, mod: "3", project_number: "2", rubric_template_id: rubric_4.id, name: "Black Thursday API Edition", program: "BE", project_type: 1)184consultancy = FactoryBot.create(:project_template, mod: "3", project_number: "3", rubric_template_id: rubric_5.id, name: "Consultancy", program: "BE", project_type: 2)185weather = FactoryBot.create(:project_template, mod: "3", project_number: "4", rubric_template_id: rubric_5.id, name: "Sweater Weather", program: "BE", is_final: true, project_type: 0)186#FE Mod 3187tomatillos = FactoryBot.create(:project_template, mod: "3", project_number: "1", rubric_template_id: rubric_11.id, name: "Rancid Tomatillos", program: "FE", project_type: 0)188stretch = FactoryBot.create(:project_template, mod: "3", project_number: "2", rubric_template_id: rubric_11.id, name: "Stretch", program: "FE", project_type: 1)189niche_audience = FactoryBot.create(:project_template, mod: "3", project_number: "3", rubric_template_id: rubric_11.id, name: "Niche Audience", program: "FE", project_type: 2)190ideas = FactoryBot.create(:project_template, mod: "3", project_number: "4", rubric_template_id: rubric_12.id, name: "Ideas-4-Ideaboxes", program: "FE", is_final: true, project_type: 0)191#Mod 4192capstone_be = FactoryBot.create(:project_template, mod: "4", project_number: "1", rubric_template_id: rubric_7.id, name: "Capstone", program: "BE", project_type: 2, is_final: true)193capstone_fe = FactoryBot.create(:project_template, mod: "4", project_number: "1", rubric_template_id: rubric_13.id, name: "Capstone", program: "FE", project_type: 2, is_final: true)194# Be 1 Mod 1 Project 1195profiles_mod1_be.each do |student|196 FactoryBot.create(:student_project, student_id: student, project_template_id: war_and_peace.id, student_comments: nil)197 FactoryBot.create(:student_project, student_id: student, project_template_id: battleship.id, student_comments: nil)198 FactoryBot.create(:student_project, student_id: student, project_template_id: black_thursday.id, student_comments: nil)199end200profiles_mod2_be.each do |student|201 FactoryBot.create(:student_project, student_id: student, project_template_id: war_and_peace.id)202 FactoryBot.create(:student_project, student_id: student, project_template_id: battleship.id)203 FactoryBot.create(:student_project, student_id: student, project_template_id: black_thursday.id)204 FactoryBot.create(:student_project, student_id: student, project_template_id: enigma.id)205 FactoryBot.create(:student_project, student_id: student, project_template_id: relational.id, student_comments: nil)206 FactoryBot.create(:student_project, student_id: student, project_template_id: adopt.id, student_comments: nil)207 FactoryBot.create(:student_project, student_id: student, project_template_id: black_rails.id, student_comments: nil)208end209profiles_mod3_be.each do |student|210 FactoryBot.create(:student_project, student_id: student, project_template_id: war_and_peace.id)211 FactoryBot.create(:student_project, student_id: student, project_template_id: battleship.id)212 FactoryBot.create(:student_project, student_id: student, project_template_id: black_thursday.id)213 FactoryBot.create(:student_project, student_id: student, project_template_id: enigma.id)214 FactoryBot.create(:student_project, student_id: student, project_template_id: relational.id)215 FactoryBot.create(:student_project, student_id: student, project_template_id: adopt.id)216 FactoryBot.create(:student_project, student_id: student, project_template_id: black_rails.id)217 FactoryBot.create(:student_project, student_id: student, project_template_id: discounts.id)218 FactoryBot.create(:student_project, student_id: student, project_template_id: viewing_party.id, student_comments: nil)219 FactoryBot.create(:student_project, student_id: student, project_template_id: black_api_edition.id, student_comments: nil)220 FactoryBot.create(:student_project, student_id: student, project_template_id: consultancy.id, student_comments: nil)221end222profiles_mod4_be.each do |student|223 FactoryBot.create(:student_project, student_id: student, project_template_id: war_and_peace.id)224 FactoryBot.create(:student_project, student_id: student, project_template_id: battleship.id)225 FactoryBot.create(:student_project, student_id: student, project_template_id: black_thursday.id)226 FactoryBot.create(:student_project, student_id: student, project_template_id: enigma.id)227 FactoryBot.create(:student_project, student_id: student, project_template_id: relational.id)228 FactoryBot.create(:student_project, student_id: student, project_template_id: adopt.id)229 FactoryBot.create(:student_project, student_id: student, project_template_id: black_rails.id)230 FactoryBot.create(:student_project, student_id: student, project_template_id: discounts.id)231 FactoryBot.create(:student_project, student_id: student, project_template_id: viewing_party.id)232 FactoryBot.create(:student_project, student_id: student, project_template_id: black_api_edition.id)233 FactoryBot.create(:student_project, student_id: student, project_template_id: consultancy.id, student_comments: nil)234 FactoryBot.create(:student_project, student_id: student, project_template_id: weather.id, student_comments: nil)235 FactoryBot.create(:student_project, student_id: student, project_template_id: capstone_be.id, student_comments: nil)236end237profiles_mod1_fe.each do |student|238 FactoryBot.create(:student_project, student_id: student, project_template_id: js_fun_library.id, student_comments: nil)239 FactoryBot.create(:student_project, student_id: student, project_template_id: rom_com.id, student_comments: nil)240 FactoryBot.create(:student_project, student_id: student, project_template_id: intention.id, student_comments: nil)241end242profiles_mod2_fe.each do |student|243 FactoryBot.create(:student_project, student_id: student, project_template_id: js_fun_library.id)244 FactoryBot.create(:student_project, student_id: student, project_template_id: rom_com.id)245 FactoryBot.create(:student_project, student_id: student, project_template_id: intention.id)246 FactoryBot.create(:student_project, student_id: student, project_template_id: tic_tac_toe.id)247 FactoryBot.create(:student_project, student_id: student, project_template_id: js_fun.id, student_comments: nil)248 FactoryBot.create(:student_project, student_id: student, project_template_id: fit.id, student_comments: nil)249 FactoryBot.create(:student_project, student_id: student, project_template_id: game_time.id, student_comments: nil)250end251profiles_mod3_fe.each do |student|252 FactoryBot.create(:student_project, student_id: student, project_template_id: js_fun_library.id)253 FactoryBot.create(:student_project, student_id: student, project_template_id: rom_com.id)254 FactoryBot.create(:student_project, student_id: student, project_template_id: intention.id)255 FactoryBot.create(:student_project, student_id: student, project_template_id: tic_tac_toe.id)256 FactoryBot.create(:student_project, student_id: student, project_template_id: js_fun.id)257 FactoryBot.create(:student_project, student_id: student, project_template_id: fit.id)258 FactoryBot.create(:student_project, student_id: student, project_template_id: game_time.id)259 FactoryBot.create(:student_project, student_id: student, project_template_id: travel_tracker.id)260 FactoryBot.create(:student_project, student_id: student, project_template_id: tomatillos.id, student_comments: nil)261 FactoryBot.create(:student_project, student_id: student, project_template_id: stretch.id, student_comments: nil)262 FactoryBot.create(:student_project, student_id: student, project_template_id: niche_audience.id, student_comments: nil)263end264profiles_mod4_fe.each do |student|265 FactoryBot.create(:student_project, student_id: student, project_template_id: js_fun_library.id)266 FactoryBot.create(:student_project, student_id: student, project_template_id: rom_com.id)267 FactoryBot.create(:student_project, student_id: student, project_template_id: intention.id)268 FactoryBot.create(:student_project, student_id: student, project_template_id: tic_tac_toe.id)269 FactoryBot.create(:student_project, student_id: student, project_template_id: js_fun.id)270 FactoryBot.create(:student_project, student_id: student, project_template_id: fit.id)271 FactoryBot.create(:student_project, student_id: student, project_template_id: game_time.id)272 FactoryBot.create(:student_project, student_id: student, project_template_id: travel_tracker.id)273 FactoryBot.create(:student_project, student_id: student, project_template_id: tomatillos.id)274 FactoryBot.create(:student_project, student_id: student, project_template_id: stretch.id)275 FactoryBot.create(:student_project, student_id: student, project_template_id: niche_audience.id)276 FactoryBot.create(:student_project, student_id: student, project_template_id: ideas.id)277 FactoryBot.create(:student_project, student_id: student, project_template_id: capstone_fe.id, student_comments: nil)278end279be_instr_ids = [[122, 123, 124], [116, 117, 118], [112, 113], [106, 107, 108, 109]]280# BE Mod 1 project feedback for students in Mod 2+281StudentProject282.joins(:project_template, user: :user_profile)283.where("project_templates.mod = '1' and project_templates.program = 'BE'")284.where.not("user_profiles.current_cohort = '2105'")285.each do |project|286 project.rubric_template_categories.each do |category|287 FactoryBot.create(:project_feedback, instructor_id: be_instr_ids[0].sample, project_id: project.id, rubric_template_category_id: category.id)288 end289end290# BE Mod 1 project feedback for students in Mod 1291[1, 2, 3].each do |n|292 StudentProject293 .joins(:project_template, user: :user_profile)294 .where("project_templates.mod = '1' and project_number = '#{n}' and project_templates.program = 'BE'")295 .where("user_profiles.current_cohort = '2105'")296 .each do |project|297 project.rubric_template_categories.each do |category|298 FactoryBot.create(:project_feedback, instructor_id: be_instr_ids[0].sample, project_id: project.id, rubric_template_category_id: category.id)299 end300 end301end302# BE Mod 2 project feedback for students in Mod 3+303StudentProject304.joins(:project_template, user: :user_profile)305.where("project_templates.mod = '2' and project_templates.program = 'BE'")306.where.not("user_profiles.current_cohort = '2103'")307.each do |project|308 project.rubric_template_categories.each do |category|309 FactoryBot.create(:project_feedback, instructor_id: be_instr_ids[1].sample, project_id: project.id, rubric_template_category_id: category.id)310 end311end312# BE Mod 2 project feedback for students in Mod 2313[1, 2, 3].each do |n|314 StudentProject315 .joins(:project_template, user: :user_profile)316 .where("project_templates.mod = '2' and project_number = '#{n}' and project_templates.program = 'BE'")317 .where("user_profiles.current_cohort = '2103'")318 .each do |project|319 project.rubric_template_categories.each do |category|320 FactoryBot.create(:project_feedback, instructor_id: be_instr_ids[1].sample, project_id: project.id, rubric_template_category_id: category.id)321 end322 end323end324# BE Mod 3 project feedback for students in Mod 4+325StudentProject326.joins(:project_template, user: :user_profile)327.where("project_templates.mod = '3' and project_templates.program = 'BE'")328.where.not("user_profiles.current_cohort = '2102'")329.each do |project|330 project.rubric_template_categories.each do |category|331 FactoryBot.create(:project_feedback, instructor_id: be_instr_ids[2].sample, project_id: project.id, rubric_template_category_id: category.id)332 end333end334# BE Mod 3 project feedback for students in Mod 3335[1, 2, 3].each do |n|336 StudentProject337 .joins(:project_template, user: :user_profile)338 .where("project_templates.mod = '3' and project_number = '#{n}' and project_templates.program = 'BE'")339 .where("user_profiles.current_cohort = '2102'")340 .each do |project|341 project.rubric_template_categories.each do |category|342 FactoryBot.create(:project_feedback, instructor_id: be_instr_ids[2].sample, project_id: project.id, rubric_template_category_id: category.id)343 end344 end345end346# BE Mod 4 project feedback for students in Mod 4347StudentProject348.joins(:project_template, user: :user_profile)349.where("project_templates.mod = '4' and project_templates.program = 'BE'")350.each do |project|351 project.rubric_template_categories.each do |category|352 FactoryBot.create(:project_feedback, instructor_id: be_instr_ids[3].sample, project_id: project.id, rubric_template_category_id: category.id)353 end354end355fe_instr_ids = [[119, 120, 121], [114, 115], [110, 111], [106, 107, 108, 109]]356# FE Mod 1 project feedback for students in Mod 2+357StudentProject358.joins(:project_template, user: :user_profile)359.where("project_templates.mod = '1' and project_templates.program = 'FE'")360.where.not("user_profiles.current_cohort = '2105'")361.each do |project|362 project.rubric_template_categories.each do |category|363 FactoryBot.create(:project_feedback, instructor_id: fe_instr_ids[0].sample, project_id: project.id, rubric_template_category_id: category.id)364 end365end366# FE Mod 1 project feedback for students in Mod 1367[1, 2, 3].each do |n|368 StudentProject369 .joins(:project_template, user: :user_profile)370 .where("project_templates.mod = '1' and project_number = '#{n}' and project_templates.program = 'FE'")371 .where("user_profiles.current_cohort = '2105'")372 .each do |project|373 project.rubric_template_categories.each do |category|374 FactoryBot.create(:project_feedback, instructor_id: fe_instr_ids[0].sample, project_id: project.id, rubric_template_category_id: category.id)375 end376 end377end378# FE Mod 2 project feedback for students in Mod 3+379StudentProject380.joins(:project_template, user: :user_profile)381.where("project_templates.mod = '2' and project_templates.program = 'FE'")382.where.not("user_profiles.current_cohort = '2103'")383.each do |project|384 project.rubric_template_categories.each do |category|385 FactoryBot.create(:project_feedback, instructor_id: fe_instr_ids[1].sample, project_id: project.id, rubric_template_category_id: category.id)386 end387end388# FE Mod 2 project feedback for students in Mod 2389[1, 2, 3].each do |n|390 StudentProject391 .joins(:project_template, user: :user_profile)392 .where("project_templates.mod = '2' and project_number = '#{n}' and project_templates.program = 'FE'")393 .where("user_profiles.current_cohort = '2103'")394 .each do |project|395 project.rubric_template_categories.each do |category|396 FactoryBot.create(:project_feedback, instructor_id: fe_instr_ids[1].sample, project_id: project.id, rubric_template_category_id: category.id)397 end398 end399end400# FE Mod 3 project feedback for students in Mod 4+401StudentProject402.joins(:project_template, user: :user_profile)403.where("project_templates.mod = '3' and project_templates.program = 'FE'")404.where.not("user_profiles.current_cohort = '2102'")405.each do |project|406 project.rubric_template_categories.each do |category|407 FactoryBot.create(:project_feedback, instructor_id: fe_instr_ids[2].sample, project_id: project.id, rubric_template_category_id: category.id)408 end409end410# FE Mod 3 project feedback for students in Mod 3411[1, 2, 3].each do |n|412 StudentProject413 .joins(:project_template, user: :user_profile)414 .where("project_templates.mod = '3' and project_number = '#{n}' and project_templates.program = 'FE'")415 .where("user_profiles.current_cohort = '2102'")416 .each do |project|417 project.rubric_template_categories.each do |category|418 FactoryBot.create(:project_feedback, instructor_id: fe_instr_ids[2].sample, project_id: project.id, rubric_template_category_id: category.id)419 end420 end421end422# FE Mod 4 project feedback for students in Mod 4423StudentProject424.joins(:project_template, user: :user_profile)425.where("project_templates.mod = '4' and project_templates.program = 'FE'")426.each do |project|427 project.rubric_template_categories.each do |category|428 FactoryBot.create(:project_feedback, instructor_id: fe_instr_ids[3].sample, project_id: project.id, rubric_template_category_id: category.id)429 end430end431# reset pk sequences to current max value432ActiveRecord::Base.connection.tables.each do |t|433 ActiveRecord::Base.connection.reset_pk_sequence!(t)434end...

Full Screen

Full Screen

dev_seeds.rb

Source:dev_seeds.rb Github

copy

Full Screen

...3rands = (1..10).to_a4puts 'Creating Breeds'55.times { FactoryBot.create(:breed) }6puts 'Creating Registrars'7Breed.all.each do |breed|8 next if breed.registrars.count > 09 rands.sample.times { FactoryBot.create(:registrar, breed: breed) }10end11puts 'Creating Animals'12Breed.all.each do |breed|13 @sires = 4.times.collect { FactoryBot.create(:animal, :with_sire, :with_dam, is_male: true, breed: breed) }14 @dams = 4.times.collect { FactoryBot.create(:animal, :with_sire, :with_dam, is_male: false, breed: breed) }15 6.times {16 FactoryBot.create(:animal, sire: @sires.sample, dam: @dams.sample, breed: breed)17 }18end19puts 'Creating Registrations'20Animal.all.each do |animal|21 Registrar.where(breed: animal.breed).each do |reg|22 next if [true, false, false].sample23 FactoryBot.create(:registration, animal: animal, registrar: reg)24 end25end26puts 'Creating Storage Facilities'275.times { FactoryBot.create(:storage_facility, :with_adjustments) }28puts 'Creating Skus'2915.times { FactoryBot.create(:sku, animal: Animal.all.sample) }30185.times do31 seller = User.all.sample32 animal = Animal.all.sample33 sf = StorageFacility.all.sample34 FactoryBot.create(:sku, :with_countries, seller: seller, animal: animal, storagefacility: sf)35end36puts 'Set random Storage Facilities to require Administrative Approval'3710.times do38 sf = StorageFacility.all.sample39 sf.update(admin_required: true)40end41puts 'Creating custom commissions'42rands.sample.times do43 user = User.all.sample44 FactoryBot.create(:commission, user: user)45end46puts 'Adding Inventory Transactions to skus'47Sku.all.each do |sku|48 quantity = (1000..5000).to_a.sample49 FactoryBot.create(:inventory_transaction, sku: sku, quantity: quantity)50end51puts 'Adding fees to storage facilities'52StorageFacility.all.each do |sf|53 (0..5).to_a.sample.times do54 FactoryBot.create(:fee, storage_facility: sf)55 end56end57puts 'Creating Users'5825.times { FactoryBot.create(:user) }59puts 'Creating Purchases'60Purchase.states.keys.each do |state|61 10.times do62 user = User.all.sample63 purchase = FactoryBot.create(:purchase, state: state, user: user, created_at: Faker::Date.backward(30))64 if state == 'paid'65 purchase.update(66 authorization_code: Faker::Number.number(6),67 transaction_id: Faker::Number.number(11)68 )69 end70 if [true, false].sample71 purchase.line_items << FactoryBot.build_list(:line_item, rands.sample)72 end73 if purchase.state_before_type_cast >= 274 purchase.shipments << FactoryBot.build_list(:shipment, rands.sample)...

Full Screen

Full Screen

each

Using AI Code Generation

copy

Full Screen

1 first_name { Faker::Name.first_name }2 last_name { Faker::Name.last_name }3 email { Faker::Internet.email }4 password { Faker::Internet.password }5user = FactoryBot.create(:user)

Full Screen

Full Screen

each

Using AI Code Generation

copy

Full Screen

1 name { Faker::Name.name }2 email { Faker::Internet.email }3 password { Faker::Internet.password }4 name { Faker::Name.name }5 email { Faker::Internet.email }6 password { Faker::Internet.password }7 name { Faker::Name.name }8 email { Faker::Internet.email }9 password { Faker::Internet.password }10 name { Faker::Name.name }11 email { Faker::Internet.email }12 password { Faker::Internet.password }13 name { Faker::Name.name }14 email { Faker::Internet.email }15 password { Faker::Internet.password }16 name { Faker::Name.name }17 email { Faker::Internet.email }18 password { Faker::Internet.password }19 name { Faker::Name.name }20 email { Faker::Internet.email }21 password { Faker::Internet.password }22 name { Faker

Full Screen

Full Screen

each

Using AI Code Generation

copy

Full Screen

1 first_name { "John" }2 last_name { "Doe" }3 email { "

Full Screen

Full Screen

each

Using AI Code Generation

copy

Full Screen

1 first_name { 'John' }2 last_name { 'Doe' }3 email { '

Full Screen

Full Screen

each

Using AI Code Generation

copy

Full Screen

1Post.create(title: "My Title", body: "My post body")2Post.create(title: "Another Title", body: "Another post body")3Post.create(title: "Yet Another Title", body: "Yet another post body")4Post.create(title: "Final Title", body: "Final post body")5Post.create(title: "Final Title", body: "Final post body")6Post.create(title: "Final Title", body: "Final post body")7Post.create(title: "Final Title", body: "Final post body")8Post.create(title: "Final Title", body: "Final post body")9Post.create(title: "Final Title", body: "Final post body")10Post.create(title: "Final Title", body: "Final post body")11Post.create(title:

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Factory_bot_ruby automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful