Commit fbd5f110 authored by Andrejs Cunskis's avatar Andrejs Cunskis

Fetch github repo id

parent e1c779cd
...@@ -24,7 +24,8 @@ module QA ...@@ -24,7 +24,8 @@ module QA
:visibility, :visibility,
:template_name, :template_name,
:import, :import,
:import_status :import_status,
:import_error
attribute :group do attribute :group do
Group.fabricate! Group.fabricate!
......
# frozen_string_literal: true # frozen_string_literal: true
require 'securerandom' require 'github_api'
module QA module QA
module Resource module Resource
class ProjectImportedFromGithub < Resource::Project class ProjectImportedFromGithub < Resource::Project
attribute :github_repo_id attribute :github_repo_id do
github_repository_path.split('/').yield_self do |path|
github_repos.get(user: path[0], repo: path[1]).id
end
end
def fabricate! def fabricate!
self.import = true self.import = true
...@@ -46,6 +50,15 @@ module QA ...@@ -46,6 +50,15 @@ module QA
def transform_api_resource(api_resource) def transform_api_resource(api_resource)
api_resource api_resource
end end
private
# Github repos client
#
# @return [Github::Client::Repos]
def github_repos
@github_repo ||= Github::Client::Repos.new(oauth_token: github_personal_access_token)
end
end end
end end
end end
...@@ -3,6 +3,9 @@ ...@@ -3,6 +3,9 @@
module QA module QA
RSpec.describe 'Manage', :github, :requires_admin do RSpec.describe 'Manage', :github, :requires_admin do
describe 'Project import' do describe 'Project import' do
let!(:github_user) { 'gitlab-qa-github' }
let!(:github_repo) { 'test-project' }
let!(:api_client) { Runtime::API::Client.as_admin } let!(:api_client) { Runtime::API::Client.as_admin }
let!(:group) { Resource::Group.fabricate_via_api! { |resource| resource.api_client = api_client } } let!(:group) { Resource::Group.fabricate_via_api! { |resource| resource.api_client = api_client } }
let!(:user) do let!(:user) do
...@@ -17,9 +20,8 @@ module QA ...@@ -17,9 +20,8 @@ module QA
project.name = 'imported-project' project.name = 'imported-project'
project.group = group project.group = group
project.github_personal_access_token = Runtime::Env.github_access_token project.github_personal_access_token = Runtime::Env.github_access_token
project.github_repository_path = 'gitlab-qa-github/test-project' project.github_repository_path = "#{github_user}/#{github_repo}"
project.api_client = api_client project.api_client = api_client
project.github_repo_id = '310217317' # id of 'test-project'
end end
end end
...@@ -50,7 +52,6 @@ module QA ...@@ -50,7 +52,6 @@ module QA
def verify_repository_import def verify_repository_import
expect(imported_project.api_response).to include( expect(imported_project.api_response).to include(
description: 'A new repo for test', description: 'A new repo for test',
import_status: 'finished',
import_error: nil import_error: nil
) )
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment