This repository has been archived by the owner on May 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a path to get all collections in one manifest.
Closes #339
- Loading branch information
Trey Terrell
committed
Jan 12, 2016
1 parent
20c9831
commit 889e055
Showing
9 changed files
with
137 additions
and
13 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,23 @@ | ||
class AllCollectionsPresenter < CollectionShowPresenter | ||
def initialize(current_ability = nil) | ||
@current_ability = current_ability | ||
end | ||
|
||
def title | ||
"Plum Collections" | ||
end | ||
|
||
def description | ||
"All collections which are a part of Plum." | ||
end | ||
|
||
def creator | ||
nil | ||
end | ||
|
||
private | ||
|
||
def ordered_ids | ||
ActiveFedora::SolrService.query("active_fedora_model_ssi:Collection", rows: 10_000, fl: "id").map { |x| x["id"] } | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
class AllCollectionsManifestBuilder < ManifestBuilder | ||
def initialize(record = nil, ssl: false) | ||
super | ||
end | ||
|
||
private | ||
|
||
def root_path | ||
"#{helper.root_url(protocol: protocol)}collections/manifest" | ||
end | ||
|
||
def protocol | ||
if @ssl | ||
:https | ||
else | ||
:http | ||
end | ||
end | ||
|
||
def helper | ||
@helper ||= ManifestBuilder::ManifestHelper.new | ||
end | ||
|
||
def record | ||
@record ||= AllCollectionsPresenter.new | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe AllCollectionsPresenter do | ||
subject { described_class.new } | ||
|
||
it "can be used to build a manifest" do | ||
expect { AllCollectionsManifestBuilder.new(subject).to_json }.not_to raise_error | ||
end | ||
|
||
it "has a title" do | ||
expect(subject.title).to eq "Plum Collections" | ||
end | ||
|
||
it "has a description" do | ||
expect(subject.description).to eq "All collections which are a part of Plum." | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe AllCollectionsManifestBuilder do | ||
subject { described_class.new } | ||
context "when there are collections" do | ||
let(:manifest_json) { JSON.parse(subject.to_json) } | ||
it "builds them as sub-manifests" do | ||
FactoryGirl.create(:collection) | ||
|
||
expect(manifest_json["manifests"].length).to eq 1 | ||
end | ||
it "has an ID" do | ||
expect(manifest_json["@id"]).to eq "http://plum.com/collections/manifest" | ||
end | ||
context "when SSL is set" do | ||
subject { described_class.new(nil, ssl: true) } | ||
it "can have an SSL ID" do | ||
expect(manifest_json["@id"]).to eq "https://plum.com/collections/manifest" | ||
end | ||
end | ||
end | ||
end |