Sha256: 8fac1c2cae56e931eb70d47e08f745e526ae697ef8f3877b465424f643d2c516

Contents?: true

Size: 1.7 KB

Versions: 7

Compression:

Stored size: 1.7 KB

Contents

require 'spec_helper'

describe 'curation_concerns/base/_form_rights.html.erb' do
  let(:curation_concern) { GenericWork.new }
  let(:form) { CurationConcerns::Forms::WorkForm.new(curation_concern, nil) }
  let(:form_template) do
    %(
      <%= simple_form_for [main_app, @form] do |f| %>
        <%= render "curation_concerns/base/form_rights", f: f, curation_concern: curation_concern %>
      <% end %>
    )
  end

  before do
    qa_fixtures = { local_path: File.expand_path('../../../../fixtures/authorities', __FILE__) }
    allow(Qa::Authorities::Local).to receive(:config).and_return(qa_fixtures)
  end

  context "when active and inactive rights are associated with a work" do
    before do
      curation_concern.rights = ['demo_id_01', 'demo_id_04']
      assign(:form, form)
      render inline: form_template, locals: { curation_concern: curation_concern }
    end

    it 'will only include active values if the current value is active' do
      expect(rendered).not_to have_xpath('//div/ul/li[1]/select/option[@value="demo_id_04"]')
      expect(rendered).not_to have_xpath('//div/ul/li[1]/select/option[text()="Fourth is an Inactive Term"]')
    end

    it 'will always include the current value as an option' do
      expect(rendered).to have_xpath('//div/ul/li[2]/select/option[@value="demo_id_04" and @selected="selected"]')
      expect(rendered).to have_xpath('//div/ul/li[2]/select/option[text()="Fourth is an Inactive Term"]')
    end

    it 'only offers active values to add to a work' do
      expect(rendered).not_to have_xpath('//div/ul/li[3]/select/option[@value="demo_id_04"]')
      expect(rendered).not_to have_xpath('//div/ul/li[3]/select/option[text()="Fourth is an Inactive Term"]')
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
curation_concerns-1.3.3 spec/views/curation_concerns/base/_form_rights_spec.rb
curation_concerns-1.3.2 spec/views/curation_concerns/base/_form_rights_spec.rb
curation_concerns-1.3.1 spec/views/curation_concerns/base/_form_rights_spec.rb
curation_concerns-1.3.0 spec/views/curation_concerns/base/_form_rights_spec.rb
curation_concerns-1.2.0 spec/views/curation_concerns/base/_form_rights_spec.rb
curation_concerns-1.1.2 spec/views/curation_concerns/base/_form_rights_spec.rb
curation_concerns-1.1.1 spec/views/curation_concerns/base/_form_rights_spec.rb