Skip to content

Commit 5288907

Browse files
committed
rubocop -a
1 parent 47db5e8 commit 5288907

16 files changed

Lines changed: 63 additions & 63 deletions

app/controllers/api/v1/assignments_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module V1
33
class AssignmentsController < ApplicationController
44
include CanvasValidationHelper
55

6-
before_action :validate_ids!, only: [:create]
6+
before_action :validate_ids!, only: [ :create ]
77
skip_before_action :verify_authenticity_token
88

99
def index

app/controllers/api/v1/lmss_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module API
22
module V1
33
class LmssController < BaseController
44
include CanvasValidationHelper
5-
before_action :validate_ids!, only: [:create]
5+
before_action :validate_ids!, only: [ :create ]
66

77
def index
88
render json: { message: 'not yet implemented' }, status: :not_implemented

app/controllers/application_controller.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ class ApplicationController < ActionController::Base
66
def excluded_controller_action?
77
# Actions and controllers that do NOT require authentication
88
excluded_actions = {
9-
'home' => ['index'],
10-
'login' => ['canvas'],
9+
'home' => [ 'index' ],
10+
'login' => [ 'canvas' ],
1111
'session' => %w[create omniauth_callback omniauth_failure],
12-
'rails/health' => ['show'],
13-
'requests' => ['export']
12+
'rails/health' => [ 'show' ],
13+
'requests' => [ 'export' ]
1414
}
1515
controller = params[:controller]
1616
action = params[:action]

app/controllers/courses_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ def show
3333

3434
@assignments = if @role == 'student'
3535
Assignment.where(course_to_lms_id: course_to_lms.id, enabled: true).order(:name)
36-
else
36+
else
3737
Assignment.where(course_to_lms_id: course_to_lms.id).order(:name)
38-
end
38+
end
3939
render_role_based_view
4040
end
4141

app/controllers/requests_controller.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
require 'csv'
22

33
class RequestsController < ApplicationController
4-
before_action :authenticate_user, except: [:export]
5-
before_action :set_course_role_from_settings, except: [:export]
6-
before_action :authenticate_course, except: [:export]
7-
before_action :set_pending_request_count, except: [:export]
8-
before_action :check_extensions_enabled_for_students, except: [:export]
4+
before_action :authenticate_user, except: [ :export ]
5+
before_action :set_course_role_from_settings, except: [ :export ]
6+
before_action :authenticate_course, except: [ :export ]
7+
before_action :set_pending_request_count, except: [ :export ]
8+
before_action :check_extensions_enabled_for_students, except: [ :export ]
99
before_action :ensure_request_is_pending, only: %i[update approve reject]
1010
before_action :set_request, only: %i[show edit cancel]
1111
before_action :check_instructor_permission, only: %i[approve reject]
@@ -14,9 +14,9 @@ def index
1414
@side_nav = 'requests'
1515
@requests = if params[:show_all] == 'true'
1616
@role == 'student' ? @course.requests.for_user(@user) : @course.requests.includes(:assignment)
17-
else
17+
else
1818
@role == 'student' ? @course.requests.for_user(@user) : @course.requests.includes(:assignment).where(status: 'pending')
19-
end
19+
end
2020

2121
# Pass the search query to the view
2222
@search_query = params[:search]
@@ -62,7 +62,7 @@ def new_for_student
6262

6363
def edit
6464
@selected_assignment = @request.assignment
65-
@assignments = [@selected_assignment]
65+
@assignments = [ @selected_assignment ]
6666
end
6767

6868
def create

app/facades/canvas_facade.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ def delete_assignment_override(courseId, assignmentId, overrideId)
286286
def provision_extension(courseId, studentId, assignmentId, newDueDate)
287287
overrideTitle = "#{studentId} extended to #{newDueDate}"
288288
create_response = create_assignment_override(
289-
courseId, assignmentId, [studentId], overrideTitle, newDueDate, get_current_formatted_time, newDueDate
289+
courseId, assignmentId, [ studentId ], overrideTitle, newDueDate, get_current_formatted_time, newDueDate
290290
)
291291
return create_response if create_response.status != 400
292292

