don't give an expired unlock-at date in lock explanation
test plan: - have an unpublished module with an unlock-at date in the past - put a file and a wiki page in it - as a student, ensure when you try to view these items (from the files and pages index pages), the "locked" message doesn't say they "will unlock" at a past date fixes CNVS-28003 Change-Id: Ib02e4f78c5ea6568398c16ab18b88748068ae52f Reviewed-on: https://gerrit.instructure.com/74695 Tested-by: Jenkins Reviewed-by: James Williams <jamesw@instructure.com> QA-Review: Jahnavi Yetukuri <jyetukuri@instructure.com> Product-Review: Jeremy Stanley <jeremy@instructure.com>
This commit is contained in:
parent
6307f7f55f
commit
3173cad1ed
|
@ -1059,7 +1059,7 @@ class Attachment < ActiveRecord::Base
|
|||
locked = {:asset_string => self.asset_string, :lock_at => self.lock_at}
|
||||
elsif self.could_be_locked && item = locked_by_module_item?(user, opts[:deep_check_if_needed])
|
||||
locked = {:asset_string => self.asset_string, :context_module => item.context_module.attributes}
|
||||
locked[:unlock_at] = locked[:context_module]["unlock_at"] if locked[:context_module]["unlock_at"]
|
||||
locked[:unlock_at] = locked[:context_module]["unlock_at"] if locked[:context_module]["unlock_at"] && locked[:context_module]["unlock_at"] > Time.now.utc
|
||||
end
|
||||
locked
|
||||
end
|
||||
|
|
|
@ -214,7 +214,7 @@ class WikiPage < ActiveRecord::Base
|
|||
locked = false
|
||||
if item = locked_by_module_item?(user, opts[:deep_check_if_needed])
|
||||
locked = {:asset_string => self.asset_string, :context_module => item.context_module.attributes}
|
||||
locked[:unlock_at] = locked[:context_module]["unlock_at"] if locked[:context_module]["unlock_at"]
|
||||
locked[:unlock_at] = locked[:context_module]["unlock_at"] if locked[:context_module]["unlock_at"] && locked[:context_module]["unlock_at"] > Time.now.utc
|
||||
end
|
||||
locked
|
||||
end
|
||||
|
|
|
@ -44,7 +44,7 @@ module HasContentTags
|
|||
end
|
||||
|
||||
def locked_cache_key(user)
|
||||
keys = ['_locked_for2', self, user]
|
||||
keys = ['_locked_for3', self, user]
|
||||
unlocked_at = self.respond_to?(:unlock_at) ? self.unlock_at : nil
|
||||
locked_at = self.respond_to?(:lock_at) ? self.lock_at : nil
|
||||
keys << (unlocked_at ? unlocked_at > Time.zone.now : false)
|
||||
|
|
|
@ -506,5 +506,25 @@ describe WikiPage do
|
|||
mod.save
|
||||
expect(pageC.reload).to be_locked_for @student
|
||||
end
|
||||
|
||||
it "includes a future unlock date" do
|
||||
course_with_student_logged_in active_all: true
|
||||
page = @course.wiki.wiki_pages.create! title: 'page'
|
||||
mod = @course.context_modules.create name: 'teh module', unlock_at: 1.week.from_now
|
||||
mod.add_item type: 'wiki_page', id: page.id
|
||||
mod.workflow_state = 'unpublished'
|
||||
mod.save!
|
||||
expect(page.reload.locked_for?(@student)[:unlock_at]).to eq mod.unlock_at
|
||||
end
|
||||
|
||||
it "doesn't reference an expired unlock-at date" do
|
||||
course_with_student_logged_in active_all: true
|
||||
page = @course.wiki.wiki_pages.create! title: 'page'
|
||||
mod = @course.context_modules.create name: 'teh module', unlock_at: 1.week.ago
|
||||
mod.add_item type: 'wiki_page', id: page.id
|
||||
mod.workflow_state = 'unpublished'
|
||||
mod.save!
|
||||
expect(page.reload.locked_for?(@student)).not_to have_key :unlock_at
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue