diff --git a/spec/controllers/curation_concern/generic_files_controller_spec.rb b/spec/controllers/curation_concern/generic_files_controller_spec.rb index 2caa970..c40e7d2 100644 --- a/spec/controllers/curation_concern/generic_files_controller_spec.rb +++ b/spec/controllers/curation_concern/generic_files_controller_spec.rb @@ -132,10 +132,11 @@ end context "updating metadata" do - it "should be successful" do + it "should be successful and update attributes" do post :update, id: generic_file, generic_file: {title: 'new_title', tag: [''], permissions: { new_user_name: {'archivist1'=>'edit'}}} expect(response).to redirect_to [:curation_concern, generic_file] + expect(assigns[:generic_file].title).to eq(['new_title']) end it "should go back to edit on an error" do diff --git a/spec/models/worthwhile/generic_file_spec.rb b/spec/models/worthwhile/generic_file_spec.rb index bd7fd85..9369bf2 100644 --- a/spec/models/worthwhile/generic_file_spec.rb +++ b/spec/models/worthwhile/generic_file_spec.rb @@ -5,6 +5,11 @@ subject.depositor = 'tess@example.com' end + it "should update attributes" do + subject.attributes = {title:"My new Title"} + expect(subject.title).to eq(["My new Title"]) + end + describe "to_solr" do before do subject.title = ['One Flew Over the Cuckoo\'s Nest'] diff --git a/worthwhile-models/app/models/concerns/worthwhile/generic_file_base.rb b/worthwhile-models/app/models/concerns/worthwhile/generic_file_base.rb index 01eef89..022ce42 100644 --- a/worthwhile-models/app/models/concerns/worthwhile/generic_file_base.rb +++ b/worthwhile-models/app/models/concerns/worthwhile/generic_file_base.rb @@ -11,7 +11,7 @@ module GenericFileBase include Sufia::GenericFile::Derivatives include Sufia::GenericFile::Metadata include Sufia::GenericFile::Versions - include Sufia::Permissions::Readable + include Sufia::GenericFile::Permissions include ::CurationConcern::VersionedContent included do @@ -21,6 +21,8 @@ module GenericFileBase attr_accessor :file + attr_accessible *(terms_for_display + [:permissions]) + # make filename single-value (Sufia::GenericFile::Characterization makes it multivalue) # has_attributes :filename, datastream: :characterization, multiple: false def filename