-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pulls in some missing presenter and form classes from Sufia
- Loading branch information
1 parent
f14951a
commit f64db2f
Showing
6 changed files
with
75 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module CurationConcerns | ||
module Forms | ||
class GenericWorkEditForm < GenericWorkPresenter | ||
include HydraEditor::Form | ||
include HydraEditor::Form::Permissions | ||
self.required_fields = [:title, :creator, :tag, :rights] | ||
end | ||
end | ||
end |
13 changes: 13 additions & 0 deletions
13
app/presenters/curation_concerns/generic_work_presenter.rb
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,13 @@ | ||
module CurationConcerns | ||
class GenericWorkPresenter | ||
include Hydra::Presenter | ||
self.model_class = GenericWork | ||
# Terms is the list of fields displayed | ||
self.terms = [:resource_type, :title, :creator, :contributor, :description, :tag, :rights, | ||
:publisher, :date_created, :subject, :language, :identifier, :based_near, :related_url] | ||
|
||
# Depositor and permissions are not displayed | ||
# so don't include them in `terms'. | ||
delegate :depositor, :permissions, to: :model | ||
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,33 @@ | ||
require 'spec_helper' | ||
|
||
describe CurationConcerns::Forms::GenericFileEditForm do | ||
subject { described_class.new(GenericFile.new) } | ||
|
||
describe "#terms" do | ||
it "should return a list" do | ||
expect(subject.terms).to eq([:resource_type, :title, :creator, :contributor, :description, :tag, | ||
:rights, :publisher, :date_created, :subject, :language, :identifier, :based_near, :related_url]) | ||
end | ||
|
||
it "doesn't contain fields that users shouldn't be allowed to edit" do | ||
# date_uploaded is reserved for the original creation date of the record. | ||
expect(subject.terms).not_to include(:date_uploaded) | ||
end | ||
end | ||
|
||
it "should initialize multivalued fields" do | ||
expect(subject.title).to eq [''] | ||
end | ||
|
||
describe ".model_attributes" do | ||
let(:params) { ActionController::Parameters.new(title: ['foo'], description: [''], "permissions_attributes"=>{"2"=>{"access"=>"edit", "_destroy"=>"true", "id"=>"a987551e-b87f-427a-8721-3e5942273125"}})} | ||
subject { described_class.model_attributes(params) } | ||
|
||
it "should only change title" do | ||
expect(subject['title']).to eq ["foo"] | ||
expect(subject['description']).to be_empty | ||
expect(subject['permissions_attributes']).to eq("2" => {"access"=>"edit", "id"=>"a987551e-b87f-427a-8721-3e5942273125", "_destroy"=>"true"}) | ||
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
16 changes: 16 additions & 0 deletions
16
spec/presenters/curation_concerns/generic_file_presenter_spec.rb
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,16 @@ | ||
require 'spec_helper' | ||
|
||
describe CurationConcerns::GenericFilePresenter do | ||
|
||
describe ".terms" do | ||
it "should return a list" do | ||
expect(described_class.terms).to eq([:resource_type, :title, | ||
:creator, :contributor, :description, :tag, :rights, :publisher, | ||
:date_created, :subject, :language, :identifier, :based_near, | ||
:related_url]) | ||
end | ||
end | ||
|
||
let(:presenter) { CurationConcerns::GenericFilePresenter.new(file) } | ||
|
||
end |