From eb8c126240c2046f9fbc71499b1de578c64d2939 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 25 Dec 2024 00:29:36 +0000 Subject: [PATCH] build(deps): bump sinatra from 3.1.0 to 4.1.0 (#7303) * build(deps): bump sinatra from 3.1.0 to 4.1.0 Bumps [sinatra](https://github.com/sinatra/sinatra) from 3.1.0 to 4.1.0. - [Changelog](https://github.com/sinatra/sinatra/blob/main/CHANGELOG.md) - [Commits](https://github.com/sinatra/sinatra/compare/v3.1.0...v4.1.0) --- updated-dependencies: - dependency-name: sinatra dependency-type: indirect ... Signed-off-by: dependabot[bot] * Added text/javascript mime type handling (was previously application/javascript) * Fixed session handling in request tests --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: David Liu --- Gemfile.lock | 30 +++++++++++--------- app/helpers/download_helper.rb | 3 +- config/environments/test.rb | 2 ++ spec/controllers/criteria_controller_spec.rb | 15 +++++----- spec/requests/admin/resque_spec.rb | 15 ++-------- spec/spec_helper.rb | 4 +++ 6 files changed, 34 insertions(+), 35 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 65f1fb1d2b..3d5578f25c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -260,7 +260,7 @@ GEM mono_logger (1.1.2) msgpack (1.7.2) multi_json (1.15.0) - mustermann (3.0.0) + mustermann (3.0.3) ruby2_keywords (~> 0.0.1) net-imap (0.5.3) date @@ -301,18 +301,19 @@ GEM nio4r (~> 2.0) raabro (1.4.0) racc (1.8.1) - rack (2.2.10) + rack (3.1.8) rack-cors (2.0.2) rack (>= 2.0.0) - rack-protection (3.1.0) - rack (~> 2.2, >= 2.2.4) - rack-session (1.0.2) - rack (< 3) + rack-protection (4.1.1) + base64 (>= 0.1.0) + logger (>= 1.6.0) + rack (>= 3.0.0, < 4) + rack-session (2.0.0) + rack (>= 3.0.0) rack-test (2.1.0) rack (>= 1.3) - rackup (1.0.1) - rack (< 3) - webrick + rackup (2.2.1) + rack (>= 3) rails (7.2.2.1) actioncable (= 7.2.2.1) actionmailbox (= 7.2.2.1) @@ -438,10 +439,12 @@ GEM simplecov-html (0.12.3) simplecov-lcov (0.8.0) simplecov_json_formatter (0.1.4) - sinatra (3.1.0) + sinatra (4.1.1) + logger (>= 1.6.0) mustermann (~> 3.0) - rack (~> 2.2, >= 2.2.4) - rack-protection (= 3.1.0) + rack (>= 3.0.0, < 4) + rack-protection (= 4.1.1) + rack-session (>= 2.0.0, < 3) tilt (~> 2.0) sorbet-runtime (0.5.11690) sprockets (4.2.1) @@ -457,7 +460,7 @@ GEM terser (1.2.4) execjs (>= 0.3.0, < 3) thor (1.3.2) - tilt (2.3.0) + tilt (2.5.0) timecop (0.9.10) timeout (0.4.3) ttfunk (1.8.0) @@ -474,7 +477,6 @@ GEM addressable (>= 2.8.0) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) - webrick (1.9.1) websocket (1.2.11) websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) diff --git a/app/helpers/download_helper.rb b/app/helpers/download_helper.rb index b5aff0b657..3acef3748c 100644 --- a/app/helpers/download_helper.rb +++ b/app/helpers/download_helper.rb @@ -1,6 +1,7 @@ # Helpers for handling downloading data files for various models. module DownloadHelper - MIME_TYPE_CONVERSION = { 'application/javascript': 'text/plain' }.stringify_keys.freeze + MIME_TYPE_CONVERSION = { 'application/javascript': 'text/plain', + 'text/javascript': 'text/plain' }.stringify_keys.freeze # Wrapper around +send_file+ which converts the +type+ optional argument according # to the +MIME_TYPE_CONVERSION+ hash. diff --git a/config/environments/test.rb b/config/environments/test.rb index 060e265e4d..93d6bd9c46 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -1,3 +1,5 @@ Markus::Application.configure do # Settings specified here will take precedence over those in config/application.rb + + Rails.application.config.middleware.use ActionDispatch::Session::CookieStore end diff --git a/spec/controllers/criteria_controller_spec.rb b/spec/controllers/criteria_controller_spec.rb index 1c4ffa38a4..8d8af0553b 100644 --- a/spec/controllers/criteria_controller_spec.rb +++ b/spec/controllers/criteria_controller_spec.rb @@ -1,4 +1,6 @@ describe CriteriaController do + include UploadHelper + # TODO: add 'role is from a different course' shared tests to each route test below let(:instructor) { create(:instructor) } let(:course) { instructor.course } @@ -1110,19 +1112,18 @@ end context 'When some criteria have been previously uploaded and and instructor performs a download' do - it 'responds with appropriate status' do - post_as instructor, :upload, params: { course_id: course.id, assignment_id: assignment.id, - upload_file: uploaded_file } + before do + Criterion.upload_criteria_from_yaml(assignment, parse_yaml_content(test_upload_download_file.read)) + end - get :download, params: { course_id: course.id, assignment_id: assignment.id } + it 'responds with appropriate status' do + get_as instructor, :download, params: { course_id: course.id, assignment_id: assignment.id } expect(response).to have_http_status(:ok) end it 'sends the correct information' do - post_as instructor, :upload, params: { course_id: course.id, assignment_id: assignment.id, - upload_file: test_upload_download_file } - get :download, params: { course_id: course.id, assignment_id: assignment.id } + get_as instructor, :download, params: { course_id: course.id, assignment_id: assignment.id } expect(YAML.safe_load(response.body, permitted_classes: [Symbol], symbolize_names: true)) .to eq(YAML.safe_load(expected_download.read, symbolize_names: true)) diff --git a/spec/requests/admin/resque_spec.rb b/spec/requests/admin/resque_spec.rb index 4bb5e0b301..a26ed9d2bb 100644 --- a/spec/requests/admin/resque_spec.rb +++ b/spec/requests/admin/resque_spec.rb @@ -6,20 +6,15 @@ end end - context 'when the user is authenticated and an admin' do + context 'when the user is authenticated' do before do - allow_any_instance_of(ActionDispatch::Request::Session).to receive(:[]).with(:auth_type) - .and_return('local') + post '/', params: { user_login: user.user_name, user_password: 'a' } end context 'and is an admin' do let(:user) { create(:admin_user) } it 'returns a 200 status code' do - # TODO: Change this to first login using a POST request, rather than mocking session. - # It seems that currently the session isn't persisted across two separate requests. - allow_any_instance_of(ActionDispatch::Request::Session).to receive(:[]).with(:real_user_name) - .and_return(user.user_name) get '/admin/resque' expect(response).to have_http_status :redirect expect(response).to redirect_to('/admin/resque/overview') @@ -30,8 +25,6 @@ let(:user) { create(:instructor) } it 'returns a 200 status code' do - allow_any_instance_of(ActionDispatch::Request::Session).to receive(:[]).with(:real_user_name) - .and_return(user.user_name) get '/admin/resque' expect(response).to have_http_status :forbidden end @@ -41,8 +34,6 @@ let(:user) { create(:ta) } it 'returns a 200 status code' do - allow_any_instance_of(ActionDispatch::Request::Session).to receive(:[]).with(:real_user_name) - .and_return(user.user_name) get '/admin/resque' expect(response).to have_http_status :forbidden end @@ -52,8 +43,6 @@ let(:user) { create(:student) } it 'returns a 200 status code' do - allow_any_instance_of(ActionDispatch::Request::Session).to receive(:[]).with(:real_user_name) - .and_return(user.user_name) get '/admin/resque' expect(response).to have_http_status :forbidden end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 4ba8c8dd5c..b4a318fe32 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -106,6 +106,10 @@ SimpleCov.command_name 'system' end + config.before :each, type: :request do + host! 'localhost' + end + config.after do |test| destroy_repos unless test.metadata[:keep_memory_repos] FactoryBot.rewind_sequences