Sha256: a18bba8c744b7191422622e9521c4482c6878c96082fba595cde7da8412cd307

Contents?: true

Size: 1.88 KB

Versions: 28

Compression:

Stored size: 1.88 KB

Contents

require 'spec_helper'

module Spotlight
  describe 'spotlight/pages/edit', type: :view do
    let(:exhibit) { stub_model(Exhibit) }
    let(:page) { stub_model(FeaturePage, exhibit: exhibit) }
    before do
      assign(:page, page)
      allow(view).to receive_messages(default_thumbnail_jcrop_options: {}, available_index_fields: [], available_view_fields: [])
    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) { 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
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
blacklight-spotlight-0.19.0 spec/views/spotlight/pages/edit.html.erb_spec.rb
blacklight-spotlight-0.18.0 spec/views/spotlight/pages/edit.html.erb_spec.rb
blacklight-spotlight-0.17.1 spec/views/spotlight/pages/edit.html.erb_spec.rb
blacklight-spotlight-0.17.0 spec/views/spotlight/pages/edit.html.erb_spec.rb
blacklight-spotlight-0.16.0 spec/views/spotlight/pages/edit.html.erb_spec.rb
blacklight-spotlight-0.15.0 spec/views/spotlight/pages/edit.html.erb_spec.rb
blacklight-spotlight-0.14.2 spec/views/spotlight/pages/edit.html.erb_spec.rb
blacklight-spotlight-0.14.1 spec/views/spotlight/pages/edit.html.erb_spec.rb
blacklight-spotlight-0.14.0 spec/views/spotlight/pages/edit.html.erb_spec.rb
blacklight-spotlight-0.13.0 spec/views/spotlight/pages/edit.html.erb_spec.rb
blacklight-spotlight-0.12.1 spec/views/spotlight/pages/edit.html.erb_spec.rb
blacklight-spotlight-0.12.0 spec/views/spotlight/pages/edit.html.erb_spec.rb
blacklight-spotlight-0.11.0 spec/views/spotlight/pages/edit.html.erb_spec.rb
blacklight-spotlight-0.10.3 spec/views/spotlight/pages/edit.html.erb_spec.rb
blacklight-spotlight-0.10.2 spec/views/spotlight/pages/edit.html.erb_spec.rb
blacklight-spotlight-0.10.1 spec/views/spotlight/pages/edit.html.erb_spec.rb
blacklight-spotlight-0.10.0 spec/views/spotlight/pages/edit.html.erb_spec.rb
blacklight-spotlight-0.9.2 spec/views/spotlight/pages/edit.html.erb_spec.rb
blacklight-spotlight-0.9.1 spec/views/spotlight/pages/edit.html.erb_spec.rb
blacklight-spotlight-0.9.0 spec/views/spotlight/pages/edit.html.erb_spec.rb