Commit fbd5f110 authored by Andrejs Cunskis's avatar Andrejs Cunskis

Fetch github repo id

parent e1c779cd
......@@ -24,7 +24,8 @@ module QA
:visibility,
:template_name,
:import,
:import_status
:import_status,
:import_error
attribute :group do
Group.fabricate!
......
# frozen_string_literal: true
require 'securerandom'
require 'github_api'
module QA
module Resource
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!
self.import = true
......@@ -46,6 +50,15 @@ module QA
def transform_api_resource(api_resource)
api_resource
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
......@@ -3,6 +3,9 @@
module QA
RSpec.describe 'Manage', :github, :requires_admin 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!(:group) { Resource::Group.fabricate_via_api! { |resource| resource.api_client = api_client } }
let!(:user) do
......@@ -17,9 +20,8 @@ module QA
project.name = 'imported-project'
project.group = group
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.github_repo_id = '310217317' # id of 'test-project'
end
end
......@@ -50,7 +52,6 @@ module QA
def verify_repository_import
expect(imported_project.api_response).to include(
description: 'A new repo for test',
import_status: 'finished',
import_error: nil
)
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