rails 4.2: api spec fixes
refs #CNVS-26056 Change-Id: I082e29c642b9150260f6571f0aa8ef397c6e2cca Reviewed-on: https://gerrit.instructure.com/70593 Reviewed-by: Cody Cutrer <cody@instructure.com> Tested-by: Jenkins Product-Review: James Williams <jamesw@instructure.com> QA-Review: James Williams <jamesw@instructure.com>
This commit is contained in:
parent
64464bb39f
commit
5881701e8c
|
@ -817,7 +817,7 @@ class CoursesController < ApplicationController
|
|||
user_id = params[:user_id]
|
||||
if user_id.present? && user = users.where(:users => { :id => user_id }).first
|
||||
position_scope = users.where("#{User.sortable_name_order_by_clause}<=#{User.best_unicode_collation_key('?')}", user.sortable_name)
|
||||
position = position_scope.count(:select => "users.id", :distinct => true)
|
||||
position = position_scope.uniq.count(:all)
|
||||
per_page = Api.per_page_for(self)
|
||||
params[:page] = (position.to_f / per_page.to_f).ceil
|
||||
end
|
||||
|
|
|
@ -379,7 +379,7 @@ class DiscussionTopicsApiController < ApplicationController
|
|||
# ]
|
||||
def entry_list
|
||||
ids = Array(params[:ids])
|
||||
entries = @topic.discussion_entries.find(ids, :order => :id)
|
||||
entries = @topic.discussion_entries.order(:id).find(ids)
|
||||
@entries = Api.paginate(entries, self, entry_pagination_url(@topic))
|
||||
render :json => discussion_entry_api_json(@entries, @context, @current_user, session, [])
|
||||
end
|
||||
|
|
|
@ -160,7 +160,7 @@ class LtiApiController < ApplicationController
|
|||
timestamp = Time.zone.at(@signature.request.timestamp.to_i)
|
||||
# 90 minutes is suggested by the LTI spec
|
||||
allowed_delta = Setting.get('oauth.allowed_timestamp_delta', 90.minutes.to_s).to_i
|
||||
if timestamp < allowed_delta.seconds.ago || timestamp > allowed_delta.from_now
|
||||
if timestamp < allowed_delta.seconds.ago || timestamp > allowed_delta.seconds.from_now
|
||||
Canvas::Errors::Reporter.raise_canvas_error(BasicLTI::BasicOutcomes::Unauthorized, "Timestamp too old or too far in the future, request has expired", oauth_error_info)
|
||||
end
|
||||
|
||||
|
|
|
@ -260,7 +260,7 @@ class Quizzes::QuizSubmission < ActiveRecord::Base
|
|||
|
||||
self.class.where(id: self).
|
||||
where("workflow_state NOT IN ('complete', 'pending_review')").
|
||||
update_all(user_id: user_id, submission_data: new_params.to_yaml)
|
||||
update_all(user_id: user_id, submission_data: CANVAS_RAILS4_0 ? new_params.to_yaml : new_params)
|
||||
|
||||
record_answer(new_params)
|
||||
|
||||
|
|
|
@ -93,6 +93,7 @@ module CanvasRails
|
|||
unless CANVAS_RAILS4_0
|
||||
config.active_record.raise_in_transactional_callbacks = true # may as well opt into the new behavior
|
||||
end
|
||||
config.active_support.encode_big_decimal_as_string = false
|
||||
|
||||
config.autoload_paths += %W(#{Rails.root}/app/middleware
|
||||
#{Rails.root}/app/observers
|
||||
|
|
|
@ -1,26 +1,6 @@
|
|||
if CANVAS_RAILS4_0
|
||||
ActiveSupport::JSON.backend = :oj
|
||||
MultiJson.dump_options = {:escape_mode => :xss_safe}
|
||||
|
||||
# Rails4 gives an option to opt out of encoding BigDecimal json as a string
|
||||
if ActiveSupport.respond_to?(:encode_big_decimal_as_string)
|
||||
ActiveSupport.encode_big_decimal_as_string = false
|
||||
|
||||
# Rails3 changes BigDecimal #to_json to encode as a string. This breaks
|
||||
# bw-compat in our apis, so this switches it back to the native behavior.
|
||||
else
|
||||
require 'bigdecimal'
|
||||
|
||||
class BigDecimal
|
||||
def as_json(options = nil)
|
||||
if finite?
|
||||
self
|
||||
else
|
||||
NilClass::AS_JSON
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
require 'json/jwt'
|
||||
require 'oj_mimic_json' # have to load after json/jwt or else the oj_mimic_json will make it never load
|
||||
|
|
|
@ -430,8 +430,9 @@ module Api
|
|||
|
||||
def resolve_placeholders(content)
|
||||
host, protocol = get_host_and_protocol_from_request
|
||||
# content is a json-encoded string; slashes are escaped
|
||||
content.gsub("#{PLACEHOLDER_PROTOCOL}:\\/\\/#{PLACEHOLDER_HOST}", "#{protocol}:\\/\\/#{host}")
|
||||
# content is a json-encoded string; slashes are escaped (at least in Rails 4.0)
|
||||
content.gsub("#{PLACEHOLDER_PROTOCOL}:\\/\\/#{PLACEHOLDER_HOST}", "#{protocol}:\\/\\/#{host}").
|
||||
gsub("#{PLACEHOLDER_PROTOCOL}://#{PLACEHOLDER_HOST}", "#{protocol}://#{host}")
|
||||
end
|
||||
|
||||
def user_can_download_attachment?(attachment, context, user)
|
||||
|
|
|
@ -46,7 +46,7 @@ module Api::V1::Conversation
|
|||
unless interleave_submissions
|
||||
result['message_count'] = result[:submissions] ?
|
||||
result['message_count'] - result[:submissions].size :
|
||||
conversation.messages.human.where(:asset_id => nil).count
|
||||
conversation.messages.human.where(:asset_id => nil).count(:all)
|
||||
end
|
||||
result[:audience] = audience.map(&:id)
|
||||
result[:audience].map!(&:to_s) if stringify_json_ids?
|
||||
|
|
|
@ -52,7 +52,7 @@ module Api::V1::GroupCategory
|
|||
hash['groups_count'] = group_category.groups.active.size
|
||||
end
|
||||
if includes.include?('unassigned_users_count')
|
||||
hash['unassigned_users_count'] = group_category.unassigned_users.count
|
||||
hash['unassigned_users_count'] = group_category.unassigned_users.count(:all)
|
||||
end
|
||||
end
|
||||
hash
|
||||
|
|
|
@ -30,7 +30,7 @@ module Api::V1::QuizSubmissionQuestion
|
|||
# @param [Boolean] meta[:censored] if answer correctness should be censored out
|
||||
def quiz_submission_questions_json(quiz_questions, quiz_submission, meta = {})
|
||||
meta[:censored] ||= true
|
||||
quiz_questions = [ quiz_questions ] unless quiz_questions.kind_of?(Array)
|
||||
quiz_questions = Array(quiz_questions) unless quiz_questions.kind_of?(Array)
|
||||
includes = (meta[:includes] || []) & INCLUDABLES
|
||||
|
||||
data = {}
|
||||
|
|
|
@ -202,7 +202,7 @@ describe "API Authentication", type: :request do
|
|||
Onelogin::Saml::Response.any_instance.stubs(:issuer).returns("saml_entity")
|
||||
Onelogin::Saml::Response.any_instance.stubs(:trusted_roots).returns([])
|
||||
|
||||
post 'saml_consume', :SAMLResponse => "foo"
|
||||
post '/saml_consume', :SAMLResponse => "foo"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -48,12 +48,12 @@ module Lti
|
|||
end
|
||||
|
||||
it 'the tool proxy raw data' do
|
||||
get "api/lti/tool_proxy/#{tool_proxy.guid}", tool_proxy_guid: tool_proxy.guid
|
||||
get "/api/lti/tool_proxy/#{tool_proxy.guid}", tool_proxy_guid: tool_proxy.guid
|
||||
expect(JSON.parse(body)).to eq tool_proxy.raw_data
|
||||
end
|
||||
|
||||
it 'has the correct content-type' do
|
||||
get "api/lti/tool_proxy/#{tool_proxy.guid}", tool_proxy_guid: tool_proxy.guid
|
||||
get "/api/lti/tool_proxy/#{tool_proxy.guid}", tool_proxy_guid: tool_proxy.guid
|
||||
expect(response.headers['Content-Type']).to include 'application/vnd.ims.lti.v2.toolproxy+json'
|
||||
end
|
||||
|
||||
|
|
|
@ -113,7 +113,7 @@ describe "Conferences API", type: :request do
|
|||
let(:course_id) { conference.context.id }
|
||||
|
||||
let(:path) do
|
||||
"api/v1/courses/#{course_id}/conferences/#{conference.id}/recording_ready"
|
||||
"/api/v1/courses/#{course_id}/conferences/#{conference.id}/recording_ready"
|
||||
end
|
||||
|
||||
let(:params) do
|
||||
|
|
|
@ -30,7 +30,7 @@ describe "Group Categories API", type: :request do
|
|||
"#{category.context_type.downcase}_id" => category.context_id,
|
||||
'group_limit' => category.group_limit,
|
||||
'groups_count' => category.groups.size,
|
||||
'unassigned_users_count' => category.unassigned_users.count,
|
||||
'unassigned_users_count' => category.unassigned_users.count(:all),
|
||||
'protected' => false,
|
||||
'allows_multiple_memberships' => false,
|
||||
'auto_leader' => category.auto_leader,
|
||||
|
|
|
@ -547,7 +547,6 @@ describe Quizzes::QuizSubmissionsApiController, type: :request do
|
|||
question_data: true_false_question_data
|
||||
})
|
||||
|
||||
@quiz.quiz_data = [ @qq1.question_data, @qq2.question_data ]
|
||||
@quiz.generate_quiz_data
|
||||
|
||||
enroll_student_and_submit({
|
||||
|
|
Loading…
Reference in New Issue