chore: init commit

in worker.../repo/GITFOLDER.zip is the .git folder.
This commit is contained in:
2026-08-11 14:44:09 -04:00
parent 0012380fd3
commit 2854619bc9
782 changed files with 65944 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
# frozen_string_literal: true
FactoryBot.define do
factory :classroom_enrollment do
student { association :student }
classroom { association :classroom }
enrolled_at { Time.current }
unenrolled_at { nil }
primary { false }
trait :current do
unenrolled_at { nil }
end
trait :historical do
enrolled_at { 1.year.ago }
unenrolled_at { 6.months.ago }
end
trait :primary do
primary { true }
end
end
end

View File

@@ -0,0 +1,8 @@
# frozen_string_literal: true
FactoryBot.define do
factory :classroom_grade do
association :classroom
association :grade
end
end

View File

@@ -0,0 +1,33 @@
# frozen_string_literal: true
FactoryBot.define do
factory :classroom do
sequence(:name) { |n| "Classroom #{n}" }
trading_enabled { false }
association :school_year
after(:build) do |classroom|
classroom.grades << build(:grade) if classroom.grades.empty?
end
trait :with_trading do
trading_enabled { true }
end
trait :with_grade do
after(:create) do |classroom|
create(:classroom_grade, classroom: classroom)
end
end
trait :with_grades do
transient do
grades_count { 3 }
end
after(:create) do |classroom, evaluator|
create_list(:classroom_grade, evaluator.grades_count, classroom: classroom)
end
end
end
end

View File

@@ -0,0 +1,10 @@
# frozen_string_literal: true
FactoryBot.define do
factory :grade_book do
quarter { create(:school_year).quarters.first }
association :classroom
status { "draft" }
end
end

View File

@@ -0,0 +1,14 @@
# frozen_string_literal: true
# test/factories/grade_entries.rb
FactoryBot.define do
factory :grade_entry do
association :grade_book
association :user, factory: :student
math_grade { nil }
reading_grade { nil }
attendance_days { 45 }
is_perfect_attendance { false }
end
end

View File

@@ -0,0 +1,8 @@
# frozen_string_literal: true
FactoryBot.define do
factory :grade do
sequence(:level) { |n| n }
sequence(:name) { |n| "Grade #{n}" }
end
end

View File

@@ -0,0 +1,51 @@
# frozen_string_literal: true
FactoryBot.define do
factory :order do
stock
shares { 1 }
user { create(:student) }
action { :sell } # Default to sell to avoid validation issues
end
trait :pending do
status { :pending }
end
trait :completed do
status { :completed }
end
trait :canceled do
status { :canceled }
end
trait :buy do
action { :buy }
end
trait :sell do
action { :sell }
end
trait :with_sufficient_funds do
after(:create) do |order|
order.user.portfolio.portfolio_transactions.create!(
amount_cents: 100_000, # $1000 - plenty for testing
transaction_type: :deposit
)
end
end
trait :with_sufficient_shares do
after(:create) do |order|
create(
:portfolio_stock,
portfolio: order.user.portfolio,
stock: order.stock,
shares: 100, # Plenty of shares for testing
purchase_price: order.stock.price_cents
)
end
end
end

View File

@@ -0,0 +1,9 @@
# frozen_string_literal: true
FactoryBot.define do
factory :portfolio_snapshot do
portfolio { create(:portfolio) }
date { Date.current }
worth_cents { 50_000 }
end
end

View File

@@ -0,0 +1,10 @@
# frozen_string_literal: true
FactoryBot.define do
factory :portfolio_stock do
association :portfolio
association :stock
shares { 10.0 }
purchase_price { 100.0 }
end
end

View File

@@ -0,0 +1,30 @@
# frozen_string_literal: true
FactoryBot.define do
factory :portfolio_transaction do
portfolio
amount_cents { 1_000 }
transaction_type { :credit }
end
trait :debit do
transaction_type { :debit }
end
trait :credit do
transaction_type { :credit }
end
trait :deposit do
transaction_type { :deposit }
end
trait :withdrawal do
transaction_type { :withdrawal }
end
trait :fee do
transaction_type { :fee }
amount_cents { PortfolioTransaction::TRANSACTION_FEE_CENTS }
end
end

View File

@@ -0,0 +1,7 @@
# frozen_string_literal: true
FactoryBot.define do
factory :portfolio do
user { create(:student) }
end
end

View File

@@ -0,0 +1,18 @@
# frozen_string_literal: true
# test/factories/quarters.rb
# SchoolYear auto-creates 4 quarters via after_create, so create(:quarter) finds
# the existing quarter rather than inserting a new one (which would violate the
# uniqueness constraint on number scoped to school_year).
FactoryBot.define do
factory :quarter do
association :school_year
number { 1 }
name { "Quarter #{number}" }
to_create do |instance|
instance.id = instance.school_year.quarters.find_by!(number: instance.number).id
instance.reload
end
end
end

View File

@@ -0,0 +1,9 @@
# frozen_string_literal: true
# test/factories/school_years.rb
FactoryBot.define do
factory :school_year do
association :school
association :year
end
end

View File

@@ -0,0 +1,7 @@
# frozen_string_literal: true
FactoryBot.define do
factory :school do
sequence(:name) { |n| "School #{n}" }
end
end

View File

@@ -0,0 +1,24 @@
# frozen_string_literal: true
FactoryBot.define do
factory :stock do
sequence(:ticker) { |n| "STOCK#{n}" }
stock_exchange { "NYSE" }
sequence(:company_name) { |n| "Sample Company#{n} Inc." }
company_website { "https://example.com" }
description { "A sample stock for testing" }
industry { "Technology" }
management { "CEO: John Doe" }
employees { 1000 }
sequence(:competitor_names) { |n| "Competitor #{n}, Competitor #{n + 1}" }
sales_growth { 5.5 }
industry_avg_sales_growth { 4.2 }
debt_to_equity { 0.3 }
industry_avg_debt_to_equity { 0.4 }
profit_margin { 15.2 }
industry_avg_profit_margin { 12.8 }
cash_flow { 1_000_000.00 }
debt { 500_000.00 }
price_cents { 12_500 } # $125.00
end
end

View File

@@ -0,0 +1,8 @@
# frozen_string_literal: true
FactoryBot.define do
factory :teacher_classroom do
teacher
classroom
end
end

View File

@@ -0,0 +1,39 @@
# frozen_string_literal: true
FactoryBot.define do
factory :admin, class: "User" do
password { "Passw0rd" }
sequence(:username) { |n| "admin_#{n}" }
sequence(:email) { |n| "admin_#{n}@example.com" }
admin { true }
end
factory :student, class: "Student" do
type { "Student" }
password { "Passw0rd" }
classroom { create(:classroom, :with_trading) }
sequence(:username) { |n| "student_#{n}" }
sequence(:email) { |n| "student_#{n}@example.com" }
trait :with_portfolio do
after(:create) do |student|
create(:portfolio, user: student)
end
end
trait :without_enrollment do
classroom { nil }
end
trait :discarded do
discarded_at { Time.current }
end
end
factory :teacher, class: "Teacher" do
type { "Teacher" }
password { "Passw0rd" }
classroom { create(:classroom) }
sequence(:email) { |n| "teacher_#{n}@example.com" }
end
end

View File

@@ -0,0 +1,7 @@
# frozen_string_literal: true
FactoryBot.define do
factory :year do
sequence(:name) { |n| "#{200 + n} - #{2000 + n + 1}" }
end
end