Skip to content

Commit

Permalink
build(deps): bump sinatra from 3.1.0 to 4.1.0 (#7303)
Browse files Browse the repository at this point in the history
* 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](sinatra/sinatra@v3.1.0...v4.1.0)

---
updated-dependencies:
- dependency-name: sinatra
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

* Added text/javascript mime type handling (was previously application/javascript)
* Fixed session handling in request tests

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: David Liu <[email protected]>
  • Loading branch information
dependabot[bot] and david-yz-liu authored Dec 25, 2024
1 parent 919aac9 commit eb8c126
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 35 deletions.
30 changes: 16 additions & 14 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion app/helpers/download_helper.rb
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 2 additions & 0 deletions config/environments/test.rb
Original file line number Diff line number Diff line change
@@ -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
15 changes: 8 additions & 7 deletions spec/controllers/criteria_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -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 }
Expand Down Expand Up @@ -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))
Expand Down
15 changes: 2 additions & 13 deletions spec/requests/admin/resque_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit eb8c126

Please sign in to comment.