Skip to content

Commit 8454464

Browse files
committed
Fix rubocop errors
1 parent 54c94aa commit 8454464

4 files changed

Lines changed: 13 additions & 13 deletions

File tree

src/app/server/Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ gem "thruster", require: false
3535
# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin Ajax possible
3636
# gem "rack-cors"
3737

38-
gem 'aws-sdk-s3'
38+
gem "aws-sdk-s3"
3939

4040
group :development, :test do
4141
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem

src/app/server/app/controllers/files_controller.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
require 'aws-sdk-s3'
1+
require "aws-sdk-s3"
22

3-
S3_BUCKET_NAME = 'ucb-assignment-snapshots-eae254943a2c4f51bef67654e99560dd'
4-
S3_BUCKET_REGION = 'us-west-2'
3+
S3_BUCKET_NAME = "ucb-assignment-snapshots-eae254943a2c4f51bef67654e99560dd"
4+
S3_BUCKET_REGION = "us-west-2"
55

66
class FilesController < ApplicationController
77
def get_object_key(params)
88
# NOTE: we assume the okpy endpoint is passed in with - as the separator since / is reserved
9-
okpy_endpoint_parsed = params[:okpy_endpoint].gsub('-', '/')
10-
return "#{okpy_endpoint_parsed}/#{params[:assignment]}/#{params[:student_id]}/#{params[:backup_id]}/#{params[:file_name]}"
9+
okpy_endpoint_parsed = params[:okpy_endpoint].gsub("-", "/")
10+
"#{okpy_endpoint_parsed}/#{params[:assignment]}/#{params[:student_id]}/#{params[:backup_id]}/#{params[:file_name]}"
1111
end
1212

1313
def show
@@ -22,7 +22,7 @@ def show
2222

2323
begin
2424
resp = s3.get_object(bucket: S3_BUCKET_NAME, key: object_key)
25-
file_contents = resp.body.read.force_encoding('UTF-8') # Assuming UTF-8 encoding
25+
file_contents = resp.body.read.force_encoding("UTF-8") # Assuming UTF-8 encoding
2626
status = :ok
2727
rescue Aws::S3::Errors::NoSuchBucket => e
2828
error = "Error: Bucket not found: #{bucket_name}"

src/app/server/test/controllers/files_controller_test.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
require "ostruct"
2-
require 'stringio'
2+
require "stringio"
33
require "test_helper"
44

5-
require_relative '../../app/controllers/files_controller'
5+
require_relative "../../app/controllers/files_controller"
66

77
class FilesControllerTest < ActionDispatch::IntegrationTest
88
raw_okpy_endpoint = "cal-cs88-sp25"
@@ -11,15 +11,15 @@ class FilesControllerTest < ActionDispatch::IntegrationTest
1111
backup_id = "def456"
1212
route_prefix = "/files/#{raw_okpy_endpoint}/#{assignment}/#{student_id}/#{backup_id}"
1313
unknown_file = "unknown.txt"
14-
known_files = ["utils.py", "abstractions.py", "recommend.py", "autograder_output.txt"]
15-
file_contents = ["foo", "bar", "baz", "qux"]
14+
known_files = [ "utils.py", "abstractions.py", "recommend.py", "autograder_output.txt" ]
15+
file_contents = [ "foo", "bar", "baz", "qux" ]
1616

1717
test "should respond with 404 Not Found if file name unknown" do
1818
# Mock AWS S3 client
1919
Aws::S3::Client.any_instance
2020
.stubs(:get_object)
2121
.with(bucket: S3_BUCKET_NAME, key: "cal/cs88/sp25/#{assignment}/#{student_id}/#{backup_id}/#{unknown_file}")
22-
.raises(Aws::S3::Errors::NoSuchKey.new(nil, 'The specified key does not exist.'))
22+
.raises(Aws::S3::Errors::NoSuchKey.new(nil, "The specified key does not exist."))
2323

2424
get "#{route_prefix}/#{unknown_file}"
2525
assert_response :missing

src/app/server/test/test_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
ENV["RAILS_ENV"] ||= "test"
22
require_relative "../config/environment"
33
require "rails/test_help"
4-
require 'mocha/minitest'
4+
require "mocha/minitest"
55

66
module ActiveSupport
77
class TestCase

0 commit comments

Comments
 (0)