-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Connects to #3821 Connects to #3824 This branch handles the "first pass" suggestion in two issues (#3821 and #3824), isolating certain `ActiveFedora::Base` class method calls within a new wrapper class (`Hyrax::Base`). Those calls are `.id_to_uri`, `.uri_to_id`, and `.uncached`. This provides a single location in the codebase where these calls might be refactored, replaced, or removed in the "second pass" work.
- Loading branch information
Showing
11 changed files
with
65 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# frozen_string_literal: true | ||
|
||
module Hyrax | ||
# Isolate calls to ActiveFedora::Base | ||
class Base | ||
def self.uncached(&block) | ||
ActiveFedora::Base.uncached(&block) | ||
end | ||
|
||
def self.uri_to_id(uri) | ||
ActiveFedora::Base.uri_to_id(uri) | ||
end | ||
|
||
def self.id_to_uri(id) | ||
ActiveFedora::Base.id_to_uri(id) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe Hyrax::Base do | ||
describe '.uncached' do | ||
let(:block) { proc { puts 'I do nothing' } } | ||
|
||
it 'calls ActiveFedora::Base.uncached' do | ||
allow(ActiveFedora::Base).to receive(:uncached) | ||
described_class.uncached(&block) | ||
expect(ActiveFedora::Base).to have_received(:uncached) do |&passed_block| | ||
expect(passed_block).to eq(block) | ||
end | ||
end | ||
end | ||
|
||
describe '.id_to_uri' do | ||
let(:id) { 'abc123' } | ||
|
||
it 'calls ActiveFedora::Base.id_to_uri' do | ||
allow(ActiveFedora::Base).to receive(:id_to_uri) | ||
described_class.id_to_uri(id) | ||
expect(ActiveFedora::Base).to have_received(:id_to_uri).with(id).once | ||
end | ||
end | ||
|
||
describe '.uri_to_id' do | ||
let(:uri) { 'https://foo.bar/abc123' } | ||
|
||
it 'calls ActiveFedora::Base.uri_to_id' do | ||
allow(ActiveFedora::Base).to receive(:uri_to_id) | ||
described_class.uri_to_id(uri) | ||
expect(ActiveFedora::Base).to have_received(:uri_to_id).with(uri).once | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters