diff options
| author | Dmitriy Zaporozhets <dzaporozhets@gitlab.com> | 2015-01-17 02:16:22 +0000 |
|---|---|---|
| committer | Dmitriy Zaporozhets <dzaporozhets@gitlab.com> | 2015-01-17 02:16:22 +0000 |
| commit | 82d8559fcd1d54869d6124c19e6da2fa7616369e (patch) | |
| tree | f7fd7261ec42804a029261a2aa4a44db26bb1a23 /spec/support | |
| parent | 9c74a32c984d9704db7dcf20c31e19fd7f9ad176 (diff) | |
| parent | ba74821d9c4e32577f9359e2b6f8b84975333303 (diff) | |
| download | gitlab-ci-82d8559fcd1d54869d6124c19e6da2fa7616369e.tar.gz | |
Merge branch 'oauth' into 'master'
Oauth2
See merge request !104
Diffstat (limited to 'spec/support')
| -rw-r--r-- | spec/support/login_helpers.rb | 5 | ||||
| -rw-r--r-- | spec/support/monkey_patches/oauth2.rb | 7 | ||||
| -rw-r--r-- | spec/support/stub_gitlab_calls.rb | 11 |
3 files changed, 18 insertions, 5 deletions
diff --git a/spec/support/login_helpers.rb b/spec/support/login_helpers.rb index 1f810d3..ebd9693 100644 --- a/spec/support/login_helpers.rb +++ b/spec/support/login_helpers.rb @@ -9,10 +9,7 @@ module LoginHelpers # # user - User instance to login with def login_with(user) - visit new_user_sessions_path - fill_in "user_session_email", with: 'test@test.com' - fill_in "user_session_password", with: "123456" - click_button "Sign in" + visit callback_user_sessions_path(code: "some_auth_code_here") end def logout diff --git a/spec/support/monkey_patches/oauth2.rb b/spec/support/monkey_patches/oauth2.rb new file mode 100644 index 0000000..dfd5e31 --- /dev/null +++ b/spec/support/monkey_patches/oauth2.rb @@ -0,0 +1,7 @@ +module OAuth2 + class Client + def get_token(params, access_token_opts = {}, access_token_class = AccessToken) + OpenStruct.new(token: "some_token") + end + end +end
\ No newline at end of file diff --git a/spec/support/stub_gitlab_calls.rb b/spec/support/stub_gitlab_calls.rb index a0624ab..6c047ec 100644 --- a/spec/support/stub_gitlab_calls.rb +++ b/spec/support/stub_gitlab_calls.rb @@ -2,6 +2,7 @@ module StubGitlabCalls def stub_gitlab_calls stub_session stub_user + stub_oauth_user stub_project_8 stub_project_8_hooks stub_projects @@ -15,7 +16,7 @@ module StubGitlabCalls private def gitlab_url - GitlabCi.config.gitlab_server_urls.first + GitlabCi.config.gitlab_server.url end def stub_session @@ -35,6 +36,14 @@ module StubGitlabCalls to_return(:status => 200, :body => f, :headers => {'Content-Type'=>'application/json'}) end + def stub_oauth_user + f = File.read(Rails.root.join('spec/support/gitlab_stubs/user.json')) + + stub_request(:get, "#{gitlab_url}api/v3/user"). + with(:headers => {'Content-Type'=>'application/json'}). + to_return(:status => 200, :body => f, :headers => {'Content-Type'=>'application/json'}) + end + def stub_project_8 f = File.read(Rails.root.join('spec/support/gitlab_stubs/project_8.json')) |
