Sha256: 8f4b93052e80349180d620ac1249489a4c0a391719d22167cc5ae5b5a37bd10f

Contents?: true

Size: 1.91 KB

Versions: 37

Compression:

Stored size: 1.91 KB

Contents

RSpec.describe 'records/edit_fields/_description.html.erb', type: :view do
  let(:work) { GenericWork.new }
  let(:form) { Hyrax::GenericWorkForm.new(work, nil, controller) }
  let(:form_template) do
    %(
      <%= simple_form_for [main_app, @form] do |f| %>
        <%= render "records/edit_fields/description", f: f, key: 'description' %>
      <% end %>
    )
  end

  before do
    assign(:form, form)
  end

  context "when single valued" do
    before do
      expect(form).to receive(:multiple?).and_return(false)
    end

    context "when not required" do
      before do
        expect(form).to receive(:required?).and_return(false)
      end
      it 'has text area' do
        render inline: form_template
        expect(rendered).to have_selector('textarea[class="form-control text optional"]')
      end
    end

    context "when required" do
      before do
        expect(form).to receive(:required?).and_return(true)
      end
      it 'has text area' do
        render inline: form_template
        expect(rendered).to have_selector('textarea[class="form-control text required"]')
      end
    end
  end

  context "when multi valued" do
    before do
      expect(form).to receive(:multiple?).and_return(true)
    end

    context "when not required" do
      before do
        expect(form).to receive(:required?).and_return(false)
      end
      it 'has text area' do
        render inline: form_template
        expect(rendered).to have_selector('textarea[class="string multi_value optional generic_work_description form-control multi-text-field"]')
      end
    end

    context "when required" do
      before do
        expect(form).to receive(:required?).and_return(true)
      end
      it 'has text area' do
        render inline: form_template
        expect(rendered).to have_selector('textarea[class="string multi_value required generic_work_description form-control multi-text-field"]')
      end
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
hyrax-2.6.0 spec/views/records/edit_fields/_description.html.erb_spec.rb
hyrax-3.0.0.pre.rc1 spec/views/records/edit_fields/_description.html.erb_spec.rb
hyrax-3.0.0.pre.beta3 spec/views/records/edit_fields/_description.html.erb_spec.rb
hyrax-2.5.1 spec/views/records/edit_fields/_description.html.erb_spec.rb
hyrax-2.5.0 spec/views/records/edit_fields/_description.html.erb_spec.rb
hyrax-3.0.0.pre.beta2 spec/views/records/edit_fields/_description.html.erb_spec.rb
hyrax-2.4.1 spec/views/records/edit_fields/_description.html.erb_spec.rb
hyrax-3.0.0.pre.beta1 spec/views/records/edit_fields/_description.html.erb_spec.rb
hyrax-2.4.0 spec/views/records/edit_fields/_description.html.erb_spec.rb
hyrax-2.3.3 spec/views/records/edit_fields/_description.html.erb_spec.rb
hyrax-2.3.2 spec/views/records/edit_fields/_description.html.erb_spec.rb
hyrax-2.3.1 spec/views/records/edit_fields/_description.html.erb_spec.rb
hyrax-2.3.0 spec/views/records/edit_fields/_description.html.erb_spec.rb
hyrax-2.0.3 spec/views/records/edit_fields/_description.html.erb_spec.rb
hyrax-2.2.4 spec/views/records/edit_fields/_description.html.erb_spec.rb
hyrax-2.2.3 spec/views/records/edit_fields/_description.html.erb_spec.rb
hyrax-2.2.2 spec/views/records/edit_fields/_description.html.erb_spec.rb
hyrax-2.2.1 spec/views/records/edit_fields/_description.html.erb_spec.rb
hyrax-2.2.0 spec/views/records/edit_fields/_description.html.erb_spec.rb
hyrax-2.1.0 spec/views/records/edit_fields/_description.html.erb_spec.rb