@@ -423,7 +423,7 @@ def handle_override_logic(courseId, curr_override, studentId, assignmentId, over
423423
else
424424
remove_student_from_override(courseId, curr_override, studentId)
425425
create_assignment_override(
426-
courseId, assignmentId, [studentId], overrideTitle, newDueDate, get_current_formatted_time, newDueDate
426+
courseId, assignmentId, [ studentId ], overrideTitle, newDueDate, get_current_formatted_time, newDueDate
427427
)
428428
end
429429
end

app/models/request.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ def send_email_response
196196
end
197197

198198
def self.to_csv(requests)
199-
headers = ['Assignment', 'Student Name', 'Student ID', 'Requested At', 'Original Due Date', 'Requested Due Date', 'Status']
199+
headers = [ 'Assignment', 'Student Name', 'Student ID', 'Requested At', 'Original Due Date', 'Requested Due Date', 'Status' ]
200200
CSV.generate(headers: true) do |csv|
201201
csv << headers
202202
requests.find_each do |request|
@@ -229,7 +229,7 @@ def delete_override(canvas_facade, override_id)
229229

230230
def create_override(canvas_facade)
231231
canvas_facade.create_assignment_override(
232-
course.canvas_id, assignment.external_assignment_id, [user.canvas_uid], "Extension for #{user.name}",
232+
course.canvas_id, assignment.external_assignment_id, [ user.canvas_uid ], "Extension for #{user.name}",
233233
requested_due_date.iso8601, nil, nil
234234
)
235235
end

lib/tasks/cucumber.rake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ unless ARGV.any? { |a| a =~ /^gems/ } # Don't load anything when running the gem
3737

3838
task statsetup: :environment do
3939
require 'rails/code_statistics'
40-
STATS_DIRECTORIES << ['Cucumber features', 'features'] if File.exist?('features')
40+
STATS_DIRECTORIES << [ 'Cucumber features', 'features' ] if File.exist?('features')
4141
CodeStatistics::TEST_TYPES << 'Cucumber features' if File.exist?('features')
4242
end
4343
end

spec/Facades/canvas_facade_spec.rb

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
due_at: mockDate,
2121
unlock_at: mockDate,
2222
lock_at: mockDate,
23-
student_ids: [mockStudentId]
23+
student_ids: [ mockStudentId ]
2424
}
2525
end
2626

@@ -56,7 +56,7 @@
5656
# other methods need to be refactors too.
5757
describe 'get_all_courses' do
5858
before do
59-
stubs.get('courses') { [200, {}, '[]'] }
59+
stubs.get('courses') { [ 200, {}, '[]' ] }
6060
end
6161

6262
it 'has correct response body on successful call' do
@@ -67,7 +67,7 @@
6767

6868
describe 'get_course' do
6969
before do
70-
stubs.get("courses/#{mockCourseId}") { [200, {}, '{}'] }
70+
stubs.get("courses/#{mockCourseId}") { [ 200, {}, '{}' ] }
7171
end
7272

7373
it 'has correct response body on successful call' do
@@ -78,7 +78,7 @@
7878

7979
describe('get_assignments') do
8080
before do
81-
stubs.get("courses/#{mockCourseId}/assignments") { [200, {}, '{}'] }
81+
stubs.get("courses/#{mockCourseId}/assignments") { [ 200, {}, '{}' ] }
8282
end
8383

8484
it 'has correct response body on successful call' do
@@ -89,7 +89,7 @@
8989

9090
describe('get_assignment') do
9191
before do
92-
stubs.get("courses/#{mockCourseId}/assignments/#{mockAssignmentId}") { [200, {}, '{}'] }
92+
stubs.get("courses/#{mockCourseId}/assignments/#{mockAssignmentId}") { [ 200, {}, '{}' ] }
9393
end
9494

9595
it 'has correct response body on successful call' do
@@ -102,7 +102,7 @@
102102
before do
103103
stubs.get(
104104
"courses/#{mockCourseId}/assignments/#{mockAssignmentId}/overrides"
105-
) { [200, {}, '{}'] }
105+
) { [ 200, {}, '{}' ] }
106106
end
107107

108108
it 'has correct response body on successful call' do
@@ -117,14 +117,14 @@
117117
before do
118118
stubs.post(
119119
createAssignmentOverrideUrl
120-
) { [200, {}, '{}'] }
120+
) { [ 200, {}, '{}' ] }
121121
end
122122

