Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

ruby "3.4.4"

gem "rails", "~> 8.1.1"
Copy link
Collaborator

@davidpgero davidpgero Jan 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have 8 migrations which already depend on 8.1

ActiveRecord::Migration[8.1]

https://github.com/search?q=repo%3Arubyforgood%2Fstocks-in-the-future+ActiveRecord%3A%3AMigration%5B8.1%5D&type=code

Can you help me a bit why we want to do a downgrade here?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, relates here: #993

gem "rails", "~> 8.0.0"

gem "administrate", "1.0.0.beta3"
gem "bootsnap", require: false
Expand All @@ -27,6 +27,7 @@
gem "strong_migrations", "~> 2.5"
gem "tailwindcss-rails"
gem "turbo-rails"
gem "action_text-trix", "~> 2.1.16"

Check failure on line 30 in Gemfile

View workflow job for this annotation

GitHub Actions / lint

Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem `action_text-trix` should appear before `turbo-rails`.

gem "discard", "~> 1.4"
gem "tzinfo-data", platforms: %i[windows jruby]
Expand Down
138 changes: 69 additions & 69 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,75 +1,74 @@
GEM
remote: https://rubygems.org/
specs:
action_text-trix (2.1.15)
action_text-trix (2.1.16)
railties
actioncable (8.1.1)
actionpack (= 8.1.1)
activesupport (= 8.1.1)
actioncable (8.0.4)
actionpack (= 8.0.4)
activesupport (= 8.0.4)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
zeitwerk (~> 2.6)
actionmailbox (8.1.1)
actionpack (= 8.1.1)
activejob (= 8.1.1)
activerecord (= 8.1.1)
activestorage (= 8.1.1)
activesupport (= 8.1.1)
actionmailbox (8.0.4)
actionpack (= 8.0.4)
activejob (= 8.0.4)
activerecord (= 8.0.4)
activestorage (= 8.0.4)
activesupport (= 8.0.4)
mail (>= 2.8.0)
actionmailer (8.1.1)
actionpack (= 8.1.1)
actionview (= 8.1.1)
activejob (= 8.1.1)
activesupport (= 8.1.1)
actionmailer (8.0.4)
actionpack (= 8.0.4)
actionview (= 8.0.4)
activejob (= 8.0.4)
activesupport (= 8.0.4)
mail (>= 2.8.0)
rails-dom-testing (~> 2.2)
actionpack (8.1.1)
actionview (= 8.1.1)
activesupport (= 8.1.1)
actionpack (8.0.4)
actionview (= 8.0.4)
activesupport (= 8.0.4)
nokogiri (>= 1.8.5)
rack (>= 2.2.4)
rack-session (>= 1.0.1)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
useragent (~> 0.16)
actiontext (8.1.1)
action_text-trix (~> 2.1.15)
actionpack (= 8.1.1)
activerecord (= 8.1.1)
activestorage (= 8.1.1)
activesupport (= 8.1.1)
actiontext (8.0.4)
actionpack (= 8.0.4)
activerecord (= 8.0.4)
activestorage (= 8.0.4)
activesupport (= 8.0.4)
globalid (>= 0.6.0)
nokogiri (>= 1.8.5)
actionview (8.1.1)
activesupport (= 8.1.1)
actionview (8.0.4)
activesupport (= 8.0.4)
builder (~> 3.1)
erubi (~> 1.11)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
activejob (8.1.1)
activesupport (= 8.1.1)
activejob (8.0.4)
activesupport (= 8.0.4)
globalid (>= 0.3.6)
activemodel (8.1.1)
activesupport (= 8.1.1)
activerecord (8.1.1)
activemodel (= 8.1.1)
activesupport (= 8.1.1)
activemodel (8.0.4)
activesupport (= 8.0.4)
activerecord (8.0.4)
activemodel (= 8.0.4)
activesupport (= 8.0.4)
timeout (>= 0.4.0)
activestorage (8.1.1)
actionpack (= 8.1.1)
activejob (= 8.1.1)
activerecord (= 8.1.1)
activesupport (= 8.1.1)
activestorage (8.0.4)
actionpack (= 8.0.4)
activejob (= 8.0.4)
activerecord (= 8.0.4)
activesupport (= 8.0.4)
marcel (~> 1.0)
activesupport (8.1.1)
activesupport (8.0.4)
base64
benchmark (>= 0.3)
bigdecimal
concurrent-ruby (~> 1.0, >= 1.3.1)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
json
logger (>= 1.4.2)
minitest (>= 5.1)
securerandom (>= 0.3)
Expand All @@ -85,6 +84,7 @@ GEM
ast (2.4.3)
base64 (0.3.0)
bcrypt (3.1.20)
benchmark (0.5.0)
better_html (2.2.0)
actionview (>= 7.0)
activesupport (>= 7.0)
Expand Down Expand Up @@ -232,12 +232,11 @@ GEM
logger
mini_mime (1.1.5)
mini_portile2 (2.8.9)
minitest (6.0.1)
prism (~> 1.5)
minitest (5.27.0)
mocha (3.0.1)
ruby2_keywords (>= 0.0.5)
msgpack (1.8.0)
net-imap (0.5.12)
net-imap (0.6.2)
date
net-protocol
net-pop (0.1.2)
Expand All @@ -246,19 +245,19 @@ GEM
timeout
net-smtp (0.5.1)
net-protocol
nio4r (2.7.4)
nokogiri (1.18.10)
nio4r (2.7.5)
nokogiri (1.19.0)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
nokogiri (1.18.10-aarch64-linux-gnu)
nokogiri (1.19.0-aarch64-linux-gnu)
racc (~> 1.4)
nokogiri (1.18.10-arm-linux-gnu)
nokogiri (1.19.0-arm-linux-gnu)
racc (~> 1.4)
nokogiri (1.18.10-arm64-darwin)
nokogiri (1.19.0-arm64-darwin)
racc (~> 1.4)
nokogiri (1.18.10-x86_64-darwin)
nokogiri (1.19.0-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.18.10-x86_64-linux-gnu)
nokogiri (1.19.0-x86_64-linux-gnu)
racc (~> 1.4)
orm_adapter (0.5.0)
parallel (1.27.0)
Expand Down Expand Up @@ -302,20 +301,20 @@ GEM
rack (>= 1.3)
rackup (2.3.1)
rack (>= 3)
rails (8.1.1)
actioncable (= 8.1.1)
actionmailbox (= 8.1.1)
actionmailer (= 8.1.1)
actionpack (= 8.1.1)
actiontext (= 8.1.1)
actionview (= 8.1.1)
activejob (= 8.1.1)
activemodel (= 8.1.1)
activerecord (= 8.1.1)
activestorage (= 8.1.1)
activesupport (= 8.1.1)
rails (8.0.4)
actioncable (= 8.0.4)
actionmailbox (= 8.0.4)
actionmailer (= 8.0.4)
actionpack (= 8.0.4)
actiontext (= 8.0.4)
actionview (= 8.0.4)
activejob (= 8.0.4)
activemodel (= 8.0.4)
activerecord (= 8.0.4)
activestorage (= 8.0.4)
activesupport (= 8.0.4)
bundler (>= 1.15.0)
railties (= 8.1.1)
railties (= 8.0.4)
rails-dom-testing (2.3.0)
activesupport (>= 5.0.0)
minitest
Expand All @@ -326,9 +325,9 @@ GEM
rails-i18n (8.1.0)
i18n (>= 0.7, < 2)
railties (>= 8.0.0, < 9)
railties (8.1.1)
actionpack (= 8.1.1)
activesupport (= 8.1.1)
railties (8.0.4)
actionpack (= 8.0.4)
activesupport (= 8.0.4)
irb (~> 1.13)
rackup (>= 1.0.0)
rake (>= 12.2)
Expand All @@ -337,7 +336,7 @@ GEM
zeitwerk (~> 2.6)
rainbow (3.1.1)
rake (13.3.1)
rdoc (7.0.2)
rdoc (7.0.3)
erb
psych (>= 4.0.0)
tsort
Expand Down Expand Up @@ -415,7 +414,7 @@ GEM
tailwindcss-ruby (4.1.16-x86_64-linux-gnu)
terminal-table (4.0.0)
unicode-display_width (>= 1.1.1, < 4)
thor (1.4.0)
thor (1.5.0)
timeout (0.6.0)
tsort (0.2.0)
turbo-rails (2.0.20)
Expand Down Expand Up @@ -457,6 +456,7 @@ PLATFORMS
x86_64-linux

