Sha256: 18438b36eb17aefd2fa4c7e466df61efad5c03e966d439e3c7263e250243e88d

Contents?: true

Size: 1.23 KB

Versions: 7

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(dashboard_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

7 entries across 7 versions & 1 rubygems

Version Path
curate-0.3.2 spec/controllers/help_requests_controller_spec.rb
curate-0.3.1 spec/controllers/help_requests_controller_spec.rb
curate-0.2.0 spec/controllers/help_requests_controller_spec.rb
curate-0.1.3 spec/controllers/help_requests_controller_spec.rb
curate-0.1.2 spec/controllers/help_requests_controller_spec.rb
curate-0.1.1 spec/controllers/help_requests_controller_spec.rb
curate-0.1.0 spec/controllers/help_requests_controller_spec.rb