diff --git a/Gemfile b/Gemfile index ee42e744a..3c64ae8e1 100644 --- a/Gemfile +++ b/Gemfile @@ -41,7 +41,7 @@ gem 'propshaft' gem 'puma', '~> 8.0' gem 'rack_content_type_default', '~> 1.1' gem 'rack-cors' -gem 'rails', '~> 7.2' +gem 'rails', '~> 8.0.5' gem 'ruby-progressbar', '~> 1.13', require: false gem 'sentry-rails' gem 'statesman' diff --git a/Gemfile.lock b/Gemfile.lock index 953f7d1a3..53b857221 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -11,68 +11,65 @@ GIT GEM remote: https://rubygems.org/ specs: - actioncable (7.2.3.1) - actionpack (= 7.2.3.1) - activesupport (= 7.2.3.1) + actioncable (8.0.5) + actionpack (= 8.0.5) + activesupport (= 8.0.5) nio4r (~> 2.0) websocket-driver (>= 0.6.1) zeitwerk (~> 2.6) - actionmailbox (7.2.3.1) - actionpack (= 7.2.3.1) - activejob (= 7.2.3.1) - activerecord (= 7.2.3.1) - activestorage (= 7.2.3.1) - activesupport (= 7.2.3.1) + actionmailbox (8.0.5) + actionpack (= 8.0.5) + activejob (= 8.0.5) + activerecord (= 8.0.5) + activestorage (= 8.0.5) + activesupport (= 8.0.5) mail (>= 2.8.0) - actionmailer (7.2.3.1) - actionpack (= 7.2.3.1) - actionview (= 7.2.3.1) - activejob (= 7.2.3.1) - activesupport (= 7.2.3.1) + actionmailer (8.0.5) + actionpack (= 8.0.5) + actionview (= 8.0.5) + activejob (= 8.0.5) + activesupport (= 8.0.5) mail (>= 2.8.0) rails-dom-testing (~> 2.2) - actionpack (7.2.3.1) - actionview (= 7.2.3.1) - activesupport (= 7.2.3.1) - cgi + actionpack (8.0.5) + actionview (= 8.0.5) + activesupport (= 8.0.5) nokogiri (>= 1.8.5) - racc - rack (>= 2.2.4, < 3.3) + 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 (7.2.3.1) - actionpack (= 7.2.3.1) - activerecord (= 7.2.3.1) - activestorage (= 7.2.3.1) - activesupport (= 7.2.3.1) + actiontext (8.0.5) + actionpack (= 8.0.5) + activerecord (= 8.0.5) + activestorage (= 8.0.5) + activesupport (= 8.0.5) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.2.3.1) - activesupport (= 7.2.3.1) + actionview (8.0.5) + activesupport (= 8.0.5) builder (~> 3.1) - cgi erubi (~> 1.11) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - activejob (7.2.3.1) - activesupport (= 7.2.3.1) + activejob (8.0.5) + activesupport (= 8.0.5) globalid (>= 0.3.6) - activemodel (7.2.3.1) - activesupport (= 7.2.3.1) - activerecord (7.2.3.1) - activemodel (= 7.2.3.1) - activesupport (= 7.2.3.1) + activemodel (8.0.5) + activesupport (= 8.0.5) + activerecord (8.0.5) + activemodel (= 8.0.5) + activesupport (= 8.0.5) timeout (>= 0.4.0) - activestorage (7.2.3.1) - actionpack (= 7.2.3.1) - activejob (= 7.2.3.1) - activerecord (= 7.2.3.1) - activesupport (= 7.2.3.1) + activestorage (8.0.5) + actionpack (= 8.0.5) + activejob (= 8.0.5) + activerecord (= 8.0.5) + activesupport (= 8.0.5) marcel (~> 1.0) - activesupport (7.2.3.1) + activesupport (8.0.5) base64 benchmark (>= 0.3) bigdecimal @@ -81,9 +78,10 @@ GEM drb i18n (>= 1.6, < 2) logger (>= 1.4.2) - minitest (>= 5.1, < 6) + minitest (>= 5.1) securerandom (>= 0.3) tzinfo (~> 2.0, >= 2.0.5) + uri (>= 0.13.1) addressable (2.9.0) public_suffix (>= 2.0.2, < 8.0) administrate (1.0.0) @@ -136,7 +134,6 @@ GEM rack-test (>= 0.6.3) regexp_parser (>= 1.5, < 3.0) xpath (~> 3.2) - cgi (0.5.1) childprocess (4.1.0) choice (0.2.0) climate_control (1.2.0) @@ -247,7 +244,7 @@ GEM actionview (>= 7.0.0) activesupport (>= 7.0.0) jmespath (1.6.2) - json (2.19.3) + json (2.19.5) jwt (2.10.2) base64 kaminari (1.2.2) @@ -268,24 +265,27 @@ GEM loofah (2.25.1) crass (~> 1.0.2) nokogiri (>= 1.12.0) - mail (2.8.1) + mail (2.9.0) + logger mini_mime (>= 0.1.1) net-imap net-pop net-smtp - marcel (1.0.4) + marcel (1.1.0) matrix (0.4.3) method_source (1.1.0) mini_magick (5.3.1) logger mini_mime (1.1.5) - minitest (5.27.0) + minitest (6.0.6) + drb (~> 2.0) + prism (~> 1.5) msgpack (1.8.0) multi_xml (0.8.1) bigdecimal (>= 3.1, < 5) net-http (0.9.1) uri (>= 0.11.1) - net-imap (0.5.9) + net-imap (0.6.4) date net-protocol net-pop (0.1.2) @@ -379,20 +379,20 @@ GEM rack rackup (2.3.1) rack (>= 3) - rails (7.2.3.1) - actioncable (= 7.2.3.1) - actionmailbox (= 7.2.3.1) - actionmailer (= 7.2.3.1) - actionpack (= 7.2.3.1) - actiontext (= 7.2.3.1) - actionview (= 7.2.3.1) - activejob (= 7.2.3.1) - activemodel (= 7.2.3.1) - activerecord (= 7.2.3.1) - activestorage (= 7.2.3.1) - activesupport (= 7.2.3.1) + rails (8.0.5) + actioncable (= 8.0.5) + actionmailbox (= 8.0.5) + actionmailer (= 8.0.5) + actionpack (= 8.0.5) + actiontext (= 8.0.5) + actionview (= 8.0.5) + activejob (= 8.0.5) + activemodel (= 8.0.5) + activerecord (= 8.0.5) + activestorage (= 8.0.5) + activesupport (= 8.0.5) bundler (>= 1.15.0) - railties (= 7.2.3.1) + railties (= 8.0.5) rails-dom-testing (2.3.0) activesupport (>= 5.0.0) minitest @@ -405,10 +405,9 @@ GEM rails-html-sanitizer (1.7.0) loofah (~> 2.25) nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0) - railties (7.2.3.1) - actionpack (= 7.2.3.1) - activesupport (= 7.2.3.1) - cgi + railties (8.0.5) + actionpack (= 8.0.5) + activesupport (= 8.0.5) irb (~> 1.13) rackup (>= 1.0.0) rake (>= 12.2) @@ -617,7 +616,7 @@ DEPENDENCIES puma (~> 8.0) rack-cors rack_content_type_default (~> 1.1) - rails (~> 7.2) + rails (~> 8.0.5) rails-erd rspec rspec-rails diff --git a/app/controllers/api/class_members_controller.rb b/app/controllers/api/class_members_controller.rb index 8bff19838..a00d104de 100644 --- a/app/controllers/api/class_members_controller.rb +++ b/app/controllers/api/class_members_controller.rb @@ -87,7 +87,7 @@ def members_existing_in_profile end def class_member_params - params.require(:class_member).permit(:user_id, :type) + params.expect(class_member: %i[user_id type]) end def create_batch_params diff --git a/app/controllers/api/google_auth_controller.rb b/app/controllers/api/google_auth_controller.rb index b18873d2d..9f60d3067 100644 --- a/app/controllers/api/google_auth_controller.rb +++ b/app/controllers/api/google_auth_controller.rb @@ -46,9 +46,9 @@ def response_error_message end def google_token_params - params.require(:google_auth).require(:code) - params.require(:google_auth).require(:redirect_uri) - params.require(:google_auth).permit(:code, :redirect_uri) + google_auth_params = params.expect(google_auth: %i[code redirect_uri]) + google_auth_params.require(%i[code redirect_uri]) + google_auth_params end end end diff --git a/app/controllers/api/projects/remixes_controller.rb b/app/controllers/api/projects/remixes_controller.rb index 430e50c56..9c51e165e 100644 --- a/app/controllers/api/projects/remixes_controller.rb +++ b/app/controllers/api/projects/remixes_controller.rb @@ -67,17 +67,19 @@ def load_and_authorize_remix_identifier end def remix_params - params.require(:project) - .permit(:name, - :identifier, - :project_type, - :locale, - :user_id, - :videos, - :audio, - :instructions, - image_list: [], - components: %i[id name extension content index]) + params + .expect(project: [:name, + :identifier, + :project_type, + :locale, + :user_id, + :videos, + :audio, + :instructions, + { + image_list: [], + components: [%i[id name extension content index]] + }]) end end end diff --git a/app/controllers/api/school_classes_controller.rb b/app/controllers/api/school_classes_controller.rb index 7774044be..b8366f4b6 100644 --- a/app/controllers/api/school_classes_controller.rb +++ b/app/controllers/api/school_classes_controller.rb @@ -192,11 +192,11 @@ def load_and_authorize_school_class def school_class_params # A school teacher may only create classes they own. - params.require(:school_class).permit(:name, :description) + params.expect(school_class: %i[name description]) end def import_school_class_params - params.require(:school_class).permit(:name, :description, :import_origin, :import_id) + params.expect(school_class: %i[name description import_origin import_id]) end def import_school_students_params diff --git a/app/controllers/api/school_students_controller.rb b/app/controllers/api/school_students_controller.rb index c403fc031..299f5eda3 100644 --- a/app/controllers/api/school_students_controller.rb +++ b/app/controllers/api/school_students_controller.rb @@ -167,7 +167,7 @@ def remove_students(student_ids) end def school_student_params - params.require(:school_student).permit(:username, :password, :name) + params.expect(school_student: %i[username password name]) end def school_students_params diff --git a/app/controllers/api/school_teachers_controller.rb b/app/controllers/api/school_teachers_controller.rb index 3407bfee4..3dde9f4ec 100644 --- a/app/controllers/api/school_teachers_controller.rb +++ b/app/controllers/api/school_teachers_controller.rb @@ -30,7 +30,7 @@ def create private def school_teacher_params - params.require(:school_teacher).permit(:email_address) + params.expect(school_teacher: [:email_address]) end end end diff --git a/app/controllers/api/schools_controller.rb b/app/controllers/api/schools_controller.rb index 075973360..52427efe9 100644 --- a/app/controllers/api/schools_controller.rb +++ b/app/controllers/api/schools_controller.rb @@ -77,26 +77,26 @@ def import private def school_params - params.require(:school).permit( - :name, - :website, - :reference, - :district_name, - :district_nces_id, - :school_roll_number, - :address_line_1, - :address_line_2, - :municipality, - :administrative_area, - :postal_code, - :country_code, - :creator_role, - :creator_department, - :creator_agree_authority, - :creator_agree_terms_and_conditions, - :creator_agree_to_ux_contact, - :creator_agree_responsible_safeguarding, - :user_origin + params.expect( + school: %i[name + website + reference + district_name + district_nces_id + school_roll_number + address_line_1 + address_line_2 + municipality + administrative_area + postal_code + country_code + creator_role + creator_department + creator_agree_authority + creator_agree_terms_and_conditions + creator_agree_to_ux_contact + creator_agree_responsible_safeguarding + user_origin] ) end end diff --git a/app/controllers/api/subscriptions_controller.rb b/app/controllers/api/subscriptions_controller.rb index 63fcc848e..bdb3883a0 100644 --- a/app/controllers/api/subscriptions_controller.rb +++ b/app/controllers/api/subscriptions_controller.rb @@ -63,7 +63,7 @@ def check_cloudflare_turnstile end def subscription_params - params.require(:subscription).permit(:email, :test_opt_in, :privacy_policy, :turnstile_token) + params.expect(subscription: %i[email test_opt_in privacy_policy turnstile_token]) end def subscriptions_submitter diff --git a/config/application.rb b/config/application.rb index a230f5477..3a914d3df 100644 --- a/config/application.rb +++ b/config/application.rb @@ -23,7 +23,7 @@ module App class Application < Rails::Application - config.load_defaults 7.2 + config.load_defaults 8.0 config.add_autoload_paths_to_load_path = false diff --git a/spec/features/school_class/listing_school_classes_spec.rb b/spec/features/school_class/listing_school_classes_spec.rb index 7e47d7d70..6f8526539 100644 --- a/spec/features/school_class/listing_school_classes_spec.rb +++ b/spec/features/school_class/listing_school_classes_spec.rb @@ -49,18 +49,20 @@ def create_remix_with_feedback(school_class:, student:, feedback_attrs: []) it 'responds with the school classes JSON' do data = get_classes - expect(data.first[:name]).to eq('Test School Class') + expect(find_school_class_by_name(data, 'Test School Class')).to be_present end it 'responds with the teachers JSON' do data = get_classes - expect(data.first[:teachers].first[:name]).to eq('School Teacher') + school_class = find_school_class_by_name(data, 'Test School Class') + expect(school_class[:teachers].first[:name]).to eq('School Teacher') end it "skips teachers if the user profile doesn't exist" do stub_user_info_api_for_unknown_users(user_id: teacher.id) data = get_classes - expect(data.first[:teachers].first).to be_nil + school_class = find_school_class_by_name(data, 'Test School Class') + expect(school_class[:teachers].first).to be_nil end it 'responds 401 Unauthorized when no token is given' do diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 4dcc17764..93941246a 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -108,14 +108,16 @@ DatabaseCleaner.strategy = :truncation DatabaseCleaner.cleaning do - Rake::Task.clear - Rails.application.load_tasks + Rake::Task.tasks.each(&:reenable) example.run - Rake::Task.clear + ensure + Rake::Task.tasks.each(&:reenable) end end config.before(:suite) do + Rails.application.load_tasks + db_config = ActiveRecord::Base.configurations.configs_for(env_name: Rails.env).first Rails.logger.debug { "Running tests in environment: #{Rails.env}" } Rails.logger.debug { "Running tests against the database: #{db_config.database}" } diff --git a/spec/requests/api_controller_spec.rb b/spec/requests/api_controller_spec.rb index d4cff479a..f8f2b37cd 100644 --- a/spec/requests/api_controller_spec.rb +++ b/spec/requests/api_controller_spec.rb @@ -46,7 +46,7 @@ def index get '/test' expect(response.parsed_body).to include( - 'error' => 'ActionController::ParameterMissing: param is missing or the value is empty: foo' + 'error' => 'ActionController::ParameterMissing: param is missing or the value is empty or invalid: foo' ) end end diff --git a/spec/requests/test_utilities_spec.rb b/spec/requests/test_utilities_spec.rb index d408d4da1..c3e99276b 100644 --- a/spec/requests/test_utilities_spec.rb +++ b/spec/requests/test_utilities_spec.rb @@ -20,9 +20,10 @@ DatabaseCleaner.strategy = :transaction DatabaseCleaner.cleaning do - Rails.application.load_tasks + Rake::Task.tasks.each(&:reenable) example.run - Rake::Task.clear + ensure + Rake::Task.tasks.each(&:reenable) end end