DEPENDENCIES
action_text-trix (~> 2.1.16)
administrate (= 1.0.0.beta3)
bootsnap
brakeman
Expand All @@ -483,7 +483,7 @@ DEPENDENCIES
pry-byebug
puma (>= 5.0)
pundit (~> 2.5)
rails (~> 8.1.1)
rails (~> 8.0.0)
rubocop
rubocop-rails
selenium-webdriver
Expand Down
8 changes: 8 additions & 0 deletions app/models/classroom.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class Classroom < ApplicationRecord
validates :name, presence: true
validate :grade_level

after_create :create_gradebooks_for_quarters

scope :active, -> { where(archived: false) }
scope :archived, -> { where(archived: true) }

Expand Down Expand Up @@ -69,6 +71,12 @@ def continuous?(values)

private

def create_gradebooks_for_quarters
school_year.quarters.each do |quarter|
GradeBook.find_or_create_by!(quarter: quarter, classroom: self)
end
end

def grade_level
errors.add(:grades, "must have at least one grade") if grades.empty?
end
Expand Down
20 changes: 20 additions & 0 deletions test/models/classroom_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,24 @@ class ClassroomTest < ActiveSupport::TestCase
assert_not_includes classroom.students, discarded_student
assert_equal [kept_student.id], classroom.students.pluck(:id)
end

test "creates gradebooks for all quarters when classroom is created" do
# Create a school year with quarters
school_year = create(:school_year)
quarter1 = create(:quarter, school_year: school_year, number: 1)
quarter2 = create(:quarter, school_year: school_year, number: 2)
quarter3 = create(:quarter, school_year: school_year, number: 3)
quarter4 = create(:quarter, school_year: school_year, number: 4)

# Creating a classroom should create gradebooks for all quarters
assert_difference("GradeBook.count", 4) do
classroom = create(:classroom, school_year: school_year)

# Verify gradebooks were created for each quarter
assert GradeBook.exists?(classroom: classroom, quarter: quarter1)
assert GradeBook.exists?(classroom: classroom, quarter: quarter2)
assert GradeBook.exists?(classroom: classroom, quarter: quarter3)
assert GradeBook.exists?(classroom: classroom, quarter: quarter4)
end
end
end
Loading