rails 5: controllers q-r
refs CNVS-34864 Change-Id: I14f590aa5b5b7e97bd240aad7feaa74298567817 Reviewed-on: https://gerrit.instructure.com/104169 Tested-by: Jenkins Reviewed-by: Simon Williams <simon@instructure.com> Product-Review: Cody Cutrer <cody@instructure.com> QA-Review: Cody Cutrer <cody@instructure.com>
This commit is contained in:
parent
0d63decaee
commit
4ec005d7fc
|
@ -486,7 +486,7 @@ class RoleOverridesController < ApplicationController
|
|||
RoleOverride.permissions.keys.each do |key|
|
||||
if params[:permissions][key]
|
||||
roles.each do |role|
|
||||
if settings = params[:permissions][key][role.id]
|
||||
if (settings = params[:permissions][key][role.id.to_s] || params[:permissions][key][role.id])
|
||||
override = settings[:override] == 'checked' if ['checked', 'unchecked'].include?(settings[:override])
|
||||
locked = settings[:locked] == 'true' if settings[:locked]
|
||||
RoleOverride.manage_role_override(@context, role, key.to_s, :override => override, :locked => locked)
|
||||
|
|
|
@ -44,7 +44,7 @@ class RubricAssociationsController < ApplicationController
|
|||
@association = RubricAssociation.generate(@current_user, @rubric, @context, association_params)
|
||||
json_res = {
|
||||
:rubric => @rubric.as_json(:methods => :criteria, :include_root => false, :permissions => {:user => @current_user, :session => session}),
|
||||
:rubric_association => @association.as_json(:include_root => false, :include => [:rubric_assessments, :assessment_requests], :methods => :assessor_name, :permissions => {:user => @current_user, :session => session})
|
||||
:rubric_association => @association.as_json(:include_root => false, :include => [:rubric_assessments, :assessment_requests], :permissions => {:user => @current_user, :session => session})
|
||||
}
|
||||
render :json => json_res
|
||||
end
|
||||
|
|
|
@ -89,7 +89,7 @@ class RubricsController < ApplicationController
|
|||
end
|
||||
json_res = {}
|
||||
json_res[:rubric] = @rubric.as_json(:methods => :criteria, :include_root => false, :permissions => {:user => @current_user, :session => session}) if @rubric
|
||||
json_res[:rubric_association] = @association.as_json(:include_root => false, :include => [:assessment_requests], :methods => :assessor_name, :permissions => {:user => @current_user, :session => session}) if @association
|
||||
json_res[:rubric_association] = @association.as_json(:include_root => false, :include => [:assessment_requests], :permissions => {:user => @current_user, :session => session}) if @association
|
||||
json_res[:rubric_association][:skip_updating_points_possible] = skip_points_update if json_res && json_res[:rubric_association]
|
||||
render :json => json_res
|
||||
end
|
||||
|
|
|
@ -241,7 +241,7 @@ class Quizzes::QuizSubmission < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def backup_submission_data(params)
|
||||
raise "Only a hash value is accepted for backup_submission_data calls" unless params.is_a?(Hash)
|
||||
raise "Only a hash value is accepted for backup_submission_data calls" unless params.is_a?(Hash) || params.is_a?(ActionController::Parameters)
|
||||
|
||||
params = sanitize_params(params)
|
||||
|
||||
|
|
|
@ -211,6 +211,7 @@ class Rubric < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def will_change_with_update?(params)
|
||||
params ||= {}
|
||||
return true if params[:free_form_criterion_comments] && !!self.free_form_criterion_comments != (params[:free_form_criterion_comments] == '1')
|
||||
data = generate_criteria(params)
|
||||
return true if data.title != self.title || data.points_possible != self.points_possible
|
||||
|
|
|
@ -110,7 +110,7 @@ module Api::V1::AssignmentOverride
|
|||
|
||||
def interpret_assignment_override_data(assignment, data, set_type=nil)
|
||||
data ||= {}
|
||||
return {}, ["invalid override data"] unless data.is_a?(Hash)
|
||||
return {}, ["invalid override data"] unless data.is_a?(Hash) || data.is_a?(ActionController::Parameters)
|
||||
|
||||
# validate structure of parameters
|
||||
override_data = {}
|
||||
|
|
|
@ -1158,6 +1158,7 @@ describe Quizzes::QuizzesController do
|
|||
|
||||
it "does not allow a nil override due date when the last grading period is closed" do
|
||||
override_params = [{ due_at: nil, course_section_id: section_id }]
|
||||
request.content_type = 'application/json' unless CANVAS_RAILS4_2
|
||||
call_create(due_at: 7.days.from_now.iso8601, assignment_overrides: override_params)
|
||||
assert_forbidden
|
||||
expect(@course.quizzes.count).to eql 0
|
||||
|
|
|
@ -50,16 +50,18 @@ describe RubricsController do
|
|||
|
||||
it "should assign variables" do
|
||||
course_with_teacher_logged_in(:active_all => true)
|
||||
request.content_type = 'application/json' unless CANVAS_RAILS4_2
|
||||
post 'create', :course_id => @course.id, :rubric => {}
|
||||
expect(assigns[:rubric]).not_to be_nil
|
||||
expect(assigns[:rubric]).not_to be_new_record
|
||||
expect(response).to be_success
|
||||
|
||||
|
||||
end
|
||||
|
||||
it "should create an association if specified" do
|
||||
course_with_teacher_logged_in(:active_all => true)
|
||||
association = @course.assignments.create!(assignment_valid_attributes)
|
||||
request.content_type = 'application/json' unless CANVAS_RAILS4_2
|
||||
post 'create', :course_id => @course.id, :rubric => {}, :rubric_association => {:association_type => association.class.to_s, :association_id => association.id}
|
||||
expect(assigns[:rubric]).not_to be_nil
|
||||
expect(assigns[:rubric]).not_to be_new_record
|
||||
|
@ -128,12 +130,12 @@ describe RubricsController do
|
|||
}
|
||||
|
||||
post 'create', create_params
|
||||
|
||||
|
||||
expect(assignment.reload.learning_outcome_alignments.count).to eq 1
|
||||
expect(Rubric.last.learning_outcome_alignments.count).to eq 1
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
describe "PUT 'update'" do
|
||||
it "should require authorization" do
|
||||
course_with_teacher(:active_all => true)
|
||||
|
@ -459,7 +461,7 @@ describe RubricsController do
|
|||
expect(@rubric.reload.learning_outcome_alignments.count).to eq 0
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
describe "DELETE 'destroy'" do
|
||||
it "should require authorization" do
|
||||
course_with_teacher(:active_all => true)
|
||||
|
@ -499,7 +501,7 @@ describe RubricsController do
|
|||
RubricAssociation.create!(:rubric => @rubric, :context => @course, :purpose => :bookmark, :association_object => @course)
|
||||
RubricAssociation.create!(:rubric => @rubric, :context => Account.default, :purpose => :bookmark, :association_object => @course)
|
||||
expect(@course.rubric_associations.bookmarked.include_rubric.to_a.select(&:rubric_id).uniq(&:rubric_id).sort_by{|a| a.rubric.title }.map(&:rubric)).to eq [@rubric]
|
||||
|
||||
|
||||
delete 'destroy', :course_id => @course.id, :id => @rubric.id
|
||||
expect(response).to be_success
|
||||
expect(@course.rubric_associations.bookmarked.include_rubric.to_a.select(&:rubric_id).uniq(&:rubric_id).sort_by{|a| a.rubric.title }.map(&:rubric)).to eq []
|
||||
|
|
Loading…
Reference in New Issue