Refactor exercise factories to pass user attribute to associations

This commit is contained in:
Sebastian Serth
2021-03-17 11:04:15 +01:00
parent 6e3127dad8
commit 58ffe061b3

View File

@ -17,7 +17,7 @@ FactoryBot.define do
factory :audio_video, class: 'Exercise' do factory :audio_video, class: 'Exercise' do
created_by_teacher created_by_teacher
description { "Try HTML's audio and video capabilities." } description { "Try HTML's audio and video capabilities." }
association :execution_environment, factory: :html execution_environment { association :html, user: user }
instructions { 'Build a simple website including an HTML <audio> and <video> element. Link the following media files: chai.ogg, devstories.mp4.' } instructions { 'Build a simple website including an HTML <audio> and <video> element. Link the following media files: chai.ogg, devstories.mp4.' }
title { 'Audio & Video' } title { 'Audio & Video' }
@ -35,7 +35,7 @@ FactoryBot.define do
factory :dummy, class: 'Exercise' do factory :dummy, class: 'Exercise' do
created_by_teacher created_by_teacher
description { 'Dummy' } description { 'Dummy' }
association :execution_environment, factory: :ruby execution_environment { association :ruby, user: user }
instructions instructions
title { 'Dummy' } title { 'Dummy' }
@ -61,7 +61,7 @@ FactoryBot.define do
factory :even_odd, class: 'Exercise' do factory :even_odd, class: 'Exercise' do
created_by_teacher created_by_teacher
description { 'Implement two methods even and odd which return whether a given number is even or odd, respectively.' } description { 'Implement two methods even and odd which return whether a given number is even or odd, respectively.' }
association :execution_environment, factory: :python execution_environment { association :python, user: user }
instructions instructions
title { 'Even/Odd' } title { 'Even/Odd' }
@ -75,7 +75,7 @@ FactoryBot.define do
factory :fibonacci, class: 'Exercise' do factory :fibonacci, class: 'Exercise' do
created_by_teacher created_by_teacher
description { 'Implement a recursive function that calculates a requested Fibonacci number.' } description { 'Implement a recursive function that calculates a requested Fibonacci number.' }
association :execution_environment, factory: :ruby execution_environment { association :ruby, user: user }
instructions instructions
title { 'Fibonacci Sequence' } title { 'Fibonacci Sequence' }
@ -91,7 +91,7 @@ FactoryBot.define do
factory :files, class: 'Exercise' do factory :files, class: 'Exercise' do
created_by_teacher created_by_teacher
description { 'Learn how to work with files.' } description { 'Learn how to work with files.' }
association :execution_environment, factory: :ruby execution_environment { association :ruby, user: user }
instructions instructions
title { 'Working with Files' } title { 'Working with Files' }
@ -105,7 +105,7 @@ FactoryBot.define do
factory :geolocation, class: 'Exercise' do factory :geolocation, class: 'Exercise' do
created_by_teacher created_by_teacher
description { "Use the HTML5 Geolocation API to get the user's geographical position." } description { "Use the HTML5 Geolocation API to get the user's geographical position." }
association :execution_environment, factory: :html execution_environment { association :html, user: user }
instructions instructions
title { 'Geolocation' } title { 'Geolocation' }
@ -118,7 +118,7 @@ FactoryBot.define do
factory :hello_world, class: 'Exercise' do factory :hello_world, class: 'Exercise' do
created_by_teacher created_by_teacher
description { "Write a simple 'Hello World' application." } description { "Write a simple 'Hello World' application." }
association :execution_environment, factory: :ruby execution_environment { association :ruby, user: user }
instructions instructions
title { 'Hello World' } title { 'Hello World' }
@ -131,7 +131,7 @@ FactoryBot.define do
factory :math, class: 'Exercise' do factory :math, class: 'Exercise' do
created_by_teacher created_by_teacher
description { 'Implement a recursive math library.' } description { 'Implement a recursive math library.' }
association :execution_environment, factory: :java execution_environment { association :java, user: user }
instructions instructions
title { 'Math' } title { 'Math' }
@ -146,7 +146,7 @@ FactoryBot.define do
factory :primes, class: 'Exercise' do factory :primes, class: 'Exercise' do
created_by_teacher created_by_teacher
description { 'Write a function that prints the first n prime numbers.' } description { 'Write a function that prints the first n prime numbers.' }
association :execution_environment, factory: :node_js execution_environment { association :node_js, user: user }
instructions instructions
title { 'Primes' } title { 'Primes' }
@ -158,7 +158,7 @@ FactoryBot.define do
factory :sql_select, class: 'Exercise' do factory :sql_select, class: 'Exercise' do
created_by_teacher created_by_teacher
description { 'Learn to use the SELECT statement.' } description { 'Learn to use the SELECT statement.' }
association :execution_environment, factory: :sqlite execution_environment { association :sqlite, user: user }
instructions { "Write a query which selects the full rows for all people with the last name 'Doe'." } instructions { "Write a query which selects the full rows for all people with the last name 'Doe'." }
title { 'SELECT' } title { 'SELECT' }
@ -172,7 +172,7 @@ FactoryBot.define do
factory :tdd, class: 'Exercise' do factory :tdd, class: 'Exercise' do
created_by_teacher created_by_teacher
description { 'Learn to appreciate test-driven development.' } description { 'Learn to appreciate test-driven development.' }
association :execution_environment, factory: :ruby execution_environment { association :ruby, user: user }
instructions { SeedsHelper.read_seed_file('tdd/instructions.md') } instructions { SeedsHelper.read_seed_file('tdd/instructions.md') }
title { 'Test-driven Development' } title { 'Test-driven Development' }
@ -185,7 +185,7 @@ FactoryBot.define do
factory :web_app, class: 'Exercise' do factory :web_app, class: 'Exercise' do
created_by_teacher created_by_teacher
description { 'Build a simple Web application with Sinatra.' } description { 'Build a simple Web application with Sinatra.' }
association :execution_environment, factory: :sinatra execution_environment { association :sinatra, user: user }
instructions instructions
title { 'A Simple Web Application' } title { 'A Simple Web Application' }