Skip to content

Commit

Permalink
Creative Commons License in main fields when adding a new work (#1525)
Browse files Browse the repository at this point in the history
* add 'license' to primary_terms

* Test
  • Loading branch information
cldambrosio authored and Julie Allinson committed Oct 4, 2018
1 parent a93a8f3 commit 6579a09
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 1 deletion.
11 changes: 11 additions & 0 deletions app/forms/hyrax/form_terms.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module Hyrax
module FormTerms
include Hyrax::Forms
# overrides Hyrax::Forms::WorkForm
# to display 'license' in the 'base-terms' div on the user dashboard "Add New Work" description
# by getting iterated over in hyrax/app/views/hyrax/base/_form_metadata.html.erb
def primary_terms
super + [:license]
end
end
end
1 change: 1 addition & 0 deletions app/forms/hyrax/generic_work_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# `rails generate curation_concerns:work GenericWork`
module Hyrax
class GenericWorkForm < Hyrax::Forms::WorkForm
include Hyrax::FormTerms
self.model_class = ::GenericWork
include HydraEditor::Form::Permissions
self.terms += %i[resource_type rendering_ids]
Expand Down
1 change: 1 addition & 0 deletions app/forms/hyrax/image_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# `rails generate hyrax:work Image`
module Hyrax
class ImageForm < Hyrax::Forms::WorkForm
include Hyrax::FormTerms
self.model_class = ::Image
self.terms += %i[resource_type extent rendering_ids]

Expand Down
6 changes: 5 additions & 1 deletion lib/importer/factory/object_factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ def update
end

def create_attributes
{ collection_type: collection_type }.merge(transform_attributes)
if klass == Collection
{ collection_type: collection_type }.merge(transform_attributes)
else
transform_attributes
end
end

def update_attributes
Expand Down
2 changes: 2 additions & 0 deletions spec/forms/hyrax/generic_work_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@
expect(subject['rendering_ids']).to eq [file_set.id]
end
end

include_examples("work_form")
end
2 changes: 2 additions & 0 deletions spec/forms/hyrax/image_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@
expect(subject['extent']).to eq ['extent']
end
end

include_examples("work_form")
end
Empty file.
7 changes: 7 additions & 0 deletions spec/support/shared_examples_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
RSpec.shared_examples "work_form" do
describe ".primary_terms" do
it 'includes the license field' do
expect(form.primary_terms).to include(:license)
end
end
end

0 comments on commit 6579a09

Please sign in to comment.