blob: d0aaaae6a11d229742966919fc2c6fd947193e08 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
# frozen_string_literal: true
module QA
module Resource
class Fork < Base
attribute :name do
upstream.name
end
attribute :project do
Resource::Project.fabricate_via_api! do |resource|
resource.add_name_uuid = false
resource.name = name
resource.path_with_namespace = "#{user.username}/#{name}"
end
end
attribute :upstream do
Repository::ProjectPush.fabricate!.project
end
attribute :user do
User.fabricate_via_api! do |resource|
if Runtime::Env.forker?
resource.username = Runtime::Env.forker_username
resource.password = Runtime::Env.forker_password
end
end
end
def fabricate!
populate(:upstream, :user)
# Sign out as admin and sign is as the fork user
Page::Main::Menu.perform(&:sign_out)
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform do |login|
login.sign_in_using_credentials(user: user)
end
upstream.visit!
Page::Project::Show.perform(&:fork_project)
Page::Project::Fork::New.perform do |fork_new|
fork_new.choose_namespace(user.name)
end
Page::Layout::Banner.perform do |banner|
banner.has_notice?('The project was successfully forked.')
end
populate(:project)
end
def fabricate_via_api!
populate(:upstream, :user)
@api_client = Runtime::API::Client.new(:gitlab, is_new_session: false, user: user)
Runtime::Logger.debug("Forking project #{upstream.name} to namespace #{user.username}...")
super
wait_until_forked
populate(:project)
end
def api_get_path
"/projects/#{CGI.escape(path_with_namespace)}"
end
def api_post_path
"/projects/#{upstream.id}/fork"
end
def api_post_body
{
namespace_path: user.username,
name: name,
path: name
}
end
def wait_until_forked
Runtime::Logger.debug("Waiting for the fork process to complete...")
forked = wait_until do
project.import_status == "finished"
end
raise "Timed out while waiting for the fork process to complete." unless forked
end
end
end
end
|