Sha256: 72878621fdfa47bfd997f744c35b5870b4266302124ee2b9a7519a79b0d7b299

Contents?: true

Size: 1.23 KB

Versions: 13

Compression:

Stored size: 1.23 KB

Contents

require 'spec_helper'

describe HelpRequestsController do
  render_views
  describe 'GET #new' do
    let(:user) { FactoryGirl.create(:user) }
    it 'is disallowed when not logged in' do
      get(:new)
      expect(response.status).to eq(302)
      expect(response).to redirect_to(new_user_session_path)
    end
    it 'requires login' do
      sign_in(user)
      get(:new)
      expect(response.status).to eq(200)
      expect(response).to render_template('new')
    end
  end

  describe 'POST #create' do
    let(:user) { FactoryGirl.create(:user) }
    let(:attributes) { {} }
    describe 'success' do
      let(:attributes) { FactoryGirl.attributes_for(:help_request) }
      it 'redirects to dashboard and flashes a message' do
        sign_in(user)
        post(:create, help_request: attributes)
        expect(response.status).to eq(302)
        expect(response).to redirect_to(catalog_index_path)
      end
    end
    describe 'failure' do
      let(:attributes) { FactoryGirl.attributes_for(:help_request_invalid) }
      it 're-renders the form' do
        sign_in(user)
        post(:create, help_request: attributes)
        expect(response.status).to eq(200)
        expect(response).to render_template('new')
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
curate-0.6.6 spec/controllers/help_requests_controller_spec.rb
curate-0.6.5 spec/controllers/help_requests_controller_spec.rb
curate-0.6.4 spec/controllers/help_requests_controller_spec.rb
curate-0.6.3 spec/controllers/help_requests_controller_spec.rb
curate-0.6.1 spec/controllers/help_requests_controller_spec.rb
curate-0.6.0 spec/controllers/help_requests_controller_spec.rb
curate-0.5.6 spec/controllers/help_requests_controller_spec.rb
curate-0.5.5 spec/controllers/help_requests_controller_spec.rb
curate-0.5.4 spec/controllers/help_requests_controller_spec.rb
curate-0.5.2 spec/controllers/help_requests_controller_spec.rb
curate-0.5.1 spec/controllers/help_requests_controller_spec.rb
curate-0.5.0 spec/controllers/help_requests_controller_spec.rb
curate-0.4.2 spec/controllers/help_requests_controller_spec.rb