Sha256: cc0ad9ae8c7c0d7c86ffd37cd8155b12b940dc44cd981274be284dd3c1e69279

Contents?: true

Size: 1.64 KB

Versions: 1

Compression:

Stored size: 1.64 KB

Contents

require 'spec_helper'

describe Spotlight::ResourcesController, :type => :controller do
  routes { Spotlight::Engine.routes }
  let(:exhibit) { FactoryGirl.create(:exhibit) }

  describe "when not logged in" do

    describe "GET new" do
      it "should not be allowed" do
        get :new, exhibit_id: exhibit
        expect(response).to redirect_to main_app.new_user_session_path
      end
    end

    describe "POST create" do
      it "should not be allowed" do
        post :create, exhibit_id: exhibit
        expect(response).to redirect_to main_app.new_user_session_path
      end
    end
  end


  describe "when signed in as a curator" do
    let(:user) { FactoryGirl.create(:exhibit_curator, exhibit: exhibit) }
    before {sign_in user }

    describe "GET new" do

      it "should render form" do
        get :new, exhibit_id: exhibit
        expect(response).to render_template "spotlight/resources/new"
      end

      it "should populate the resource with parameters from the url" do
        get :new, exhibit_id: exhibit, resource: { url: "info:uri"}
        expect(assigns[:resource].url).to eq "info:uri"
      end

      describe "Within a popup" do
        it "should render with the simplified popup layout" do
          get :new, exhibit_id: exhibit, popup: true
          expect(response).to render_template "layouts/spotlight/popup"
        end
      end
    end

    describe "POST create" do
      it "create a resource" do
        allow_any_instance_of(Spotlight::Resource).to receive(:reindex)
        post :create, exhibit_id: exhibit, resource: { url: "info:uri" }
        expect(assigns[:resource]).to be_persisted
      end
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
blacklight-spotlight-0.2.0 spec/controllers/spotlight/resources_controller_spec.rb