ignore deleted overrides in has_overrides?

test plan:
* have an overriden assignment
* delete the overrides
* should not return "has_overrides in the API

closes #CORE-3

Change-Id: I14c131226e606bb7493586b417bce2447016bdb8
Reviewed-on: https://gerrit.instructure.com/130170
Tested-by: Jenkins
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Product-Review: James Williams  <jamesw@instructure.com>
This commit is contained in:
James Williams 2017-10-18 13:32:28 -06:00
parent 085f16c9b9
commit 0ec135477e
2 changed files with 11 additions and 1 deletions

View File

@ -60,7 +60,12 @@ module DatesOverridable
end
def has_overrides?
assignment_overrides.loaded? ? assignment_overrides.any? : assignment_overrides.exists?
if current_version?
assignment_overrides.loaded? ? assignment_overrides.any?(&:active?) : assignment_overrides.active.exists?
else
# the old version's overrides might have be deleted too but it's probably more trouble than it's worth to check here
assignment_overrides.loaded? ? assignment_overrides.any? : assignment_overrides.exists?
end
end
def has_active_overrides?

View File

@ -205,6 +205,11 @@ shared_examples_for "an object whose dates are overridable" do
it { is_expected.to be_truthy }
end
context "when it does but it's deleted" do
before { override.destroy }
it { is_expected.to be_falsey }
end
context "when it doesn't" do
it { is_expected.to be_falsey }
end