1
0
mirror of https://github.com/projekteuler/projekteuler.git synced 2026-01-26 18:18:51 +01:00

Add authentication via GitHub

This commit is contained in:
2019-02-04 16:06:09 +01:00
parent 8ba5608689
commit f70a5275f0
8 changed files with 50 additions and 3 deletions

View File

@@ -0,0 +1,19 @@
require 'test_helper'
class TranslatorFlowTest < ActionDispatch::IntegrationTest
test "can view a problem" do
get '/problems/1'
assert_response :success
assert_select "h1", "First title Problem 1"
end
test "can login via github" do
get '/users/auth/github'
assert_response :redirect
follow_redirect!
follow_redirect!
assert_response :success
assert controller.user_signed_in?
assert_equal "translator", controller.current_user.name
end
end

View File

@@ -20,3 +20,13 @@ class ActiveSupport::TestCase
sign_in translator
end
end
class ActionDispatch::IntegrationTest
OmniAuth.config.test_mode = true
OmniAuth.config.mock_auth[:github] = OmniAuth::AuthHash.new({
provider: :github,
uid: 'translator',
name: 'translator'
})
end