2014-12-31 13:07:48 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2015-02-03 01:01:07 +00:00
|
|
|
describe Import::GithubController do
|
2015-05-21 21:40:13 +00:00
|
|
|
include ImportSpecHelper
|
|
|
|
|
2016-12-15 16:31:14 +00:00
|
|
|
let(:provider) { :github }
|
2015-08-07 07:06:20 +00:00
|
|
|
|
2016-12-15 16:31:14 +00:00
|
|
|
include_context 'a GitHub-ish import controller'
|
2014-12-31 13:07:48 +00:00
|
|
|
|
2016-05-02 15:22:38 +00:00
|
|
|
describe "GET new" do
|
2016-12-15 16:31:14 +00:00
|
|
|
it_behaves_like 'a GitHub-ish import controller: GET new'
|
2016-05-02 15:22:38 +00:00
|
|
|
|
2016-12-15 16:31:14 +00:00
|
|
|
it "redirects to GitHub for an access token if logged in with GitHub" do
|
|
|
|
allow(controller).to receive(:logged_in_with_provider?).and_return(true)
|
|
|
|
expect(controller).to receive(:go_to_provider_for_permissions)
|
2016-05-02 15:22:38 +00:00
|
|
|
|
|
|
|
get :new
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-12-31 13:07:48 +00:00
|
|
|
describe "GET callback" do
|
|
|
|
it "updates access token" do
|
|
|
|
token = "asdasd12345"
|
2015-02-12 18:32:58 +00:00
|
|
|
allow_any_instance_of(Gitlab::GithubImport::Client).
|
|
|
|
to receive(:get_token).and_return(token)
|
2016-04-22 19:43:10 +00:00
|
|
|
allow_any_instance_of(Gitlab::GithubImport::Client).
|
|
|
|
to receive(:github_options).and_return({})
|
2015-05-21 21:40:13 +00:00
|
|
|
stub_omniauth_provider('github')
|
2014-12-31 13:07:48 +00:00
|
|
|
|
|
|
|
get :callback
|
2015-02-12 18:32:58 +00:00
|
|
|
|
2016-12-16 16:43:34 +00:00
|
|
|
expect(session[:github_access_token]).to eq(token)
|
2015-02-12 18:17:35 +00:00
|
|
|
expect(controller).to redirect_to(status_import_github_url)
|
2014-12-31 13:07:48 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-05-02 15:22:38 +00:00
|
|
|
describe "POST personal_access_token" do
|
2016-12-15 16:31:14 +00:00
|
|
|
it_behaves_like 'a GitHub-ish import controller: POST personal_access_token'
|
2016-05-02 15:22:38 +00:00
|
|
|
end
|
|
|
|
|
2014-12-31 13:07:48 +00:00
|
|
|
describe "GET status" do
|
2016-12-15 16:31:14 +00:00
|
|
|
it_behaves_like 'a GitHub-ish import controller: GET status'
|
2014-12-31 13:07:48 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
describe "POST create" do
|
2016-12-15 16:31:14 +00:00
|
|
|
it_behaves_like 'a GitHub-ish import controller: POST create'
|
2014-12-31 13:07:48 +00:00
|
|
|
end
|
|
|
|
end
|