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:
19
test/integration/translator_flow_test.rb
Normal file
19
test/integration/translator_flow_test.rb
Normal 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
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user