rails 6: fixes for API specs
Change-Id: I3ac07e45861aecaca50f82dbb7dccf169bc11edc Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/250566 Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Reviewed-by: Simon Williams <simon@instructure.com> QA-Review: Simon Williams <simon@instructure.com> Product-Review: Simon Williams <simon@instructure.com>
This commit is contained in:
parent
d6e4c5ef69
commit
d52d6968c2
|
@ -141,7 +141,7 @@ module Lti
|
|||
# Course
|
||||
}
|
||||
end
|
||||
render_unauthorized_action unless codes && tool_proxy.matches?(codes)
|
||||
render_unauthorized_action unless codes && tool_proxy.matches?(**codes)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -300,7 +300,7 @@ class OutcomesApiController < ApplicationController
|
|||
joins("INNER JOIN #{Assignment.quoted_table_name} assignments ON assignments.id = content_tags.content_id AND content_tags.content_type = 'Assignment'").
|
||||
joins("INNER JOIN #{Submission.quoted_table_name} submissions ON submissions.assignment_id = assignments.id AND submissions.user_id = #{student_id} AND submissions.workflow_state <> 'deleted'").
|
||||
where('assignments.workflow_state NOT IN (?)', assignment_states).
|
||||
to_sql).to_hash
|
||||
to_sql).to_a
|
||||
alignments.each{|a| a[:url] = "#{polymorphic_url([course, :assignments])}/#{a['assignment_id']}"}
|
||||
|
||||
quizzes = Quizzes::Quiz.active
|
||||
|
|
|
@ -491,7 +491,7 @@ class SubmissionsApiController < ApplicationController
|
|||
ActiveRecord::Associations::Preloader.new.preload(
|
||||
submissions,
|
||||
:submission_comments,
|
||||
{select: [:hidden, :submission_id]}
|
||||
SubmissionComment.select(:hidden, :submission_id)
|
||||
)
|
||||
|
||||
bulk_load_attachments_and_previews(submissions)
|
||||
|
|
|
@ -1404,10 +1404,10 @@ class Submission < ActiveRecord::Base
|
|||
|
||||
def check_for_media_object
|
||||
if self.media_comment_id.present? && self.saved_change_to_media_comment_id?
|
||||
MediaObject.ensure_media_object(self.media_comment_id, {
|
||||
:user => self.user,
|
||||
:context => self.user,
|
||||
})
|
||||
MediaObject.ensure_media_object(self.media_comment_id,
|
||||
user: self.user,
|
||||
context: self.user,
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -214,7 +214,7 @@ module Api::V1::OutcomeResults
|
|||
|
||||
def outcome_results_rollups_csv(current_user, context, rollups, outcomes, outcome_paths)
|
||||
options = CsvWithI18n.csv_i18n_settings(current_user)
|
||||
CsvWithI18n.generate(options) do |csv|
|
||||
CsvWithI18n.generate(**options) do |csv|
|
||||
row = []
|
||||
row << I18n.t(:student_name, 'Student name')
|
||||
row << I18n.t(:student_id, 'Student ID')
|
||||
|
|
|
@ -32,7 +32,7 @@ module Lti
|
|||
get "/api/lti/accounts/#{account.id}/tool_consumer_profile/#{tool_consumer_profile_id}",
|
||||
params: {tool_consumer_profile_id: tool_consumer_profile_id,
|
||||
account_id: account.id}
|
||||
expect(response.content_type.to_s).to eq 'application/vnd.ims.lti.v2.toolconsumerprofile+json'
|
||||
expect(response.media_type.to_s).to eq 'application/vnd.ims.lti.v2.toolconsumerprofile+json'
|
||||
end
|
||||
|
||||
it 'returns the consumer profile JSON' do
|
||||
|
|
|
@ -57,13 +57,13 @@ module Lti
|
|||
get "/api/lti/tool_settings/#{@link_setting.id}.json",
|
||||
params: {tool_setting_id: @link_setting},
|
||||
headers: {'HTTP_ACCEPT' => 'application/vnd.ims.lti.v2.toolsettings.simple+json', 'Authorization' => "bearer #{access_token}"}
|
||||
expect(response.content_type).to eq 'application/vnd.ims.lti.v2.toolsettings.simple+json'
|
||||
expect(response.media_type).to eq 'application/vnd.ims.lti.v2.toolsettings.simple+json'
|
||||
end
|
||||
|
||||
it 'returns toolsettings when requested' do
|
||||
get "/api/lti/tool_settings/#{@link_setting.id}.json", params: {tool_setting_id: @link_setting},
|
||||
headers: {'HTTP_ACCEPT' => 'application/vnd.ims.lti.v2.toolsettings+json', 'Authorization' => 'oauth_token'}
|
||||
expect(response.content_type).to eq 'application/vnd.ims.lti.v2.toolsettings+json'
|
||||
expect(response.media_type).to eq 'application/vnd.ims.lti.v2.toolsettings+json'
|
||||
end
|
||||
|
||||
it 'returns not_found if there isn\'t a tool setting' do
|
||||
|
|
|
@ -149,7 +149,7 @@ module Lti
|
|||
|
||||
it "requires the plagiarism feature flag" do
|
||||
post @endpoints[:show]
|
||||
expect(response).not_to be_success
|
||||
expect(response).not_to be_successful
|
||||
end
|
||||
|
||||
it "verifies the specified attachment is in the course" do
|
||||
|
@ -239,7 +239,7 @@ module Lti
|
|||
|
||||
it "requires the plagiarism feature flag" do
|
||||
post @endpoints[:alt_show]
|
||||
expect(response).not_to be_success
|
||||
expect(response).not_to be_successful
|
||||
end
|
||||
|
||||
it "verifies the specified attachment is in the course" do
|
||||
|
@ -411,7 +411,7 @@ module Lti
|
|||
it "requires the plagiarism feature flag" do
|
||||
|
||||
put @endpoints[:udpate], params: {originality_report: {originality_report_lti_url: "http://www.lti-test.com"}}, headers: request_headers
|
||||
expect(response).not_to be_success
|
||||
expect(response).not_to be_successful
|
||||
end
|
||||
|
||||
it "verifies the report is in the same context as the assignment" do
|
||||
|
@ -554,7 +554,7 @@ module Lti
|
|||
|
||||
it "requires the plagiarism feature flag" do
|
||||
put @endpoints[:udpate], params: {originality_report: {originality_report_lti_url: "http://www.lti-test.com"}}, headers: request_headers
|
||||
expect(response).not_to be_success
|
||||
expect(response).not_to be_successful
|
||||
end
|
||||
|
||||
it "verifies the report is in the same context as the assignment" do
|
||||
|
@ -677,12 +677,12 @@ module Lti
|
|||
it "checks that the specified assignment exists" do
|
||||
invalid_attach_url = "/api/lti/assignments/#{@assignment.id + 1}/submissions/#{@submission.id}/originality_report"
|
||||
post invalid_attach_url, params: {originality_report: {file_id: @attachment.id, originality_score: 0.4}}
|
||||
expect(response).not_to be_success
|
||||
expect(response).not_to be_successful
|
||||
end
|
||||
|
||||
it "checks that the specified file exists" do
|
||||
post @endpoints[:create], params: {originality_report: {file_id: @attachment.id + 1, originality_score: 0.4}}, headers: request_headers
|
||||
expect(response).not_to be_success
|
||||
expect(response).not_to be_successful
|
||||
end
|
||||
|
||||
it "requires the tool proxy to be associated to the assignment" do
|
||||
|
|
|
@ -244,7 +244,7 @@ module Lti
|
|||
json = JSON.parse(response.body)
|
||||
url = json["attachments"].first["url"]
|
||||
get url, headers: request_headers
|
||||
expect(response.content_type.to_s).to eq attachment.content_type
|
||||
expect(response.media_type.to_s).to eq attachment.content_type
|
||||
end
|
||||
|
||||
it "returns a 401 if the attachment isn't associated to the assignment" do
|
||||
|
|
|
@ -133,7 +133,7 @@ module Lti
|
|||
it 'gives 404 if subscription does not exist' do
|
||||
allow(subscription_service).to receive_messages(destroy_tool_proxy_subscription: not_found_response)
|
||||
delete delete_endpoint, headers: request_headers
|
||||
expect(response).not_to be_success
|
||||
expect(response).not_to be_successful
|
||||
end
|
||||
|
||||
it 'requires JWT Access token' do
|
||||
|
@ -171,7 +171,7 @@ module Lti
|
|||
it 'gives gives 404 if subscription does not exist' do
|
||||
allow(subscription_service).to receive_messages(destroy_tool_proxy_subscription: not_found_response)
|
||||
get show_endpoint, headers: request_headers
|
||||
expect(response).not_to be_success
|
||||
expect(response).not_to be_successful
|
||||
end
|
||||
|
||||
it 'requires JWT Access token' do
|
||||
|
|
|
@ -93,7 +93,7 @@ describe Quizzes::QuizSubmissionUsersController, type: :request do
|
|||
it "does not allow students to view information at the endpoint" do
|
||||
@user = @student1
|
||||
get_submitted_users
|
||||
expect(response).not_to be_success
|
||||
expect(response).not_to be_successful
|
||||
end
|
||||
|
||||
it "allows teachers to see submitted students with ?submitted=true" do
|
||||
|
|
|
@ -277,7 +277,7 @@ describe "Rubrics API", type: :request do
|
|||
it "returns an error if passed an invalid argument" do
|
||||
raw_rubric_call(@course, {include: "cheez"})
|
||||
|
||||
expect(response).not_to be_success
|
||||
expect(response).not_to be_successful
|
||||
json = JSON.parse response.body
|
||||
expect(json["errors"]["include"].first["message"]).to start_with "invalid include value requested. Must be one of the following:"
|
||||
end
|
||||
|
@ -285,13 +285,13 @@ describe "Rubrics API", type: :request do
|
|||
it "returns an error if passed mutually-exclusive include options" do
|
||||
raw_rubric_call(@course, {include: ["assessments", "peer_assessments"]})
|
||||
|
||||
expect(response).not_to be_success
|
||||
expect(response).not_to be_successful
|
||||
json = JSON.parse response.body
|
||||
expect(json["errors"]["include"].first["message"]).to start_with "cannot list multiple assessment includes."
|
||||
|
||||
raw_rubric_call(@course, {include: ["associations", "assignment_associations"]})
|
||||
|
||||
expect(response).not_to be_success
|
||||
expect(response).not_to be_successful
|
||||
json = JSON.parse response.body
|
||||
expect(json["errors"]["include"].first["message"]).to start_with "cannot list multiple association includes."
|
||||
end
|
||||
|
@ -310,7 +310,7 @@ describe "Rubrics API", type: :request do
|
|||
it "returns an error if passed an invalid argument" do
|
||||
raw_rubric_call(@course, {include: "assessments", style: "BigMcLargeHuge"})
|
||||
|
||||
expect(response).not_to be_success
|
||||
expect(response).not_to be_successful
|
||||
json = JSON.parse response.body
|
||||
expect(json["errors"]["style"].first["message"]).to eq "invalid style requested. Must be one of the following: full, comments_only"
|
||||
end
|
||||
|
@ -318,7 +318,7 @@ describe "Rubrics API", type: :request do
|
|||
it "returns an error if passed a style parameter without assessments" do
|
||||
raw_rubric_call(@course, {style: "full"})
|
||||
|
||||
expect(response).not_to be_success
|
||||
expect(response).not_to be_successful
|
||||
json = JSON.parse response.body
|
||||
expect(json["errors"]["style"].first["message"]).to eq "invalid parameters. Style parameter passed without requesting assessments"
|
||||
end
|
||||
|
@ -524,7 +524,7 @@ describe "Rubrics API", type: :request do
|
|||
it "returns an error if passed an invalid argument" do
|
||||
raw_rubric_call(@account, {include: "cheez"}, 'account')
|
||||
|
||||
expect(response).not_to be_success
|
||||
expect(response).not_to be_successful
|
||||
json = JSON.parse response.body
|
||||
expect(json["errors"]["include"].first["message"]).to start_with "invalid include value requested. Must be one of the following:"
|
||||
end
|
||||
|
@ -532,13 +532,13 @@ describe "Rubrics API", type: :request do
|
|||
it "returns an error if passed mutually-exclusive include options" do
|
||||
raw_rubric_call(@account, {include: ["assessments", "peer_assessments"]}, 'account')
|
||||
|
||||
expect(response).not_to be_success
|
||||
expect(response).not_to be_successful
|
||||
json = JSON.parse response.body
|
||||
expect(json["errors"]["include"].first["message"]).to start_with "cannot list multiple assessment includes."
|
||||
|
||||
raw_rubric_call(@account, {include: ["associations", "assignment_associations"]}, 'account')
|
||||
|
||||
expect(response).not_to be_success
|
||||
expect(response).not_to be_successful
|
||||
json = JSON.parse response.body
|
||||
expect(json["errors"]["include"].first["message"]).to start_with "cannot list multiple association includes."
|
||||
end
|
||||
|
@ -561,7 +561,7 @@ describe "Rubrics API", type: :request do
|
|||
it "returns an error if passed an invalid argument" do
|
||||
raw_rubric_call(@account, {include: "assessments", style: "BigMcLargeHuge"}, 'account')
|
||||
|
||||
expect(response).not_to be_success
|
||||
expect(response).not_to be_successful
|
||||
json = JSON.parse response.body
|
||||
expect(json["errors"]["style"].first["message"]).to eq "invalid style requested. Must be one of the following: full, comments_only"
|
||||
end
|
||||
|
@ -569,7 +569,7 @@ describe "Rubrics API", type: :request do
|
|||
it "returns an error if passed a style parameter without assessments" do
|
||||
raw_rubric_call(@account, {style: "full"}, 'account')
|
||||
|
||||
expect(response).not_to be_success
|
||||
expect(response).not_to be_successful
|
||||
json = JSON.parse response.body
|
||||
expect(json["errors"]["style"].first["message"]).to eq "invalid parameters. Style parameter passed without requesting assessments"
|
||||
end
|
||||
|
|
|
@ -68,7 +68,7 @@ describe 'Submissions Comment API', type: :request do
|
|||
format: "json", course_id: @course.to_param,
|
||||
assignment_id: @assignment.to_param, user_id: @student.to_param},
|
||||
name: "whatever"
|
||||
expect(response).not_to be_success
|
||||
expect(response).not_to be_successful
|
||||
end
|
||||
|
||||
it "creates an attachment with the right the user_id" do
|
||||
|
|
|
@ -22,7 +22,7 @@ describe UsersController, type: :request do
|
|||
include Api
|
||||
|
||||
before(:once) do
|
||||
Account.find_or_create_by!(id: 0).update_attributes(name: 'Dummy Root Account', workflow_state: 'deleted', root_account_id: nil)
|
||||
Account.find_or_create_by!(id: 0).update(name: 'Dummy Root Account', workflow_state: 'deleted', root_account_id: nil)
|
||||
end
|
||||
|
||||
context "without current_user" do
|
||||
|
|
|
@ -58,7 +58,7 @@ RSpec.shared_examples 'a provisional grades status action' do |controller|
|
|||
it 'is authorized when the user is an admin with permission to select final grade' do
|
||||
admin = account_admin_user(account: @course.account)
|
||||
api_call_as_user(admin, :get, @path, @params.merge(last_updated_at: 1.day.ago(@submission.updated_at)), {}, {})
|
||||
expect(response).to be_success
|
||||
expect(response).to be_successful
|
||||
end
|
||||
|
||||
it 'is unauthorized when the user is an admin without permission to select final grade' do
|
||||
|
|
Loading…
Reference in New Issue