Sha256: 43c7b951bbbef73b3b2251104e3b8fcd9c4b5ddd576b06894c50db45ef4e393d

Contents?: true

Size: 1.94 KB

Versions: 29

Compression:

Stored size: 1.94 KB

Contents

require 'spec_helper'

describe CurationConcerns::Forms::FileSetEditForm do
  subject { described_class.new(FileSet.new) }

  describe '#terms' do
    it 'returns 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,
         :visibility_during_embargo, :visibility_after_embargo, :embargo_release_date,
         :visibility_during_lease, :visibility_after_lease, :lease_expiration_date,
         :visibility])
    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 'initializes multivalued fields' do
    expect(subject.title).to eq ['']
  end

  describe '.model_attributes' do
    let(:params) do
      ActionController::Parameters.new(
        title: ['foo'],
        "visibility" => "on-campus",
        "visibility_during_embargo" => "restricted",
        "embargo_release_date" => "2015-10-21",
        "visibility_after_embargo" => "open",
        "visibility_during_lease" => "open",
        "lease_expiration_date" => "2015-10-21",
        "visibility_after_lease" => "restricted"
      )
    end
    subject { described_class.model_attributes(params) }

    it 'changes only the title' do
      expect(subject['title']).to eq ['foo']
      expect(subject['visibility']).to eq('on-campus')
      expect(subject['visibility_during_embargo']).to eq('restricted')
      expect(subject['visibility_after_embargo']).to eq('open')
      expect(subject['embargo_release_date']).to eq('2015-10-21')
      expect(subject['visibility_during_lease']).to eq('open')
      expect(subject['visibility_after_lease']).to eq('restricted')
      expect(subject['lease_expiration_date']).to eq('2015-10-21')
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
curation_concerns-1.0.0.beta1 spec/forms/file_set_edit_form_spec.rb
curation_concerns-0.14.0 spec/forms/file_set_edit_form_spec.rb
curation_concerns-0.14.0.pre4 spec/forms/file_set_edit_form_spec.rb
curation_concerns-0.14.0.pre3 spec/forms/file_set_edit_form_spec.rb
curation_concerns-0.14.0.pre2 spec/forms/file_set_edit_form_spec.rb
curation_concerns-0.14.0.pre1 spec/forms/file_set_edit_form_spec.rb
curation_concerns-0.13.1 spec/forms/file_set_edit_form_spec.rb
curation_concerns-0.13.0 spec/forms/file_set_edit_form_spec.rb
curation_concerns-0.12.0 spec/forms/file_set_edit_form_spec.rb
curation_concerns-0.12.0.pre9 spec/forms/file_set_edit_form_spec.rb
curation_concerns-0.12.0.pre8 spec/forms/file_set_edit_form_spec.rb
curation_concerns-0.12.0.pre7 spec/forms/file_set_edit_form_spec.rb
curation_concerns-0.12.0.pre6 spec/forms/file_set_edit_form_spec.rb
curation_concerns-0.12.0.pre5 spec/forms/file_set_edit_form_spec.rb
curation_concerns-0.12.0.pre4 spec/forms/file_set_edit_form_spec.rb
curation_concerns-0.12.0.pre3 spec/forms/file_set_edit_form_spec.rb
curation_concerns-0.12.0.pre2 spec/forms/file_set_edit_form_spec.rb
curation_concerns-0.12.0.pre1 spec/forms/file_set_edit_form_spec.rb
curation_concerns-0.11.0 spec/forms/file_set_edit_form_spec.rb
curation_concerns-0.11.0.rc1 spec/forms/file_set_edit_form_spec.rb