rails4: various api spec fixes
refs #CNVS-21596 Change-Id: Ib41c03782b1667d3876283fd99d8ccf7585e1fd6 Reviewed-on: https://gerrit.instructure.com/58651 Tested-by: Jenkins Reviewed-by: Cody Cutrer <cody@instructure.com> Product-Review: James Williams <jamesw@instructure.com> QA-Review: James Williams <jamesw@instructure.com>
This commit is contained in:
parent
04d0e70ca5
commit
5f9304f3e0
|
@ -789,9 +789,12 @@ class CoursesController < ApplicationController
|
|||
if includes.include?('enrollments')
|
||||
# not_ended_enrollments for enrollment_json
|
||||
# enrollments course for has_grade_permissions?
|
||||
ActiveRecord::Associations::Preloader.new(users,
|
||||
{ :not_ended_enrollments => :course },
|
||||
:conditions => ['enrollments.course_id = ?', @context.id]).run
|
||||
preload_scope = if CANVAS_RAILS3
|
||||
{:conditions => ['enrollments.course_id = ?', @context.id]}
|
||||
else
|
||||
Enrollment.where(:course_id => @context)
|
||||
end
|
||||
ActiveRecord::Associations::Preloader.new(users, { :not_ended_enrollments => :course }, preload_scope).run
|
||||
end
|
||||
render :json => users.map { |u|
|
||||
enrollments = u.not_ended_enrollments if includes.include?('enrollments')
|
||||
|
|
|
@ -333,7 +333,7 @@ class DiscussionTopicsApiController < ApplicationController
|
|||
# "created_at": "2011-11-03T21:26:44Z" } ]
|
||||
def replies
|
||||
@parent = root_entries(@topic).find(params[:entry_id])
|
||||
@replies = Api.paginate(reply_entries(@parent).newest_first, self, reply_pagination_url(@parent))
|
||||
@replies = Api.paginate(reply_entries(@parent).newest_first, self, reply_pagination_url(@topic, @parent))
|
||||
render :json => discussion_entry_api_json(@replies, @context, @current_user, session)
|
||||
end
|
||||
|
||||
|
|
|
@ -34,9 +34,9 @@ module Lti
|
|||
def tool_consumer_profile_url(uuid)
|
||||
case context
|
||||
when Course
|
||||
course_tool_consumer_profile_url(context)
|
||||
course_tool_consumer_profile_url(context, uuid)
|
||||
when Account
|
||||
account_tool_consumer_profile_url(context)
|
||||
account_tool_consumer_profile_url(context, uuid)
|
||||
else
|
||||
raise "Unsupported context"
|
||||
end
|
||||
|
|
|
@ -437,7 +437,7 @@ class Quizzes::QuizQuestionsController < ApplicationController
|
|||
end
|
||||
|
||||
def render_question_set(scope, quiz_data=nil)
|
||||
api_route = polymorphic_url([:api, :v1, @context, :quiz_questions])
|
||||
api_route = polymorphic_url([:api, :v1, @context, :quiz_questions], {:quiz_id => @quiz})
|
||||
questions = Api.paginate(scope, self, api_route)
|
||||
|
||||
render :json => questions_json(questions,
|
||||
|
|
|
@ -179,7 +179,7 @@ class SubmissionsApiController < ApplicationController
|
|||
if includes.include?("visibility") && @context.feature_enabled?(:differentiated_assignments)
|
||||
json = bulk_process_submissions_for_visibility(submissions, includes)
|
||||
else
|
||||
submissions = Api.paginate(submissions, self, api_v1_course_assignment_submissions_url(@context))
|
||||
submissions = Api.paginate(submissions, self, api_v1_course_assignment_submissions_url(@context, @assignment))
|
||||
bulk_load_attachments_and_previews(submissions)
|
||||
json = submissions.map { |s|
|
||||
s.visible_to_user = true
|
||||
|
|
|
@ -147,7 +147,7 @@ class WikiPagesApiController < ApplicationController
|
|||
# Retrieve the content of the front page
|
||||
#
|
||||
# @example_request
|
||||
# curl -H 'Authorization: Bearer <token>' \
|
||||
# curl -H 'Authorization: Bearer <token>' \
|
||||
# https://<canvas>/api/v1/courses/123/front_page
|
||||
#
|
||||
# @returns Page
|
||||
|
@ -210,7 +210,7 @@ class WikiPagesApiController < ApplicationController
|
|||
#
|
||||
#
|
||||
# @example_request
|
||||
# curl -H 'Authorization: Bearer <token>' \
|
||||
# curl -H 'Authorization: Bearer <token>' \
|
||||
# https://<canvas>/api/v1/courses/123/pages?sort=title&order=asc
|
||||
#
|
||||
# @returns [Page]
|
||||
|
@ -218,7 +218,7 @@ class WikiPagesApiController < ApplicationController
|
|||
if authorized_action(@context.wiki, @current_user, :read) && tab_enabled?(@context.class::TAB_PAGES)
|
||||
pages_route = polymorphic_url([:api_v1, @context, :wiki_pages])
|
||||
# omit body from selection, since it's not included in index results
|
||||
scope = @context.wiki.wiki_pages.select(WikiPage.column_names - ['body']).includes(:user)
|
||||
scope = @context.wiki.wiki_pages.select(WikiPage.column_names - ['body']).preload(:user)
|
||||
if params.has_key?(:published)
|
||||
scope = value_to_boolean(params[:published]) ? scope.published : scope.unpublished
|
||||
else
|
||||
|
@ -276,7 +276,7 @@ class WikiPagesApiController < ApplicationController
|
|||
# Set an unhidden page as the front page (if true)
|
||||
#
|
||||
# @example_request
|
||||
# curl -X POST -H 'Authorization: Bearer <token>' \
|
||||
# curl -X POST -H 'Authorization: Bearer <token>' \
|
||||
# https://<canvas>/api/v1/courses/123/pages \
|
||||
# -d wiki_page[title]=New+page
|
||||
# -d wiki_page[body]=New+body+text
|
||||
|
@ -305,7 +305,7 @@ class WikiPagesApiController < ApplicationController
|
|||
# Retrieve the content of a wiki page
|
||||
#
|
||||
# @example_request
|
||||
# curl -H 'Authorization: Bearer <token>' \
|
||||
# curl -H 'Authorization: Bearer <token>' \
|
||||
# https://<canvas>/api/v1/courses/123/pages/my-page-url
|
||||
#
|
||||
# @returns Page
|
||||
|
@ -315,7 +315,7 @@ class WikiPagesApiController < ApplicationController
|
|||
render :json => wiki_page_json(@page, @current_user, session)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# @API Update/create page
|
||||
#
|
||||
# Update the title or contents of a wiki page
|
||||
|
@ -346,7 +346,7 @@ class WikiPagesApiController < ApplicationController
|
|||
# Set an unhidden page as the front page (if true)
|
||||
#
|
||||
# @example_request
|
||||
# curl -X PUT -H 'Authorization: Bearer <token>' \
|
||||
# curl -X PUT -H 'Authorization: Bearer <token>' \
|
||||
# https://<canvas>/api/v1/courses/123/pages/the-page-url \
|
||||
# -d 'wiki_page[body]=Updated+body+text'
|
||||
#
|
||||
|
@ -376,7 +376,7 @@ class WikiPagesApiController < ApplicationController
|
|||
# Delete a wiki page
|
||||
#
|
||||
# @example_request
|
||||
# curl -X DELETE -H 'Authorization: Bearer <token>' \
|
||||
# curl -X DELETE -H 'Authorization: Bearer <token>' \
|
||||
# https://<canvas>/api/v1/courses/123/pages/the-page-url
|
||||
#
|
||||
# @returns Page
|
||||
|
@ -482,7 +482,7 @@ class WikiPagesApiController < ApplicationController
|
|||
def is_front_page_action?
|
||||
!!action_name.match(/_front_page$/)
|
||||
end
|
||||
|
||||
|
||||
def get_wiki_page
|
||||
@wiki = @context.wiki
|
||||
|
||||
|
@ -521,7 +521,7 @@ class WikiPagesApiController < ApplicationController
|
|||
@was_front_page = false
|
||||
@was_front_page = @page.is_front_page? if @page
|
||||
end
|
||||
|
||||
|
||||
def get_update_params(allowed_fields=Set[])
|
||||
# normalize parameters
|
||||
page_params = (params[:wiki_page] || {}).slice(*%w(title body notify_of_update published front_page editing_roles))
|
||||
|
|
|
@ -69,7 +69,13 @@ module SearchHelper
|
|||
|
||||
add_groups = lambda do |groups, group_context = nil|
|
||||
ActiveRecord::Associations::Preloader.new(groups, :group_category).run
|
||||
ActiveRecord::Associations::Preloader.new(groups, :group_memberships, conditions: { group_memberships: { user_id: @current_user }}).run
|
||||
preload_scope = if CANVAS_RAILS3
|
||||
{conditions: { group_memberships: { user_id: @current_user }}}
|
||||
else
|
||||
# Rails 4 uses a scope, not a hash
|
||||
GroupMembership.where(user_id: @current_user)
|
||||
end
|
||||
ActiveRecord::Associations::Preloader.new(groups, :group_memberships, preload_scope).run
|
||||
groups.each do |group|
|
||||
group.can_participate = true
|
||||
contexts[:groups][group.id] = {
|
||||
|
|
|
@ -45,6 +45,7 @@ class AccountAuthorizationConfig < ActiveRecord::Base
|
|||
# we have a lot of old data that didn't actually use STI,
|
||||
# so we shim it
|
||||
def self.find_sti_class(type_name)
|
||||
return self if type_name.blank? # super no longer does this in Rails 4
|
||||
case type_name
|
||||
when 'cas', 'ldap', 'saml'
|
||||
const_get(type_name.upcase)
|
||||
|
|
|
@ -170,7 +170,7 @@ class AssignmentOverride < ActiveRecord::Base
|
|||
true
|
||||
end
|
||||
|
||||
scope "overriding_#{field}", where("#{field}_overridden" => true)
|
||||
scope "overriding_#{field}", -> { where("#{field}_overridden" => true) }
|
||||
end
|
||||
|
||||
override :due_at
|
||||
|
|
|
@ -702,7 +702,7 @@ ActiveRecord::Relation.class_eval do
|
|||
old_proc = connection.raw_connection.set_notice_processor {}
|
||||
if pluck && pluck.any?{|p| p == primary_key.to_s}
|
||||
connection.add_index table, primary_key, name: index
|
||||
index = primary_key
|
||||
index = primary_key.to_s
|
||||
else
|
||||
pluck.unshift(index) if pluck
|
||||
connection.execute "ALTER TABLE #{table}
|
||||
|
@ -924,7 +924,7 @@ ActiveRecord::Relation.class_eval do
|
|||
def union(*scopes)
|
||||
uniq_identifier = "#{table_name}.#{primary_key}"
|
||||
scopes << self
|
||||
sub_query = (scopes).map {|s| s.except(:select).select(uniq_identifier).to_sql}.join(" UNION ALL ")
|
||||
sub_query = (scopes).map {|s| s.except(:select, :order).select(uniq_identifier).to_sql}.join(" UNION ALL ")
|
||||
engine.where("#{uniq_identifier} IN (#{sub_query})")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -226,17 +226,17 @@ module Api::V1::DiscussionTopics
|
|||
|
||||
def entry_pagination_url(topic)
|
||||
if @context.is_a? Course
|
||||
api_v1_course_discussion_entries_url(@context)
|
||||
api_v1_course_discussion_entries_url(@context, topic)
|
||||
else
|
||||
api_v1_group_discussion_entries_url(@context)
|
||||
api_v1_group_discussion_entries_url(@context, topic)
|
||||
end
|
||||
end
|
||||
|
||||
def reply_pagination_url(entry)
|
||||
def reply_pagination_url(topic, entry)
|
||||
if @context.is_a? Course
|
||||
api_v1_course_discussion_replies_url(@context)
|
||||
api_v1_course_discussion_replies_url(@context, topic, entry)
|
||||
else
|
||||
api_v1_group_discussion_replies_url(@context)
|
||||
api_v1_group_discussion_replies_url(@context, topic, entry)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#
|
||||
|
||||
class MessageableUser < User
|
||||
COLUMNS = ['id', 'short_name', 'name', 'avatar_image_url', 'avatar_image_source'].map{ |col| "users.#{col}" }
|
||||
COLUMNS = ['id', 'updated_at', 'short_name', 'name', 'avatar_image_url', 'avatar_image_source'].map{ |col| "users.#{col}" }
|
||||
SELECT = COLUMNS.join(", ")
|
||||
AVAILABLE_CONDITIONS = "users.workflow_state IN ('registered', 'pre_registered')"
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ def api_call(method, path, params, body_params = {}, headers = {}, opts = {})
|
|||
|
||||
case params[:format]
|
||||
when 'json'
|
||||
expect(CANVAS_RAILS3 ? response.header['content-type'] : response.header['Content-Type']).to eq 'application/json; charset=utf-8'
|
||||
expect(response.header[content_type_key]).to eq 'application/json; charset=utf-8'
|
||||
|
||||
body = response.body
|
||||
if body.respond_to?(:call)
|
||||
|
|
|
@ -148,7 +148,7 @@ describe "API Authentication", type: :request do
|
|||
# we have the code, we can close the browser session
|
||||
post "/login/oauth2/token", :client_id => @client_id, :client_secret => @client_secret, :code => code
|
||||
expect(response).to be_success
|
||||
expect(response.header['content-type']).to eq 'application/json; charset=utf-8'
|
||||
expect(response.header[content_type_key]).to eq 'application/json; charset=utf-8'
|
||||
json = JSON.parse(response.body)
|
||||
token = json['access_token']
|
||||
expect(json['user']).to eq({ 'id' => @user.id, 'name' => 'test1@example.com' })
|
||||
|
@ -345,7 +345,7 @@ describe "API Authentication", type: :request do
|
|||
# we have the code, we can close the browser session
|
||||
post "/login/oauth2/token", :client_id => @key.id, :client_secret => @client_secret, :code => code
|
||||
expect(response).to be_success
|
||||
expect(response.header['content-type']).to eq 'application/json; charset=utf-8'
|
||||
expect(response.header[content_type_key]).to eq 'application/json; charset=utf-8'
|
||||
json = JSON.parse(response.body)
|
||||
@token = json['access_token']
|
||||
expect(json['user']).to eq({ 'id' => @user.id, 'name' => 'test1@example.com' })
|
||||
|
@ -410,7 +410,7 @@ describe "API Authentication", type: :request do
|
|||
# exchange the code for the token
|
||||
post "/login/oauth2/token", {:code => code}, {'HTTP_AUTHORIZATION' => ActionController::HttpAuthentication::Basic.encode_credentials(@client_id, @client_secret)}
|
||||
expect(response).to be_success
|
||||
expect(response.header['content-type']).to eq 'application/json; charset=utf-8'
|
||||
expect(response.header[content_type_key]).to eq 'application/json; charset=utf-8'
|
||||
json = JSON.parse(response.body)
|
||||
token = json['access_token']
|
||||
reset!
|
||||
|
@ -458,7 +458,7 @@ describe "API Authentication", type: :request do
|
|||
# exchange the code for the token
|
||||
post "/login/oauth2/token", {:code => code}, {'HTTP_AUTHORIZATION' => ActionController::HttpAuthentication::Basic.encode_credentials(@client_id, @client_secret)}
|
||||
expect(response).to be_success
|
||||
expect(response.header['content-type']).to eq 'application/json; charset=utf-8'
|
||||
expect(response.header[content_type_key]).to eq 'application/json; charset=utf-8'
|
||||
JSON.parse(response.body)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -93,7 +93,7 @@ describe "API", type: :request do
|
|||
# no content-type header is sent
|
||||
post "/api/v1/courses/#{@course.id}/assignments", html_request, { "HTTP_AUTHORIZATION" => "Bearer #{@token.full_token}" }
|
||||
expect(response).to be_success
|
||||
expect(response.header['content-type']).to eq 'application/json; charset=utf-8'
|
||||
expect(response.header[content_type_key]).to eq 'application/json; charset=utf-8'
|
||||
|
||||
@assignment = @course.assignments.order(:id).last
|
||||
expect(@assignment.title).to eq "test assignment"
|
||||
|
@ -104,7 +104,7 @@ describe "API", type: :request do
|
|||
json_request = { "assignment" => { "name" => "test assignment", "points_possible" => 15 } }
|
||||
post "/api/v1/courses/#{@course.id}/assignments", json_request.to_json, { "CONTENT_TYPE" => "application/json", "HTTP_AUTHORIZATION" => "Bearer #{@token.full_token}" }
|
||||
expect(response).to be_success
|
||||
expect(response.header['content-type']).to eq 'application/json; charset=utf-8'
|
||||
expect(response.header[content_type_key]).to eq 'application/json; charset=utf-8'
|
||||
|
||||
@assignment = @course.assignments.order(:id).last
|
||||
expect(@assignment.title).to eq "test assignment"
|
||||
|
@ -125,7 +125,7 @@ describe "API", type: :request do
|
|||
"file_ids" => [a1.id, a2.id] } }
|
||||
post "/api/v1/courses/#{@course.id}/assignments/#{@assignment.id}/submissions", json_request.to_json, { "CONTENT_TYPE" => "application/json", "HTTP_AUTHORIZATION" => "Bearer #{@token.full_token}" }
|
||||
expect(response).to be_success
|
||||
expect(response.header['content-type']).to eq 'application/json; charset=utf-8'
|
||||
expect(response.header[content_type_key]).to eq 'application/json; charset=utf-8'
|
||||
|
||||
@submission = @assignment.submissions.where(user_id: @user).first
|
||||
expect(@submission.attachments.map { |a| a.id }.sort).to eq [a1.id, a2.id]
|
||||
|
|
|
@ -1077,13 +1077,13 @@ describe AssignmentsApiController, type: :request do
|
|||
json = api_call_to_create_adhoc_override(student_ids: [@student.id])
|
||||
|
||||
@assignment = Assignment.find json['id']
|
||||
adhoc_override = @assignment.assignment_overrides.where(set_type: 'ADHOC').first
|
||||
adhoc_override = @assignment.assignment_overrides.active.where(set_type: 'ADHOC').first
|
||||
|
||||
expect(@assignment.assignment_overrides.count).to eq 1
|
||||
|
||||
api_call_to_update_adhoc_override(student_ids: [@student.id, @first_student.id])
|
||||
|
||||
ao = @assignment.assignment_overrides.where(set_type: 'ADHOC').first
|
||||
ao = @assignment.assignment_overrides.active.where(set_type: 'ADHOC').first
|
||||
expect(ao.set).to match_array([@student, @first_student])
|
||||
end
|
||||
|
||||
|
@ -1113,12 +1113,12 @@ describe AssignmentsApiController, type: :request do
|
|||
|
||||
expect(@assignment.assignment_overrides.count).to eq 1
|
||||
|
||||
adhoc_override = @assignment.assignment_overrides.where(set_type: 'ADHOC').first
|
||||
adhoc_override = @assignment.assignment_overrides.active.where(set_type: 'ADHOC').first
|
||||
expect(adhoc_override.set).to eq [@student]
|
||||
|
||||
api_call_to_update_adhoc_override(student_ids: [@first_student.id])
|
||||
|
||||
ao = @assignment.assignment_overrides.where(set_type: 'ADHOC').first
|
||||
ao = @assignment.assignment_overrides.active.where(set_type: 'ADHOC').first
|
||||
expect(ao.set).to eq [@first_student]
|
||||
end
|
||||
end
|
||||
|
|
|
@ -87,10 +87,9 @@ describe Api::V1::Course do
|
|||
mod.publish
|
||||
mod.save!
|
||||
|
||||
class CourseProgress
|
||||
def course_context_modules_item_redirect_url(opts = {})
|
||||
"course_context_modules_item_redirect_url(:course_id => #{opts[:course_id]}, :id => #{opts[:id]}, :host => HostUrl.context_host(Course.find(#{opts[:course_id]}))"
|
||||
end
|
||||
stubbed_url = "redirect_url"
|
||||
CourseProgress.any_instance.stubs(:course_context_modules_item_redirect_url).returns(stubbed_url).with do |opts|
|
||||
opts[:course_id] == @course2.id && opts[:id] == tag.id
|
||||
end
|
||||
|
||||
json = @test_api.course_json(@course2, @me, {}, ['course_progress'], [])
|
||||
|
@ -98,7 +97,7 @@ describe Api::V1::Course do
|
|||
expect(json['course_progress']).to eq({
|
||||
'requirement_count' => 1,
|
||||
'requirement_completed_count' => 0,
|
||||
'next_requirement_url' => "course_context_modules_item_redirect_url(:course_id => #{@course2.id}, :id => #{tag.id}, :host => HostUrl.context_host(Course.find(#{@course2.id}))",
|
||||
'next_requirement_url' => stubbed_url,
|
||||
'completed_at' => nil
|
||||
})
|
||||
end
|
||||
|
|
|
@ -147,7 +147,7 @@ describe "Files API", type: :request do
|
|||
|
||||
raw_api_call(:post, "/api/v1/files/#{@attachment.id}/create_success?uuid=#{@attachment.uuid}",
|
||||
{:controller => "files", :action => "api_create_success", :format => "json", :id => @attachment.to_param, :uuid => @attachment.uuid})
|
||||
expect(response.headers["content-type"]).to eq "text/html; charset=utf-8"
|
||||
expect(response.headers[content_type_key]).to eq "text/html; charset=utf-8"
|
||||
expect(response.body).not_to include 'verifier='
|
||||
end
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ describe Quizzes::QuizGroupsController, type: :request do
|
|||
{'Accept' => 'application/vnd.api+json'}, opts)
|
||||
end
|
||||
|
||||
let (:new_quiz_group) { @quiz.quiz_groups.all[0] }
|
||||
let (:new_quiz_group) { @quiz.reload; @quiz.quiz_groups.first }
|
||||
|
||||
it "creates a question group for a quiz" do
|
||||
api_create_quiz_group('name' => 'testing')
|
||||
|
|
|
@ -193,7 +193,8 @@ describe Quizzes::QuizzesApiController, type: :request do
|
|||
{ quizzes: [{ 'title' => 'blah blah', 'published' => true }] },
|
||||
'Accept' => 'application/vnd.api+json')
|
||||
@json = @json.fetch('quizzes').map { |q| q.with_indifferent_access }
|
||||
@quiz = Quizzes::Quiz.first
|
||||
@course.reload
|
||||
@quiz = @course.quizzes.first
|
||||
expect(@json).to match_array [
|
||||
Quizzes::QuizSerializer.new(@quiz, scope: @user, controller: controller, session: session).
|
||||
as_json[:quiz].with_indifferent_access
|
||||
|
|
|
@ -697,7 +697,7 @@ describe 'Submissions API', type: :request do
|
|||
url = json[0]['attachments'][0]['url']
|
||||
get_via_redirect(url)
|
||||
expect(response).to be_success
|
||||
expect(response['content-type']).to eq 'image/png'
|
||||
expect(response[content_type_key]).to eq 'image/png'
|
||||
end
|
||||
|
||||
it "should allow retrieving media comments without a session" do
|
||||
|
|
|
@ -1118,9 +1118,11 @@ describe "Users API", type: :request do
|
|||
|
||||
context "a user with permissions" do
|
||||
it "should be able to delete a user" do
|
||||
json = api_call(:delete, @path, @path_options)
|
||||
expect(@student.associated_accounts).not_to include(Account.default)
|
||||
expect(json.to_json).to eq @student.reload.to_json
|
||||
Timecop.freeze do
|
||||
json = api_call(:delete, @path, @path_options)
|
||||
expect(@student.associated_accounts).not_to include(Account.default)
|
||||
expect(json.to_json).to eq @student.reload.to_json
|
||||
end
|
||||
end
|
||||
|
||||
it "should be able to delete a user by SIS ID" do
|
||||
|
@ -1135,10 +1137,12 @@ describe "Users API", type: :request do
|
|||
end
|
||||
|
||||
it 'should be able to delete itself' do
|
||||
path = "/api/v1/accounts/#{Account.default.to_param}/users/#{@user.id}"
|
||||
json = api_call(:delete, path, @path_options.merge(:user_id => @user.to_param))
|
||||
expect(@user.associated_accounts).not_to include(Account.default)
|
||||
expect(json.to_json).to eq @user.reload.to_json
|
||||
Timecop.freeze do
|
||||
path = "/api/v1/accounts/#{Account.default.to_param}/users/#{@user.id}"
|
||||
json = api_call(:delete, path, @path_options.merge(:user_id => @user.to_param))
|
||||
expect(@user.associated_accounts).not_to include(Account.default)
|
||||
expect(json.to_json).to eq @user.reload.to_json
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -51,11 +51,11 @@ describe 'ReassociateConversationAttachments' do
|
|||
|
||||
u1.reload
|
||||
expect(u1.folders.map(&:name).sort).to eql ["conversation attachments", "my files"]
|
||||
expect(u1.conversation_attachments_folder.attachments).to eql [a1]
|
||||
expect(u1.conversation_attachments_folder.attachments.to_a).to eql [a1]
|
||||
cm1.reload
|
||||
a1.reload
|
||||
expect(cm1.attachment_ids).to eql a1.id.to_s
|
||||
expect(cm1.attachments).to eql [a1]
|
||||
expect(cm1.attachments.to_a).to eql [a1]
|
||||
expect(a1.context).to eql u1
|
||||
expect(a1.folder).to eql u1.conversation_attachments_folder
|
||||
|
||||
|
@ -66,7 +66,7 @@ describe 'ReassociateConversationAttachments' do
|
|||
a2.reload
|
||||
a3.reload
|
||||
expect(cm2.attachment_ids.split(',').map(&:to_i).sort).to eql [a2.id, a3.id]
|
||||
expect(cm2.attachments).to eql [a2, a3]
|
||||
expect(cm2.attachments.to_a).to eql [a2, a3]
|
||||
expect(a2.context).to eql u2
|
||||
expect(a2.folder).to eql u2.conversation_attachments_folder
|
||||
expect(a3.context).to eql u2
|
||||
|
|
|
@ -752,6 +752,10 @@ RSpec.configure do |config|
|
|||
send(method, url, query, headers.merge(http_headers))
|
||||
end
|
||||
|
||||
def content_type_key
|
||||
CANVAS_RAILS3 ? 'content-type' : 'Content-Type'
|
||||
end
|
||||
|
||||
def force_string_encoding(str, encoding = "UTF-8")
|
||||
if str.respond_to?(:force_encoding)
|
||||
str.force_encoding(encoding)
|
||||
|
|
Loading…
Reference in New Issue