Sha256: c86ce0c0ef91eb3931ecd86d2a2a79388cb725297daf018b64eb07ade1006d5c

Contents?: true

Size: 1.71 KB

Versions: 8

Compression:

Stored size: 1.71 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__) }
    stub_const("Qa::Authorities::LocalSubauthority::AUTHORITIES_CONFIG", 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

8 entries across 8 versions & 1 rubygems

Version Path
curation_concerns-1.1.0 spec/views/curation_concerns/base/_form_rights_spec.rb
curation_concerns-1.0.0 spec/views/curation_concerns/base/_form_rights_spec.rb
curation_concerns-1.0.0.beta10 spec/views/curation_concerns/base/_form_rights_spec.rb
curation_concerns-1.0.0.beta9 spec/views/curation_concerns/base/_form_rights_spec.rb
curation_concerns-1.0.0.beta8 spec/views/curation_concerns/base/_form_rights_spec.rb
curation_concerns-1.0.0.beta7 spec/views/curation_concerns/base/_form_rights_spec.rb
curation_concerns-1.0.0.beta6 spec/views/curation_concerns/base/_form_rights_spec.rb
curation_concerns-1.0.0.beta5 spec/views/curation_concerns/base/_form_rights_spec.rb