Sha256: 2c6a2569fe4892d0bf1e37a0f050d90fb20756936c36074e96e63ba09e665c82

Contents?: true

Size: 1.32 KB

Versions: 5

Compression:

Stored size: 1.32 KB

Contents

require 'spec_helper'

describe 'SelectWithHelpInput', type: :input do
  subject { input_for form, :resource_type, options }
  let(:file) { FileSet.new }
  let(:form_class) do
    Class.new do
      include HydraEditor::Form
      self.model_class = FileSet
      self.terms = [:resource_type]
    end
  end
  let(:form) { form_class.new(FileSet.new) }
  let(:collection) { CurationConcerns.config.resource_types }
  let(:base_options) do
    { as: :select_with_help, collection: collection,
      input_html: { class: 'form-control', multiple: true } }
  end
  let(:options) { base_options }

  it "does not be required by default" do
    expect(subject).to have_selector 'select'
    expect(subject).not_to match(/required/)
  end

  context 'with File Edit' do
    let(:user) { create(:user) }
    let(:file) { FileSet.create(label: 'f1') { |f| f.apply_depositor_metadata(user) } }
    let(:form) { CurationConcerns::Forms::FileSetEditForm.new(file) }
    let(:base_options) do
      { as: :select_with_help, collection: collection,
        input_html: { class: 'form-control', multiple: true } }
    end
    let(:options) { base_options }

    subject { input_for form, :resource_type, options }

    it "is not required by default" do
      expect(subject).to have_selector 'select'
      expect(subject).not_to match(/required/)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
curation_concerns-0.8.0 spec/inputs/select_with_help_input_spec.rb
curation_concerns-0.7.0 spec/inputs/select_with_help_input_spec.rb
curation_concerns-0.6.0 spec/inputs/select_with_help_input_spec.rb
curation_concerns-0.5.0 spec/inputs/select_with_help_input_spec.rb
curation_concerns-0.4.0 spec/inputs/select_with_help_input_spec.rb