Sha256: 24c7ed282c47b67074e6e20ab2b63e22863f69d6502f0f7b63b530814756e2c2

Contents?: true

Size: 1.67 KB

Versions: 22

Compression:

Stored size: 1.67 KB

Contents

# frozen_string_literal: true

describe Spotlight::PagesController, type: :controller do
  routes { Spotlight::Engine.routes }
  let(:exhibit) { FactoryBot.create(:exhibit) }
  let(:feature_page) { FactoryBot.create(:feature_page, exhibit: exhibit, published: false) }
  let(:about_page) { FactoryBot.create(:about_page, exhibit: exhibit, published: false) }
  let(:update_all_params) do
    {
      exhibit: {
        pages_attributes: {
          0 => {
            id: feature_page.id,
            published: 1
          },
          1 => {
            id: about_page.id,
            published: 1
          }
        }
      }
    }
  end

  describe 'when signed in as a curator' do
    let(:user) { FactoryBot.create(:exhibit_curator, exhibit: exhibit) }

    before do
      sign_in user
    end

    it 'the feature and about pages are updated' do
      expect(Spotlight::Page.find(feature_page.id)).not_to be_published
      expect(Spotlight::Page.find(about_page.id)).not_to be_published
      put :update_all, params: update_all_params.merge(exhibit_id: exhibit.id)
      expect(Spotlight::Page.find(feature_page.id)).to be_published
      expect(Spotlight::Page.find(about_page.id)).to be_published
    end
  end

  describe 'when user is not authenticated' do
    it 'does not allow publishing pages' do
      put :update_all, params: update_all_params.merge(exhibit_id: exhibit.id)
      expect(Spotlight::Page.find(feature_page.id)).not_to be_published
      expect(Spotlight::Page.find(about_page.id)).not_to be_published
      expect(flash['alert']).to eq 'You need to sign in or sign up before continuing.'
      expect(response).to redirect_to main_app.new_user_session_path
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

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