Sha256: 3d636cea6cb916bcc433ecbb34a5e933c34106811308e48009cede3fe987feb9

Contents?: true

Size: 1.56 KB

Versions: 22

Compression:

Stored size: 1.56 KB

Contents

# frozen_string_literal: true

describe Spotlight::VersionsController, type: :controller, versioning: true do
  routes { Spotlight::Engine.routes }

  describe 'when not logged in' do
    describe 'POST revert' do
      it 'is not allowed' do
        post :revert, params: { id: 1 }
        expect(response).to redirect_to main_app.new_user_session_path
      end
    end
  end

  describe 'when not authorized for the exhibit resource' do
    let(:exhibit) { FactoryBot.create(:exhibit) }
    let(:user) { FactoryBot.create(:exhibit_visitor) }
    let!(:page) { FactoryBot.create(:feature_page, exhibit: exhibit) }

    before do
      sign_in user
    end

    describe 'POST revert' do
      it 'is not allowed' do
        post :revert, params: { id: page.versions.last }
        expect(response).to redirect_to main_app.root_path
        expect(flash[:alert]).to be_present
      end
    end
  end

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

    before do
      sign_in user
    end

    describe 'POST revert' do
      it 'reverts the change' do
        page.title = 'xyz'
        page.save!

        post :revert, params: { id: page.versions.last }
        page.reload
        expect(page.title).not_to eq 'xyz'
        expect(response).to redirect_to [exhibit, page]
        expect(flash[:notice]).to be_present
        expect(flash[:notice]).to match(/Redo changes/)
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

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