don't enforce sequential completion of zero requirements

test plan:
 - create a public course
 - create a module in the course
 - add an item
 - add a completion requirement for the item, and check the
   "require sequential progress" option
 - remove the requirement
 - ensure both a logged-in student and a non-logged-in user
   can access the module item

fixes CNVS-24908

Change-Id: Ia692a5a433c9fa4345f65664a650a01e5ada84e0
Reviewed-on: https://gerrit.instructure.com/67204
Tested-by: Jenkins
Reviewed-by: James Williams  <jamesw@instructure.com>
QA-Review: Ryan Allen <rallen@instructure.com>
Product-Review: Jeremy Stanley <jeremy@instructure.com>
This commit is contained in:
Jeremy Stanley 2015-11-16 11:27:54 -07:00
parent e35b087cfe
commit 1599fac783
2 changed files with 9 additions and 1 deletions

View File

@ -237,7 +237,8 @@ class ContextModule < ActiveRecord::Base
end
def available_for?(user, opts={})
return true if self.active? && !self.to_be_unlocked && self.prerequisites.blank? && !self.require_sequential_progress
return true if self.active? && !self.to_be_unlocked && self.prerequisites.blank? &&
(self.completion_requirements.empty? || !self.require_sequential_progress)
if self.grants_right?(user, :read_as_admin)
return true
elsif !self.active?

View File

@ -29,6 +29,13 @@ describe ContextModule do
course_module
expect(@module.available_for?(nil)).to eql(true)
end
it "returns true by default when require_sequential_progress is true and there are no requirements" do
course_module
@module.require_sequential_progress = true
@module.save!
expect(@module.available_for?(nil)).to eql(true)
end
end
describe "prerequisites=" do