123123
it 'has correct request body' do
124124
expect(conn).to receive(:post).with(
125125
createAssignmentOverrideUrl,
126126
{ assignment_override: {
127-
student_ids: [mockStudentId],
127+
student_ids: [ mockStudentId ],
128128
title: mockTitle,
129129
due_at: mockDate,
130130
unlock_at: mockDate,
@@ -135,7 +135,7 @@
135135
facade.create_assignment_override(
136136
mockCourseId,
137137
mockAssignmentId,
138-
[mockStudentId],
138+
[ mockStudentId ],
139139
mockTitle,
140140
mockDate,
141141
mockDate,
@@ -147,7 +147,7 @@
147147
expect(facade.create_assignment_override(
148148
mockCourseId,
149149
mockAssignmentId,
150-
[mockStudentId],
150+
[ mockStudentId ],
151151
mockTitle,
152152
mockDate,
153153
mockDate,
@@ -165,14 +165,14 @@
165165
before do
166166
stubs.put(
167167
updateAssignmentOverrideUrl
168-
) { [200, {}, '{}'] }
168+
) { [ 200, {}, '{}' ] }
169169
end
170170

171171
it 'has correct request body' do
172172
expect(conn).to receive(:put).with(
173173
updateAssignmentOverrideUrl,
174174
{
175-
student_ids: [mockStudentId],
175+
student_ids: [ mockStudentId ],
176176
title: mockTitle,
177177
due_at: mockDate,
178178
unlock_at: mockDate,
@@ -184,7 +184,7 @@
184184
mockCourseId,
185185
mockAssignmentId,
186186
mockOverrideId,
187-
[mockStudentId],
187+
[ mockStudentId ],
188188
mockTitle,
189189
mockDate,
190190
mockDate,
@@ -197,7 +197,7 @@
197197
mockCourseId,
198198
mockAssignmentId,
199199
mockOverrideId,
200-
[mockStudentId],
200+
[ mockStudentId ],
201201
mockTitle,
202202
mockDate,
203203
mockDate,
@@ -211,7 +211,7 @@
211211
before do
212212
stubs.delete(
213213
"courses/#{mockCourseId}/assignments/#{mockAssignmentId}/overrides/#{mockOverrideId}"
214-
) { [200, {}, '{}'] }
214+
) { [ 200, {}, '{}' ] }
215215
end
216216

217217
it 'has correct response body on successful call' do
@@ -230,11 +230,11 @@
230230
[
231231
400,
232232
{},
233-
{ errors: { assignment_override_students: [{
233+
{ errors: { assignment_override_students: [ {
234234
attribute: 'assignment_override_students',
235235
type: 'taken',
236236
message: 'already belongs to an assignment override'
237-
}] } }.to_json
237+
} ] } }.to_json
238238
]
239239
end
240240

@@ -243,7 +243,7 @@
243243
end
244244

245245
it 'returns correct response body on successful creation' do
246-
stubs.post(mockOverrideCreationUrl) { [200, {}, '{}'] }
246+
stubs.post(mockOverrideCreationUrl) { [ 200, {}, '{}' ] }
247247
expect(facade.provision_extension(
248248
mockCourseId,
249249
mockStudentId,
@@ -253,7 +253,7 @@
253253
end
254254

255255
it 'throws a pipeline error if the creation response body is improperly formatted' do
256-
stubs.post(mockOverrideCreationUrl) { [400, {}, '{invalid json}'] }
256+
stubs.post(mockOverrideCreationUrl) { [ 400, {}, '{invalid json}' ] }
257257
expect do
258258
facade.provision_extension(
259259
mockCourseId,
@@ -321,7 +321,7 @@
321321
let(:getAssignmentOverridesUrl) { "courses/#{mockCourseId}/assignments/#{mockAssignmentId}/overrides" }
322322

323323
it 'throws an error if the overrides response body cannot be parsed' do
324-
stubs.get(getAssignmentOverridesUrl) { [200, {}, '{invalid json}'] }
324+
stubs.get(getAssignmentOverridesUrl) { [ 200, {}, '{invalid json}' ] }
325325
expect do
326326
facade.send(
327327
:get_existing_student_override,
@@ -334,12 +334,12 @@
334334

335335
it 'returns the override that the student is listed in' do
336336
mockOverrideWithoutStudent = mockOverride.clone
337-
mockOverrideWithoutStudent[:student_ids] = [mockStudentId + 1]
337+
mockOverrideWithoutStudent[:student_ids] = [ mockStudentId + 1 ]
338338
stubs.get(getAssignmentOverridesUrl) do
339339
[
340340
200,
341341
{},
342-
[mockOverrideWithoutStudent, mockOverride].to_json
342+
[ mockOverrideWithoutStudent, mockOverride ].to_json
343343
]
344344
end
345345
expect(facade.send(
@@ -351,7 +351,7 @@
351351
end
352352

353353
it 'returns nil if no override for that student is found' do
354-
mockOverride[:student_ids] = [mockStudentId + 1]
354+
mockOverride[:student_ids] = [ mockStudentId + 1 ]
355355
stubs.get(getAssignmentOverridesUrl) do
356356
[
357357
200,
@@ -387,7 +387,7 @@
387387

388388
it 'removes the student and keeps everything else the same' do
389389
mockOverrideWithoutStudent = OpenStruct.new(mockOverride)
390-
mockOverrideWithoutStudent.student_ids = [mockStudentId + 1]
390+
mockOverrideWithoutStudent.student_ids = [ mockStudentId + 1 ]
391391
expect(facade).to receive(:update_assignment_override).with(
392392
mockCourseId,
393393
mockOverrideStruct.assignment_id,

spec/Helpers/canvas_validation_helper_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,19 +67,19 @@ class Helper
6767

6868
describe 'is_valid_student_ids' do
6969
it 'returns true on positive integral input' do
70-
expect(helper.is_valid_student_ids([16, 18])).to be(true)
70+
expect(helper.is_valid_student_ids([ 16, 18 ])).to be(true)
7171
end
7272

7373
it 'returns false on negative integer input' do
74-
expect(helper.is_valid_student_ids([-16, 16])).to be(false)
74+
expect(helper.is_valid_student_ids([ -16, 16 ])).to be(false)
7575
end
7676

7777
it 'returns false on boolean input' do
78-
expect(helper.is_valid_student_ids([16, 0.1])).to be(false)
78+
expect(helper.is_valid_student_ids([ 16, 0.1 ])).to be(false)
7979
end
8080

8181
it 'returns false on alphabetical input' do
82-
expect(helper.is_valid_student_ids(['abc', 16])).to be(false)
82+
expect(helper.is_valid_student_ids([ 'abc', 16 ])).to be(false)
8383
end
8484
end
8585

0 commit comments

Comments
 (0)