Sha256: 4a22e2fedd2ab751ab30a0b4eda13794691a001db6aebaea5d3ad5a42a98fbd9

Contents?: true

Size: 1020 Bytes

Versions: 3

Compression:

Stored size: 1020 Bytes

Contents

require 'spec_helper'

module OpenStax::Accounts
  describe SessionsController, type: :controller do
    routes { Engine.routes }

    let!(:account) { FactoryGirl.create :openstax_accounts_account,
                                        username: 'some_user',
                                        openstax_uid: 10 }

    it 'should redirect users to the login path' do
      c = controller
      get :new
      expect(response).to redirect_to(
        c.send(:with_interceptor) { c.dev_accounts_path })
      expect(response.code).to eq('302')
    end

    it 'should authenticate users based on the oauth callback' do
      # TODO
    end

    it 'should let users logout' do
      controller.sign_in account
      expect(controller.current_account).to eq(account)
      expect(controller.current_account.is_anonymous?).to eq(false)
      delete :destroy
      expect(controller.current_account).to eq(AnonymousAccount.instance)
      expect(controller.current_account.is_anonymous?).to eq(true)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
openstax_accounts-3.1.1 spec/controllers/openstax/accounts/sessions_controller_spec.rb
openstax_accounts-3.1.0 spec/controllers/openstax/accounts/sessions_controller_spec.rb
openstax_accounts-3.0.0 spec/controllers/openstax/accounts/sessions_controller_spec.rb