rails 6: various fixes for controller specs
Change-Id: I93b6470bda86efc324d3fe0704d271813c49d6dc Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/250497 Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Reviewed-by: Michael Ziwisky <mziwisky@instructure.com> QA-Review: Cody Cutrer <cody@instructure.com> Product-Review: Cody Cutrer <cody@instructure.com>
This commit is contained in:
parent
5e16d6572f
commit
934e10af14
|
@ -17,7 +17,7 @@
|
|||
|
||||
group :test do
|
||||
gem 'rails-dom-testing', '2.0.3'
|
||||
gem 'rails-controller-testing', '1.0.4'
|
||||
gem 'rails-controller-testing', '1.0.5'
|
||||
|
||||
gem 'gergich', '1.2.0', require: false
|
||||
gem 'dotenv', '2.7.5', require: false
|
||||
|
@ -30,7 +30,7 @@ group :test do
|
|||
|
||||
gem 'rspec', '3.9.0'
|
||||
gem 'rspec_around_all', '0.2.0'
|
||||
gem 'rspec-rails', '3.9.0'
|
||||
gem 'rspec-rails', '4.0.1'
|
||||
gem 'rspec-collection_matchers', '1.2.0'
|
||||
gem 'rspec-support', '3.9.2'
|
||||
gem 'rspec-expectations', '3.9.0'
|
||||
|
|
|
@ -1461,7 +1461,7 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
|
||||
def log_gets
|
||||
if @page_view && !request.xhr? && request.get? && (((response.content_type || "").to_s.match(/html/)) ||
|
||||
if @page_view && !request.xhr? && request.get? && (((response.media_type || "").to_s.match(/html/)) ||
|
||||
(Setting.get('create_get_api_page_views', 'true') == 'true') && api_request?)
|
||||
@page_view.render_time ||= (Time.now.utc - @page_before_render) rescue nil
|
||||
@page_view_update = true
|
||||
|
@ -2698,8 +2698,8 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
|
||||
# makes it so you can use the prefetch_xhr erb helper from controllers. They'll be rendered in _head.html.erb
|
||||
def prefetch_xhr(*args)
|
||||
(@xhrs_to_prefetch_from_controller ||= []) << args
|
||||
def prefetch_xhr(*args, **kwargs)
|
||||
(@xhrs_to_prefetch_from_controller ||= []) << [args, kwargs]
|
||||
end
|
||||
|
||||
def teardown_live_events_context
|
||||
|
|
|
@ -541,25 +541,25 @@ class CommunicationChannelsController < ApplicationController
|
|||
|
||||
def bouncing_channel_report
|
||||
generate_bulk_report do
|
||||
CommunicationChannel::BulkActions::ResetBounceCounts.new(bulk_action_args)
|
||||
CommunicationChannel::BulkActions::ResetBounceCounts.new(**bulk_action_args)
|
||||
end
|
||||
end
|
||||
|
||||
def bulk_reset_bounce_counts
|
||||
perform_bulk_action do
|
||||
CommunicationChannel::BulkActions::ResetBounceCounts.new(bulk_action_args)
|
||||
CommunicationChannel::BulkActions::ResetBounceCounts.new(**bulk_action_args)
|
||||
end
|
||||
end
|
||||
|
||||
def unconfirmed_channel_report
|
||||
generate_bulk_report do
|
||||
CommunicationChannel::BulkActions::Confirm.new(bulk_action_args)
|
||||
CommunicationChannel::BulkActions::Confirm.new(**bulk_action_args)
|
||||
end
|
||||
end
|
||||
|
||||
def bulk_confirm
|
||||
perform_bulk_action do
|
||||
CommunicationChannel::BulkActions::Confirm.new(bulk_action_args)
|
||||
CommunicationChannel::BulkActions::Confirm.new(**bulk_action_args)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -163,8 +163,7 @@ class FilesController < ApplicationController
|
|||
def quota
|
||||
get_quota
|
||||
if authorized_action(@context.attachments.temp_record, @current_user, :create)
|
||||
h = ActionView::Base.new
|
||||
h.extend ActionView::Helpers::NumberHelper
|
||||
h = ActiveSupport::NumberHelper
|
||||
result = {
|
||||
:quota => h.number_to_human_size(@quota),
|
||||
:quota_used => h.number_to_human_size(@quota_used),
|
||||
|
|
|
@ -1247,9 +1247,9 @@ class GradebooksController < ApplicationController
|
|||
def grade_summary_presenter
|
||||
options = presenter_options
|
||||
if options.key?(:grading_period_id)
|
||||
GradingPeriodGradeSummaryPresenter.new(@context, @current_user, params[:id], options)
|
||||
GradingPeriodGradeSummaryPresenter.new(@context, @current_user, params[:id], **options)
|
||||
else
|
||||
GradeSummaryPresenter.new(@context, @current_user, params[:id], options)
|
||||
GradeSummaryPresenter.new(@context, @current_user, params[:id], **options)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ module Lti::Ims::Providers
|
|||
# Non-active students get an active ('submitted') Submission, so join on base_users_scope to narrow down
|
||||
# Submissions to only active students.
|
||||
students_scope = base_users_scope.where(enrollments: {type: student_queryable_roles})
|
||||
narrowed_students_scope = students_scope.where(correlated_assignment_submissions('users.id').exists)
|
||||
narrowed_students_scope = students_scope.where("EXISTS (?)", correlated_assignment_submissions('users.id'))
|
||||
# If we only care about students, this scope is sufficient and can avoid the ugly union down below
|
||||
return narrowed_students_scope if filter_non_students?
|
||||
|
||||
|
|
|
@ -217,7 +217,7 @@ class PlannerController < ApplicationController
|
|||
#
|
||||
# grading = @user.assignments_needing_grading(default_opts) if @domain_root_account.grants_right?(@user, :manage_grades)
|
||||
# moderation = @user.assignments_needing_moderation(default_opts)
|
||||
viewing = @user.assignments_for_student('viewing', default_opts).
|
||||
viewing = @user.assignments_for_student('viewing', **default_opts).
|
||||
preload(:quiz, :discussion_topic, :wiki_page)
|
||||
scopes = {viewing: viewing}
|
||||
# TODO: Add when ready (see above comment)
|
||||
|
@ -235,13 +235,13 @@ class PlannerController < ApplicationController
|
|||
|
||||
def ungraded_quiz_collection
|
||||
item_collection('ungraded_quizzes',
|
||||
@user.ungraded_quizzes(default_opts),
|
||||
@user.ungraded_quizzes(**default_opts),
|
||||
Quizzes::Quiz, [:user_due_date, :due_at, :created_at], :id)
|
||||
end
|
||||
|
||||
def unread_discussion_topic_collection
|
||||
item_collection('unread_discussion_topics',
|
||||
@user.discussion_topics_needing_viewing(default_opts.except(:include_locked)).
|
||||
@user.discussion_topics_needing_viewing(**default_opts.except(:include_locked)).
|
||||
unread_for(@user),
|
||||
DiscussionTopic, [:todo_date, :posted_at, :delayed_post_at, :created_at], :id)
|
||||
end
|
||||
|
@ -273,12 +273,12 @@ class PlannerController < ApplicationController
|
|||
end
|
||||
|
||||
def page_collection
|
||||
item_collection('pages', @user.wiki_pages_needing_viewing(default_opts.except(:include_locked)),
|
||||
item_collection('pages', @user.wiki_pages_needing_viewing(**default_opts.except(:include_locked)),
|
||||
WikiPage, [:todo_date, :created_at], :id)
|
||||
end
|
||||
|
||||
def ungraded_discussion_collection
|
||||
item_collection('ungraded_discussions', @user.discussion_topics_needing_viewing(default_opts.except(:include_locked)),
|
||||
item_collection('ungraded_discussions', @user.discussion_topics_needing_viewing(**default_opts.except(:include_locked)),
|
||||
DiscussionTopic, [:todo_date, :posted_at, :created_at], :id)
|
||||
end
|
||||
|
||||
|
@ -291,7 +291,7 @@ class PlannerController < ApplicationController
|
|||
|
||||
def peer_reviews_collection
|
||||
item_collection('peer_reviews',
|
||||
@user.submissions_needing_peer_review(default_opts.except(:include_locked)),
|
||||
@user.submissions_needing_peer_review(**default_opts.except(:include_locked)),
|
||||
AssessmentRequest, [{submission: {assignment: :peer_reviews_due_at}},
|
||||
{assessor_asset: :cached_due_date}, :created_at], :id)
|
||||
end
|
||||
|
@ -333,8 +333,8 @@ class PlannerController < ApplicationController
|
|||
end
|
||||
@user_ids = @contexts.select{ |c| c.is_a? User }.map(&:id)
|
||||
else
|
||||
@course_ids = @user.course_ids_for_todo_lists(:student, default_opts.slice(:course_ids, :include_concluded))
|
||||
@group_ids = @user.group_ids_for_todo_lists(default_opts.slice(:group_ids))
|
||||
@course_ids = @user.course_ids_for_todo_lists(:student, **default_opts.slice(:course_ids, :include_concluded))
|
||||
@group_ids = @user.group_ids_for_todo_lists(**default_opts.slice(:group_ids))
|
||||
@user_ids = [@user.id]
|
||||
end
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ class GroupAndMembershipImporter < ActiveRecord::Base
|
|||
return unless progress.reload.running?
|
||||
|
||||
begin
|
||||
csv_contents = CSV.read(csv[:fullpath], SIS::CSV::CSVBaseImporter::PARSE_ARGS)
|
||||
csv_contents = CSV.read(csv[:fullpath], **SIS::CSV::CSVBaseImporter::PARSE_ARGS)
|
||||
rescue CSV::MalformedCSVError
|
||||
fail_import(I18n.t("Malformed CSV"))
|
||||
end
|
||||
|
|
|
@ -85,7 +85,7 @@ class Lti::LineItem < ApplicationRecord
|
|||
|
||||
line_item ||= self.new(assignment: assignment, root_account_id: assignment.root_account_id)
|
||||
attrs = params.to_h.merge(client_id: tool.developer_key.global_id, coupled: false).compact
|
||||
line_item.update_attributes!(attrs)
|
||||
line_item.update!(attrs)
|
||||
line_item
|
||||
end
|
||||
end
|
||||
|
|
|
@ -46,7 +46,7 @@ class PageView < ActiveRecord::Base
|
|||
p.http_method = request.request_method.downcase
|
||||
p.controller = request.path_parameters[:controller]
|
||||
p.action = request.path_parameters[:action]
|
||||
p.session_id = request.session_options[:id].to_s.force_encoding(Encoding::UTF_8).presence
|
||||
p.session_id = request.session_options[:id].to_s.dup.force_encoding(Encoding::UTF_8).presence
|
||||
p.user_agent = request.user_agent
|
||||
p.remote_ip = request.remote_ip
|
||||
p.interaction_seconds = 5
|
||||
|
|
|
@ -144,10 +144,10 @@ class SubmissionComment < ActiveRecord::Base
|
|||
|
||||
def check_for_media_object
|
||||
if self.media_comment? && self.saved_change_to_media_comment_id?
|
||||
MediaObject.ensure_media_object(self.media_comment_id, {
|
||||
:user => self.author,
|
||||
:context => self.author,
|
||||
})
|
||||
MediaObject.ensure_media_object(self.media_comment_id,
|
||||
user: self.author,
|
||||
context: self.author
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -69,8 +69,8 @@
|
|||
</script>
|
||||
|
||||
<%= benchmark("include_head_js") { include_head_js } %>
|
||||
<% @xhrs_to_prefetch_from_controller&.each do |args| %>
|
||||
<%= prefetch_xhr(*args) %>
|
||||
<% @xhrs_to_prefetch_from_controller&.each do |(args, kwargs)| %>
|
||||
<%= prefetch_xhr(*args, **kwargs) %>
|
||||
<% end %>
|
||||
<% @content_for_head&.each do |string| %>
|
||||
<%= string %>
|
||||
|
|
|
@ -90,6 +90,7 @@ module IgnoreMonkeyPatchesInDeprecations
|
|||
return true if label == 'render' && path&.end_with?("application_controller.rb")
|
||||
return true if label == 'named_context_url' && path&.end_with?("application_controller.rb")
|
||||
return true if label == 'redirect_to' && path&.end_with?("application_controller.rb")
|
||||
return true if label == 'block in wrap_block_in_transaction' && path == File.expand_path(File.dirname(__FILE__) + "/../../spec/spec_helper.rb")
|
||||
|
||||
return false unless path
|
||||
super(path)
|
||||
|
|
|
@ -1183,7 +1183,7 @@ RSpec.describe ApplicationController do
|
|||
end
|
||||
|
||||
it 'uses selection_width and selection_height from the ContentTag if provided' do
|
||||
content_tag.update_attributes(link_settings: {selection_width: 543, selection_height: 321})
|
||||
content_tag.update(link_settings: {selection_width: 543, selection_height: 321})
|
||||
controller.send(:content_tag_redirect, course, content_tag, nil)
|
||||
|
||||
expect(assigns[:lti_launch].tool_dimensions[:selection_width]).to eq '543px'
|
||||
|
|
|
@ -20,7 +20,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|||
|
||||
describe AppointmentGroupsController do
|
||||
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)
|
||||
@course2 = course_factory(active_all: true)
|
||||
course_factory(active_all: true)
|
||||
student_in_course(active_all: true)
|
||||
|
|
|
@ -200,7 +200,7 @@ describe ConversationsController do
|
|||
it "returns starred conversations with no received messages" do
|
||||
course_with_student_logged_in(:active_all => true)
|
||||
conv = @user.initiate_conversation([])
|
||||
conv.update_attributes(starred: true, message_count: 1)
|
||||
conv.update(starred: true, message_count: 1)
|
||||
|
||||
get 'index', params: {:scope => 'starred'}, :format => 'json'
|
||||
expect(response).to be_successful
|
||||
|
|
|
@ -778,7 +778,7 @@ describe DiscussionTopicsController do
|
|||
end
|
||||
|
||||
it "successfully redirects no authorization for a public course" do
|
||||
@course.update_attributes(is_public: true)
|
||||
@course.update(is_public: true)
|
||||
course_topic
|
||||
get 'show', params: {:course_id => @course.id, :id => @topic.id}
|
||||
expect(response.code).to eq "302"
|
||||
|
|
|
@ -624,7 +624,7 @@ describe FilesController do
|
|||
get "show_relative", params: {file_id: @file.id, course_id: @course.id, file_path: @file.full_display_path, inline: 1, download: 1}
|
||||
expect(response).to be_successful
|
||||
expect(response.body).to eq 'hello'
|
||||
expect(response.content_type).to eq 'text/html'
|
||||
expect(response.media_type).to eq 'text/html'
|
||||
end
|
||||
|
||||
it "redirects for large html files" do
|
||||
|
@ -1116,7 +1116,7 @@ describe FilesController do
|
|||
end
|
||||
|
||||
before :each do
|
||||
@content = Rack::Test::UploadedFile.new(File.join(ActionController::TestCase.fixture_path, 'courses.yml'), '')
|
||||
@content = Rack::Test::UploadedFile.new(File.join(RSpec.configuration.fixture_path, 'courses.yml'), '')
|
||||
request.env['CONTENT_TYPE'] = 'multipart/form-data'
|
||||
enable_forgery_protection
|
||||
end
|
||||
|
@ -1129,7 +1129,7 @@ describe FilesController do
|
|||
@attachment.reload
|
||||
# the file is not available until the third api call is completed
|
||||
expect(@attachment.file_state).to eq 'deleted'
|
||||
expect(@attachment.open.read).to eq File.read(File.join(ActionController::TestCase.fixture_path, 'courses.yml'))
|
||||
expect(@attachment.open.read).to eq File.read(File.join(RSpec.configuration.fixture_path, 'courses.yml'))
|
||||
end
|
||||
|
||||
it "opens up cors headers" do
|
||||
|
|
|
@ -131,7 +131,7 @@ describe Lti::Ims::AuthenticationController do
|
|||
},
|
||||
(1.year.from_now)
|
||||
)
|
||||
jws.first(-1)
|
||||
jws[0...-1]
|
||||
end
|
||||
|
||||
it_behaves_like 'lti_message_hint error'
|
||||
|
@ -156,7 +156,7 @@ describe Lti::Ims::AuthenticationController do
|
|||
assigns[:oidc_error]
|
||||
end
|
||||
|
||||
it { is_expected.to be_success }
|
||||
it { is_expected.to be_successful }
|
||||
|
||||
it 'has a descriptive error message' do
|
||||
expect(error_object[:error_description]).to eq expected_message
|
||||
|
|
|
@ -63,7 +63,7 @@ module Lti
|
|||
|
||||
before { Lti::Security.check_and_store_nonce(nonce_key, iat, 30.seconds) }
|
||||
|
||||
it { is_expected.to be_success }
|
||||
it { is_expected.to be_successful }
|
||||
end
|
||||
|
||||
context 'when the aud is invalid' do
|
||||
|
@ -127,7 +127,7 @@ module Lti
|
|||
|
||||
it do
|
||||
expected_url_called(url, :get, stubbed_response)
|
||||
is_expected.to be_success
|
||||
is_expected.to be_successful
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -138,7 +138,7 @@ module Lti
|
|||
|
||||
it do
|
||||
expected_url_called(url, :get, stubbed_response)
|
||||
is_expected.to be_success
|
||||
is_expected.to be_successful
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -264,7 +264,7 @@ module Lti
|
|||
user_session(@user)
|
||||
context_external_tool
|
||||
subject
|
||||
is_expected.to be_success
|
||||
is_expected.to be_successful
|
||||
expect(context_module.content_tags.count).to eq(3)
|
||||
end
|
||||
|
||||
|
@ -273,7 +273,7 @@ module Lti
|
|||
user_session(@user)
|
||||
context_external_tool
|
||||
subject
|
||||
is_expected.to be_success
|
||||
is_expected.to be_successful
|
||||
expect(context_module.content_tags[0][:link_settings]).to be(nil)
|
||||
end
|
||||
|
||||
|
@ -291,7 +291,7 @@ module Lti
|
|||
user_session(@user)
|
||||
context_external_tool
|
||||
subject
|
||||
is_expected.to be_success
|
||||
is_expected.to be_successful
|
||||
expect(context_module.content_tags[0][:link_settings]['selection_width']).to be(642)
|
||||
expect(context_module.content_tags[0][:link_settings]['selection_height']).to be(842)
|
||||
end
|
||||
|
|
|
@ -120,7 +120,7 @@ module Lti
|
|||
|
||||
it 'does not 500 if tool registration fails' do
|
||||
get 'registration_return', params: {course_id: course.id, status: 'failure'}
|
||||
expect(response).to be_succes
|
||||
expect(response).to be_successful
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ RSpec.describe Lti::ToolConfigurationsApiController, type: :controller do
|
|||
|
||||
shared_examples_for 'an action that requires manage developer keys' do |skip_404|
|
||||
context 'when the user has manage_developer_keys' do
|
||||
it { is_expected.to be_success }
|
||||
it { is_expected.to be_successful }
|
||||
end
|
||||
|
||||
context 'when the user is not an admin' do
|
||||
|
|
|
@ -264,7 +264,7 @@ XML
|
|||
|
||||
def check_failure(failure_type = 'unsupported', error_message = nil)
|
||||
expect(response).to be_successful
|
||||
expect(response.content_type).to eq 'application/xml'
|
||||
expect(response.media_type).to eq 'application/xml'
|
||||
xml = Nokogiri::XML.parse(response.body)
|
||||
expect(xml.at_css('imsx_POXEnvelopeResponse > imsx_POXHeader > imsx_POXResponseHeaderInfo > imsx_statusInfo > imsx_codeMajor').content).to eq failure_type
|
||||
expect(@assignment.submissions.not_placeholder.where(user_id: @student)).not_to be_exists
|
||||
|
@ -275,7 +275,7 @@ XML
|
|||
|
||||
def check_success
|
||||
expect(response).to be_successful
|
||||
expect(response.content_type).to eq 'application/xml'
|
||||
expect(response.media_type).to eq 'application/xml'
|
||||
expect(Nokogiri::XML.parse(response.body).at_css('imsx_POXEnvelopeResponse > imsx_POXHeader > imsx_POXResponseHeaderInfo > imsx_statusInfo > imsx_codeMajor').content).to eq 'success'
|
||||
end
|
||||
|
||||
|
@ -681,7 +681,7 @@ to because the assignment has no points possible.
|
|||
|
||||
def check_success
|
||||
expect(response).to be_successful
|
||||
expect(response.content_type).to eq 'application/xml'
|
||||
expect(response.media_type).to eq 'application/xml'
|
||||
xml = Nokogiri::XML.parse(response.body)
|
||||
expect(xml.at_css('message_response > statusinfo > codemajor').content).to eq 'Success'
|
||||
expect(xml.at_css('message_response > statusinfo > codeminor').content).to eq 'fullsuccess'
|
||||
|
@ -690,7 +690,7 @@ to because the assignment has no points possible.
|
|||
|
||||
def check_failure(failure_type = 'Failure', error_message = nil)
|
||||
expect(response).to be_successful
|
||||
expect(response.content_type).to eq 'application/xml'
|
||||
expect(response.media_type).to eq 'application/xml'
|
||||
xml = Nokogiri::XML.parse(response.body)
|
||||
expect(xml.at_css('message_response > statusinfo > codemajor').content).to eq failure_type
|
||||
expect(@assignment.submissions.not_placeholder.where(user_id: @student)).not_to be_exists
|
||||
|
|
|
@ -179,7 +179,7 @@ describe OutcomeResultsController do
|
|||
aggregate: 'course',
|
||||
aggregate_stat: 'powerlaw'},
|
||||
format: "json"
|
||||
expect(response).not_to be_success
|
||||
expect(response).not_to be_successful
|
||||
end
|
||||
|
||||
context 'with muted assignment' do
|
||||
|
@ -304,23 +304,23 @@ describe OutcomeResultsController do
|
|||
context 'sorting' do
|
||||
it 'should validate sort_by parameter' do
|
||||
get_rollups(sort_by: 'garbage')
|
||||
expect(response).not_to be_success
|
||||
expect(response).not_to be_successful
|
||||
end
|
||||
|
||||
it 'should validate sort_order parameter' do
|
||||
get_rollups(sort_by: 'student', sort_order: 'random')
|
||||
expect(response).not_to be_success
|
||||
expect(response).not_to be_successful
|
||||
end
|
||||
|
||||
context 'by outcome' do
|
||||
it 'should validate a missing sort_outcome_id parameter' do
|
||||
get_rollups(sort_by: 'outcome')
|
||||
expect(response).not_to be_success
|
||||
expect(response).not_to be_successful
|
||||
end
|
||||
|
||||
it 'should validate an invalid sort_outcome_id parameter' do
|
||||
get_rollups(sort_by: 'outcome', sort_outcome_id: 'NaN')
|
||||
expect(response).not_to be_success
|
||||
expect(response).not_to be_successful
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -340,14 +340,14 @@ describe OutcomeResultsController do
|
|||
context 'by student' do
|
||||
it 'should sort rollups by ascending student name' do
|
||||
get_rollups(sort_by: 'student')
|
||||
expect(response).to be_success
|
||||
expect(response).to be_successful
|
||||
json = parse_response(response)
|
||||
expect_user_order(json['rollups'], [@student1, @student2, @student3])
|
||||
end
|
||||
|
||||
it 'should sort rollups by descending student name' do
|
||||
get_rollups(sort_by: 'student', sort_order: 'desc')
|
||||
expect(response).to be_success
|
||||
expect(response).to be_successful
|
||||
json = parse_response(response)
|
||||
expect_user_order(json['rollups'], [@student3, @student2, @student1])
|
||||
end
|
||||
|
@ -392,7 +392,7 @@ describe OutcomeResultsController do
|
|||
|
||||
def expect_students_in_pagination(page, students, sort_order = 'asc', include: nil)
|
||||
get_rollups(sort_by: 'student', sort_order: sort_order, per_page: 1, page: page, include: include)
|
||||
expect(response).to be_success
|
||||
expect(response).to be_successful
|
||||
expect_user_order(json['rollups'], students)
|
||||
end
|
||||
|
||||
|
@ -469,7 +469,7 @@ describe OutcomeResultsController do
|
|||
context 'by outcome' do
|
||||
it 'should sort rollups by ascending rollup score' do
|
||||
get_rollups(sort_by: 'outcome', sort_outcome_id: @outcome.id)
|
||||
expect(response).to be_success
|
||||
expect(response).to be_successful
|
||||
json = parse_response(response)
|
||||
expect_user_order(json['rollups'], [@student2, @student1, @student3])
|
||||
expect_score_order(json['rollups'], [1, 3, nil])
|
||||
|
@ -477,7 +477,7 @@ describe OutcomeResultsController do
|
|||
|
||||
it 'should sort rollups by descending rollup score' do
|
||||
get_rollups(sort_by: 'outcome', sort_outcome_id: @outcome.id, sort_order: 'desc')
|
||||
expect(response).to be_success
|
||||
expect(response).to be_successful
|
||||
json = parse_response(response)
|
||||
expect_user_order(json['rollups'], [@student1, @student2, @student3])
|
||||
expect_score_order(json['rollups'], [3, 1, nil])
|
||||
|
@ -486,7 +486,7 @@ describe OutcomeResultsController do
|
|||
context 'with pagination' do
|
||||
def expect_students_in_pagination(page, students, scores, sort_order = 'asc')
|
||||
get_rollups(sort_by: 'outcome', sort_outcome_id: @outcome.id, sort_order: sort_order, per_page: 1, page: page)
|
||||
expect(response).to be_success
|
||||
expect(response).to be_successful
|
||||
json = parse_response(response)
|
||||
expect_user_order(json['rollups'], students)
|
||||
expect_score_order(json['rollups'], scores)
|
||||
|
|
|
@ -20,7 +20,7 @@ require_relative '../sharding_spec_helper'
|
|||
|
||||
describe PlannerController do
|
||||
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)
|
||||
course_with_teacher(active_all: true)
|
||||
student_in_course(active_all: true)
|
||||
@group = @course.assignment_groups.create(:name => "some group")
|
||||
|
@ -722,7 +722,7 @@ describe PlannerController do
|
|||
context "with user id" do
|
||||
it "allows a student to query her own planner items" do
|
||||
get :index, params: {user_id: 'self', per_page: 1}
|
||||
expect(response).to be_success
|
||||
expect(response).to be_successful
|
||||
link = Api.parse_pagination_links(response.headers['Link']).detect{|p| p[:rel] == "next"}
|
||||
expect(link[:uri].path).to include "/api/v1/users/self/planner/items"
|
||||
end
|
||||
|
@ -732,7 +732,7 @@ describe PlannerController do
|
|||
user_session(observer)
|
||||
UserObservationLink.create_or_restore(observer: observer, student: @student, root_account: Account.default)
|
||||
get :index, params: {user_id: @student.to_param, per_page: 1}
|
||||
expect(response).to be_success
|
||||
expect(response).to be_successful
|
||||
link = Api.parse_pagination_links(response.headers['Link']).detect{|p| p[:rel] == "next"}
|
||||
expect(link[:uri].path).to include "/api/v1/users/#{@student.to_param}/planner/items"
|
||||
end
|
||||
|
|
|
@ -80,7 +80,7 @@ describe SupportHelpers::PlagiarismPlatformController do
|
|||
end
|
||||
|
||||
it 'is a succesful response' do
|
||||
expect(response).to be_success
|
||||
expect(response).to be_successful
|
||||
end
|
||||
|
||||
it 'adds the service to all tool proxies' do
|
||||
|
|
|
@ -599,7 +599,7 @@ describe ContentZipper do
|
|||
it "creates uploaded data for the assignment and marks it as available" do
|
||||
expect(@attachment).to receive(:save!).once
|
||||
zip_name = "submissions.zip"
|
||||
zip_path = File.join(ActionController::TestCase.fixture_path, zip_name)
|
||||
zip_path = File.join(RSpec.configuration.fixture_path, zip_name)
|
||||
data = "just some stub data"
|
||||
expect(Rack::Test::UploadedFile).to receive(:new).with(zip_path, 'application/zip').and_return data
|
||||
expect(@attachment).to receive(:uploaded_data=).with data
|
||||
|
|
|
@ -1848,7 +1848,11 @@ describe Course, "enroll" do
|
|||
@course.enroll_student(@user)
|
||||
scope = account.associated_courses.active.select([:id, :name]).eager_load(:teachers).joins(:teachers).where(:enrollments => { :workflow_state => 'active' })
|
||||
sql = scope.to_sql
|
||||
expect(sql).to match(/"enrollments"\."type" IN \('TeacherEnrollment'\)/)
|
||||
if CANVAS_RAILS5_2
|
||||
expect(sql).to match(/"enrollments"\."type" IN \('TeacherEnrollment'\)/)
|
||||
else
|
||||
expect(sql).to match(/"enrollments"\."type" = 'TeacherEnrollment'/)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -452,10 +452,10 @@ describe LiveEventsObserver do
|
|||
expect(Canvas::LiveEvents).to receive(:course_completed).with(anything)
|
||||
ContextModuleProgression.transaction(requires_new: true) do
|
||||
# complete it
|
||||
context_module_progression.update_attributes(:workflow_state => 'completed',
|
||||
context_module_progression.update(:workflow_state => 'completed',
|
||||
:requirements_met => [{:id => tag.id, :type => 'must_view'}])
|
||||
# sneakily remove the requiremets met because terribleness
|
||||
context_module_progression.update_attributes(:requirements_met => [])
|
||||
context_module_progression.update(:requirements_met => [])
|
||||
end
|
||||
# event fires off now but it should ignore the missing requirements_met in the db and
|
||||
# use the ones that were present when the completion happened
|
||||
|
|
|
@ -350,8 +350,7 @@ describe "submissions" do
|
|||
|
||||
describe 'uploaded files for submission' do
|
||||
def fixture_file_path(file)
|
||||
path = ActionController::TestCase.respond_to?(:fixture_path) ? ActionController::TestCase.send(:fixture_path) : nil
|
||||
return "#{path}#{file}"
|
||||
RSpec.configuration.fixture_path.join(file).to_s
|
||||
end
|
||||
|
||||
def make_folder_actions_visible
|
||||
|
|
|
@ -516,7 +516,7 @@ RSpec.configure do |config|
|
|||
end
|
||||
|
||||
def fixture_file_upload(path, mime_type=nil, binary=false)
|
||||
Rack::Test::UploadedFile.new(File.join(ActionController::TestCase.fixture_path, path), mime_type, binary)
|
||||
Rack::Test::UploadedFile.new(File.join(RSpec.configuration.fixture_path, path), mime_type, binary)
|
||||
end
|
||||
|
||||
def default_uploaded_data
|
||||
|
|
Loading…
Reference in New Issue