Sha256: 7256e59f52e00dcb17f2884d9e9b8000cff56e2cd0a8c6fda94cb8b0ad56749d

Contents?: true

Size: 1.23 KB

Versions: 1

Compression:

Stored size: 1.23 KB

Contents

require 'spec_helper'

describe Worthwhile::ClassifyConcernsController do
  routes { Worthwhile::Engine.routes }
  let(:user) { FactoryGirl.create(:user) }

  describe '#new' do
    it 'requires authentication' do
      get :new
      expect(response).to redirect_to(main_app.user_session_path)
    end
    it 'renders when signed in' do
      sign_in(user)
      get :new
      expect(response).to be_successful
    end
  end

  describe '#create' do
    it 'redirect to login page if user is not logged in' do
      post :create, classify: { curation_concern_type: 'GenericWork' }
      expect(response).to redirect_to(main_app.user_session_path)
    end

    it 'requires authentication' do
      sign_in(user)
      # Had to stub the actual handling of curation_concern paths since those paths live outside the engine while the path to this controller lives inside the engine.
      new_curation_concern_generic_work_path = "/stub/path"
      subject.should_receive(:new_polymorphic_path).with([:curation_concern, GenericWork]).and_return(new_curation_concern_generic_work_path)
      post :create, classify_concern: { curation_concern_type: 'GenericWork' }
      expect(response).to redirect_to(new_curation_concern_generic_work_path)
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
worthwhile-0.0.1 spec/controllers/worthwhile/classify_concerns_controller_spec.rb