diff options
Diffstat (limited to 'spec/controllers/import/github_controller_spec.rb')
-rw-r--r-- | spec/controllers/import/github_controller_spec.rb | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/spec/controllers/import/github_controller_spec.rb b/spec/controllers/import/github_controller_spec.rb index 5f2a09280b2..0bc14059a35 100644 --- a/spec/controllers/import/github_controller_spec.rb +++ b/spec/controllers/import/github_controller_spec.rb @@ -1,11 +1,14 @@ require 'spec_helper' +require_relative 'import_spec_helper' describe Import::GithubController do + include ImportSpecHelper + let(:user) { create(:user, github_access_token: 'asd123') } before do sign_in(user) - controller.stub(:github_import_enabled?).and_return(true) + allow(controller).to receive(:github_import_enabled?).and_return(true) end describe "GET callback" do @@ -13,9 +16,7 @@ describe Import::GithubController do token = "asdasd12345" allow_any_instance_of(Gitlab::GithubImport::Client). to receive(:get_token).and_return(token) - Gitlab.config.omniauth.providers << OpenStruct.new(app_id: 'asd123', - app_secret: 'asd123', - name: 'github') + stub_omniauth_provider('github') get :callback @@ -33,9 +34,7 @@ describe Import::GithubController do it "assigns variables" do @project = create(:project, import_type: 'github', creator_id: user.id) - controller.stub_chain(:client, :repos).and_return([@repo]) - controller.stub_chain(:client, :orgs).and_return([@org]) - controller.stub_chain(:client, :org_repos).with(@org.login).and_return([@org_repo]) + stub_client(repos: [@repo], orgs: [@org], org_repos: [@org_repo]) get :status @@ -45,8 +44,7 @@ describe Import::GithubController do it "does not show already added project" do @project = create(:project, import_type: 'github', creator_id: user.id, import_source: 'asd/vim') - controller.stub_chain(:client, :repos).and_return([@repo]) - controller.stub_chain(:client, :orgs).and_return([]) + stub_client(repos: [@repo], orgs: []) get :status @@ -67,8 +65,7 @@ describe Import::GithubController do end before do - controller.stub_chain(:client, :user).and_return(github_user) - controller.stub_chain(:client, :repo).and_return(github_repo) + stub_client(user: github_user, repo: github_repo) end context "when the repository owner is the GitHub user" do |