Sha256: dfac1b27e1d22a8fe9c5ef15205daea518263a4f816f20bf78ba193aff64a7fa

Contents?: true

Size: 1.37 KB

Versions: 5

Compression:

Stored size: 1.37 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
    context 'without logging in' 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
    end

    context 'when logged in' do
      before 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.
        expect(subject).to receive(:new_polymorphic_path).with([:curation_concern, GenericWork]).and_return(new_curation_concern_generic_work_path)
      end

      let(:new_curation_concern_generic_work_path) { "/stub/path" }

      it 'requires authentication' do
        post :create, classify_concern: { curation_concern_type: 'GenericWork' }
        expect(response).to redirect_to(new_curation_concern_generic_work_path)
      end
   end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
worthwhile-0.1.2 spec/controllers/worthwhile/classify_concerns_controller_spec.rb
worthwhile-0.1.1 spec/controllers/worthwhile/classify_concerns_controller_spec.rb
worthwhile-0.1.0 spec/controllers/worthwhile/classify_concerns_controller_spec.rb
worthwhile-0.0.3 spec/controllers/worthwhile/classify_concerns_controller_spec.rb
worthwhile-0.0.2 spec/controllers/worthwhile/classify_concerns_controller_spec.rb