diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index e3f7cab70ce..c89671525cc 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -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') diff --git a/app/controllers/discussion_topics_api_controller.rb b/app/controllers/discussion_topics_api_controller.rb index 8d4abc4b921..acbd30dd822 100644 --- a/app/controllers/discussion_topics_api_controller.rb +++ b/app/controllers/discussion_topics_api_controller.rb @@ -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 diff --git a/app/controllers/lti/ims/tool_consumer_profile_controller.rb b/app/controllers/lti/ims/tool_consumer_profile_controller.rb index 945e5d11b02..e97dd9c1a36 100644 --- a/app/controllers/lti/ims/tool_consumer_profile_controller.rb +++ b/app/controllers/lti/ims/tool_consumer_profile_controller.rb @@ -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 diff --git a/app/controllers/quizzes/quiz_questions_controller.rb b/app/controllers/quizzes/quiz_questions_controller.rb index 2fe3f5461c8..7d48466224c 100644 --- a/app/controllers/quizzes/quiz_questions_controller.rb +++ b/app/controllers/quizzes/quiz_questions_controller.rb @@ -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, diff --git a/app/controllers/submissions_api_controller.rb b/app/controllers/submissions_api_controller.rb index ef81db617a0..6552f329f78 100644 --- a/app/controllers/submissions_api_controller.rb +++ b/app/controllers/submissions_api_controller.rb @@ -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 diff --git a/app/controllers/wiki_pages_api_controller.rb b/app/controllers/wiki_pages_api_controller.rb index 1b26176c0ce..9ef3fe7c7bd 100644 --- a/app/controllers/wiki_pages_api_controller.rb +++ b/app/controllers/wiki_pages_api_controller.rb @@ -147,7 +147,7 @@ class WikiPagesApiController < ApplicationController # Retrieve the content of the front page # # @example_request - # curl -H 'Authorization: Bearer ' \ + # curl -H 'Authorization: Bearer ' \ # https:///api/v1/courses/123/front_page # # @returns Page @@ -210,7 +210,7 @@ class WikiPagesApiController < ApplicationController # # # @example_request - # curl -H 'Authorization: Bearer ' \ + # curl -H 'Authorization: Bearer ' \ # https:///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 ' \ + # curl -X POST -H 'Authorization: Bearer ' \ # https:///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 ' \ + # curl -H 'Authorization: Bearer ' \ # https:///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 ' \ + # curl -X PUT -H 'Authorization: Bearer ' \ # https:///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 ' \ + # curl -X DELETE -H 'Authorization: Bearer ' \ # https:///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)) diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb index 6790121a099..9124cef3d03 100644 --- a/app/helpers/search_helper.rb +++ b/app/helpers/search_helper.rb @@ -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] = { diff --git a/app/models/account_authorization_config.rb b/app/models/account_authorization_config.rb index 79d34c95ce6..5a5e78db9f2 100644 --- a/app/models/account_authorization_config.rb +++ b/app/models/account_authorization_config.rb @@ -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) diff --git a/app/models/assignment_override.rb b/app/models/assignment_override.rb index 1fc82a2764c..7339c0c2e87 100644 --- a/app/models/assignment_override.rb +++ b/app/models/assignment_override.rb @@ -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 diff --git a/config/initializers/active_record.rb b/config/initializers/active_record.rb index 33f39a1363d..2d1e53c2410 100644 --- a/config/initializers/active_record.rb +++ b/config/initializers/active_record.rb @@ -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 diff --git a/lib/api/v1/discussion_topics.rb b/lib/api/v1/discussion_topics.rb index 2838f727556..161c602344e 100644 --- a/lib/api/v1/discussion_topics.rb +++ b/lib/api/v1/discussion_topics.rb @@ -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 diff --git a/lib/messageable_user.rb b/lib/messageable_user.rb index 75f2ae71413..6b2d1dbcbf9 100644 --- a/lib/messageable_user.rb +++ b/lib/messageable_user.rb @@ -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')" diff --git a/spec/apis/api_spec_helper.rb b/spec/apis/api_spec_helper.rb index 303b61cd989..f3a97481820 100644 --- a/spec/apis/api_spec_helper.rb +++ b/spec/apis/api_spec_helper.rb @@ -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) diff --git a/spec/apis/auth_spec.rb b/spec/apis/auth_spec.rb index 7f2029b7c3b..bb71b3f7cde 100644 --- a/spec/apis/auth_spec.rb +++ b/spec/apis/auth_spec.rb @@ -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 diff --git a/spec/apis/general_api_spec.rb b/spec/apis/general_api_spec.rb index 92e6d06776f..553b6c9f362 100644 --- a/spec/apis/general_api_spec.rb +++ b/spec/apis/general_api_spec.rb @@ -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] diff --git a/spec/apis/v1/assignments_api_spec.rb b/spec/apis/v1/assignments_api_spec.rb index ca1b156c8f6..34c57605459 100644 --- a/spec/apis/v1/assignments_api_spec.rb +++ b/spec/apis/v1/assignments_api_spec.rb @@ -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 diff --git a/spec/apis/v1/courses_api_spec.rb b/spec/apis/v1/courses_api_spec.rb index 29205e50f67..bc7f3ab89de 100644 --- a/spec/apis/v1/courses_api_spec.rb +++ b/spec/apis/v1/courses_api_spec.rb @@ -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 diff --git a/spec/apis/v1/files_controller_api_spec.rb b/spec/apis/v1/files_controller_api_spec.rb index 5c6db167fe6..a1ea5a426ab 100644 --- a/spec/apis/v1/files_controller_api_spec.rb +++ b/spec/apis/v1/files_controller_api_spec.rb @@ -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 diff --git a/spec/apis/v1/quizzes/quiz_groups_api_spec.rb b/spec/apis/v1/quizzes/quiz_groups_api_spec.rb index a9503816472..eca80f16c57 100644 --- a/spec/apis/v1/quizzes/quiz_groups_api_spec.rb +++ b/spec/apis/v1/quizzes/quiz_groups_api_spec.rb @@ -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') diff --git a/spec/apis/v1/quizzes/quizzes_api_spec.rb b/spec/apis/v1/quizzes/quizzes_api_spec.rb index c879cbe17c0..53d63e72142 100644 --- a/spec/apis/v1/quizzes/quizzes_api_spec.rb +++ b/spec/apis/v1/quizzes/quizzes_api_spec.rb @@ -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 diff --git a/spec/apis/v1/submissions_api_spec.rb b/spec/apis/v1/submissions_api_spec.rb index 708156fb300..0ae590317e5 100644 --- a/spec/apis/v1/submissions_api_spec.rb +++ b/spec/apis/v1/submissions_api_spec.rb @@ -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 diff --git a/spec/apis/v1/users_api_spec.rb b/spec/apis/v1/users_api_spec.rb index 28cf2165593..c640f559cd1 100644 --- a/spec/apis/v1/users_api_spec.rb +++ b/spec/apis/v1/users_api_spec.rb @@ -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 diff --git a/spec/migrations/reassociate_conversation_attachments_spec.rb b/spec/migrations/reassociate_conversation_attachments_spec.rb index 0a3ddf0fbbd..73cc1725fcd 100644 --- a/spec/migrations/reassociate_conversation_attachments_spec.rb +++ b/spec/migrations/reassociate_conversation_attachments_spec.rb @@ -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 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index a7eb9be47ee..9fbff90a75b 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -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)