From f2777f0526a67cbcb2248b3ce67b0914b47f486b Mon Sep 17 00:00:00 2001 From: Jonathan Rochkind Date: Wed, 17 May 2017 14:46:11 -0400 Subject: [PATCH] Deprecate FileSetFixityCheckService#logged_fixity_status, use the FixityStatusPresenter --- app/presenters/hyrax/file_set_presenter.rb | 2 +- .../hyrax/file_set_fixity_check_service.rb | 3 +-- .../file_set_fixity_check_service_spec.rb | 24 ++++++++++++------- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/app/presenters/hyrax/file_set_presenter.rb b/app/presenters/hyrax/file_set_presenter.rb index 290ce0ea4e..b5a74bbf61 100644 --- a/app/presenters/hyrax/file_set_presenter.rb +++ b/app/presenters/hyrax/file_set_presenter.rb @@ -77,7 +77,7 @@ def event_class end def fixity_check_status - fixity_check_service.logged_fixity_status + Hyrax::FixityStatusPresenter.new(id).render_file_set_status end def parent diff --git a/app/services/hyrax/file_set_fixity_check_service.rb b/app/services/hyrax/file_set_fixity_check_service.rb index 50b9cd555f..c8feab4137 100644 --- a/app/services/hyrax/file_set_fixity_check_service.rb +++ b/app/services/hyrax/file_set_fixity_check_service.rb @@ -64,9 +64,8 @@ def fixity_check # Return current fixity status for this FileSet based on # ChecksumAuditLog records on file. - # TODO: This method is on this class for legacy, callers - # should just use FixityStatusService directly. def logged_fixity_status + Deprecation.warn(self, "logged_fixity_status is deprecated, use FixityStatusPresenter instead") FixityStatusPresenter.new(file_set.id).render_file_set_status end diff --git a/spec/services/hyrax/file_set_fixity_check_service_spec.rb b/spec/services/hyrax/file_set_fixity_check_service_spec.rb index 9299f5bbee..48fdac4335 100644 --- a/spec/services/hyrax/file_set_fixity_check_service_spec.rb +++ b/spec/services/hyrax/file_set_fixity_check_service_spec.rb @@ -61,6 +61,14 @@ end describe '#logged_fixity_status' do + around do |example| + # Deprecation.silence is supposed to be a thing, but I can't get it to work + original = Deprecation.default_deprecation_behavior + Deprecation.default_deprecation_behavior = :silence + example.run + Deprecation.default_deprecation_behavior = original + end + context "with an object" do subject { service_by_object.logged_fixity_status } @@ -89,17 +97,17 @@ expect(subject).to include "passed" end end - end - context "with an id" do - subject { service_by_id.logged_fixity_status } + context "with an id" do + subject { service_by_id.logged_fixity_status } - before do - ChecksumAuditLog.create!(passed: true, file_set_id: f.id, checked_uri: f.original_file.versions.first.label, file_id: 'original_file') - end + before do + ChecksumAuditLog.create!(passed: true, file_set_id: f.id, checked_uri: f.original_file.versions.first.label, file_id: 'original_file') + end - it "records the fixity result" do - expect(subject).to include "passed" + it "records the fixity result" do + expect(subject).to include "passed" + end end end end