Sha256: b367d1aaa719944cbeaf06ef31518035b3cc5b6d4596469b2813d3bfdfa26e45

Contents?: true

Size: 1.06 KB

Versions: 6

Compression:

Stored size: 1.06 KB

Contents

require 'test_helper'

class RailsSso::SessionsControllerTest < ActionController::TestCase
  def setup
    @routes = RailsSso::Engine.routes

    @auth_hash = OmniAuth::AuthHash.new({
      provider: 'developer',
      uid: '1',
      name: 'Kowalski',
      email: 'jan@kowalski.pl',
      key: 'value'
    })

    OmniAuth.config.mock_auth[:developer] = @auth_hash

    request.env['omniauth.auth'] = OmniAuth.config.mock_auth[:developer]
  end

  def teardown
    OmniAuth.config.mock_auth[:developer] = nil
  end

  test 'create should save access token and redirect to root path' do
    @controller.expects(:sign_in_with_access_token!).with(@auth_hash.credentials).once

    get :create, { provider: 'developer' }

    assert_redirected_to main_app.root_path
  end

  test 'destroy should invalidate access token and redirect to root path' do
    @controller.expects(:sign_out!).once

    delete :destroy, {}, { access_token: 'abc', refresh_token: 'def' }

    assert_redirected_to main_app.root_path
  end

  def main_app
    Rails.application.class.routes.url_helpers
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rails_sso-0.7.5 test/controllers/rails_sso/sessions_controller_test.rb
rails_sso-0.7.4 test/controllers/rails_sso/sessions_controller_test.rb
rails_sso-0.7.3 test/controllers/rails_sso/sessions_controller_test.rb
rails_sso-0.7.2 test/controllers/rails_sso/sessions_controller_test.rb
rails_sso-0.7.1 test/controllers/rails_sso/sessions_controller_test.rb
rails_sso-0.7.0 test/controllers/rails_sso/sessions_controller_test.rb