Sha256: d679d28fb2e449780b34a6c158dd7c942ea55994c438c99e1bd09e78015296c7

Contents?: true

Size: 1.81 KB

Versions: 22

Compression:

Stored size: 1.81 KB

Contents

# frozen_string_literal: true

describe 'spotlight/pages/edit', type: :view do
  let(:exhibit) { stub_model(Spotlight::Exhibit) }
  let(:page) { stub_model(Spotlight::FeaturePage, exhibit: exhibit) }

  before do
    assign(:page, page)
    allow(view).to receive_messages(configurations_for_current_page: {},
                                    featured_images_path: '/foo')
  end

  it 'renders the edit page form' do
    render

    # Run the generator again with the --webrat flag if you want to use webrat matchers
    assert_select 'form[action=?][method=?]', spotlight.exhibit_feature_page_path(page.exhibit, page), 'post' do
      assert_select 'input#feature_page_title[name=?]', 'feature_page[title]'
      assert_select 'textarea#feature_page_content[name=?]', 'feature_page[content]'
    end
  end

  describe 'locks' do
    let(:lock) { Spotlight::Lock.create! on: page }

    before do
      page.lock = lock
    end

    it 'renders a lock' do
      render

      expect(rendered).to have_css '.alert-lock'
    end

    it 'does not render an old lock' do
      lock.created_at -= 1.day

      render

      expect(rendered).not_to have_css '.alert-lock'
    end

    it 'does not render a lock held by the current session' do
      lock.current_session!

      render

      expect(rendered).not_to have_css '.alert-lock'
    end

    it 'attaches a data-lock attribute to the cancel button' do
      lock.current_session!

      render

      expect(rendered).to have_link 'Cancel'
      expect(rendered).to have_css "a[data-lock=\"#{url_for([spotlight, page.exhibit, lock])}\"]", text: 'Cancel'
    end

    it "does not have data-lock attribute if the lock doesn't belong to this session" do
      render

      expect(rendered).to have_link 'Cancel'
      expect(rendered).not_to have_css 'a[data-lock]', text: 'Cancel'
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
blacklight-spotlight-3.4.0 spec/views/spotlight/pages/edit.html.erb_spec.rb
blacklight-spotlight-3.3.0 spec/views/spotlight/pages/edit.html.erb_spec.rb
blacklight-spotlight-3.2.0 spec/views/spotlight/pages/edit.html.erb_spec.rb
blacklight-spotlight-3.1.0 spec/views/spotlight/pages/edit.html.erb_spec.rb
blacklight-spotlight-3.0.3 spec/views/spotlight/pages/edit.html.erb_spec.rb
blacklight-spotlight-3.0.2 spec/views/spotlight/pages/edit.html.erb_spec.rb
blacklight-spotlight-3.0.1 spec/views/spotlight/pages/edit.html.erb_spec.rb
blacklight-spotlight-3.0.0 spec/views/spotlight/pages/edit.html.erb_spec.rb
blacklight-spotlight-3.0.0.rc6 spec/views/spotlight/pages/edit.html.erb_spec.rb
blacklight-spotlight-3.0.0.rc5 spec/views/spotlight/pages/edit.html.erb_spec.rb
blacklight-spotlight-3.0.0.rc4 spec/views/spotlight/pages/edit.html.erb_spec.rb
blacklight-spotlight-3.0.0.rc3 spec/views/spotlight/pages/edit.html.erb_spec.rb
blacklight-spotlight-3.0.0.rc2 spec/views/spotlight/pages/edit.html.erb_spec.rb
blacklight-spotlight-3.0.0.rc1 spec/views/spotlight/pages/edit.html.erb_spec.rb
blacklight-spotlight-3.0.0.alpha.10 spec/views/spotlight/pages/edit.html.erb_spec.rb
blacklight-spotlight-3.0.0.alpha.9 spec/views/spotlight/pages/edit.html.erb_spec.rb
blacklight-spotlight-3.0.0.alpha.8 spec/views/spotlight/pages/edit.html.erb_spec.rb
blacklight-spotlight-3.0.0.alpha.7 spec/views/spotlight/pages/edit.html.erb_spec.rb
blacklight-spotlight-3.0.0.alpha.6 spec/views/spotlight/pages/edit.html.erb_spec.rb
blacklight-spotlight-3.0.0.alpha.5 spec/views/spotlight/pages/edit.html.erb_spec.rb