gitlab-org--gitlab-foss/spec/controllers/import/github_controller_spec.rb

49 lines
1.3 KiB
Ruby
Raw Normal View History

2014-12-31 13:07:48 +00:00
require 'spec_helper'
2015-02-03 01:01:07 +00:00
describe Import::GithubController do
include ImportSpecHelper
let(:provider) { :github }
include_context 'a GitHub-ish import controller'
2014-12-31 13:07:48 +00:00
describe "GET new" do
it_behaves_like 'a GitHub-ish import controller: GET new'
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)
get :new
end
end
2014-12-31 13:07:48 +00:00
describe "GET callback" do
it "updates access token" do
token = "asdasd12345"
allow_any_instance_of(Gitlab::GithubImport::Client).
to receive(:get_token).and_return(token)
allow_any_instance_of(Gitlab::GithubImport::Client).
to receive(:github_options).and_return({})
stub_omniauth_provider('github')
2014-12-31 13:07:48 +00:00
get :callback
expect(session[:github_access_token]).to eq(token)
expect(controller).to redirect_to(status_import_github_url)
2014-12-31 13:07:48 +00:00
end
end
describe "POST personal_access_token" do
it_behaves_like 'a GitHub-ish import controller: POST personal_access_token'
end
2014-12-31 13:07:48 +00:00
describe "GET status" do
it_behaves_like 'a GitHub-ish import controller: GET status'
2014-12-31 13:07:48 +00:00
end
describe "POST create" do
it_behaves_like 'a GitHub-ish import controller: POST create'
2014-12-31 13:07:48 +00:00
end
end