Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorValery Sizov <vsv2711@gmail.com>2015-04-06 16:36:56 +0300
committerValery Sizov <vsv2711@gmail.com>2015-04-06 19:45:16 +0300
commitbafec400f153153cad3920ff128e5ba4ccc8ebf7 (patch)
treebc1f4893abeea2f224ada8af654adb643f403336 /app
parent9c2301808b2d96d41d8972d114c9f77dd2b2471f (diff)
CI forking: tests
Diffstat (limited to 'app')
-rw-r--r--app/models/project_services/gitlab_ci_service.rb20
-rw-r--r--app/services/projects/fork_service.rb2
-rw-r--r--app/workers/fork_registration_worker.rb (renamed from app/workers/fork_registrator_worker.rb)4
3 files changed, 15 insertions, 11 deletions
diff --git a/app/models/project_services/gitlab_ci_service.rb b/app/models/project_services/gitlab_ci_service.rb
index d66a1331951..0f9838a575d 100644
--- a/app/models/project_services/gitlab_ci_service.rb
+++ b/app/models/project_services/gitlab_ci_service.rb
@@ -18,6 +18,8 @@
#
class GitlabCiService < CiService
+ API_PREFIX = "api/v1"
+
prop_accessor :project_url, :token
validates :project_url, presence: true, if: :activated?
validates :token, presence: true, if: :activated?
@@ -59,7 +61,7 @@ class GitlabCiService < CiService
end
end
- def register_fork(new_project, user_token)
+ def fork_registration(new_project, private_token)
params = {
id: new_project.id,
name_with_namespace: new_project.name_with_namespace,
@@ -69,12 +71,12 @@ class GitlabCiService < CiService
}
HTTParty.post(
- register_fork_path,
+ fork_registration_path,
body: {
project_id: project.id,
project_token: token,
- user_token: user_token,
- data: params.to_yaml},
+ private_token: private_token,
+ data: params },
verify: false
)
end
@@ -95,10 +97,6 @@ class GitlabCiService < CiService
project_url + "?ref=" + project.default_branch
end
- def register_fork_path
- project_url.sub(/projects\/\d*/, 'api/v1/forks')
- end
-
def status_img_path
project_url + "/status.png?ref=" + project.default_branch
end
@@ -121,4 +119,10 @@ class GitlabCiService < CiService
{ type: 'text', name: 'project_url', placeholder: 'http://ci.gitlabhq.com/projects/3' }
]
end
+
+ private
+
+ def fork_registration_path
+ project_url.sub(/projects\/\d*/, "#{API_PREFIX}/forks")
+ end
end
diff --git a/app/services/projects/fork_service.rb b/app/services/projects/fork_service.rb
index b5150fefc4c..4ec98696a65 100644
--- a/app/services/projects/fork_service.rb
+++ b/app/services/projects/fork_service.rb
@@ -50,7 +50,7 @@ module Projects
end
if @from_project.gitlab_ci?
- ForkRegistratorWorker.perform_async(@from_project.id, project.id, @current_user.private_token)
+ ForkRegistrationWorker.perform_async(@from_project.id, project.id, @current_user.private_token)
end
rescue => ex
project.errors.add(:base, 'Fork transaction failed.')
diff --git a/app/workers/fork_registrator_worker.rb b/app/workers/fork_registration_worker.rb
index 49d040d65ee..fffa8b3a659 100644
--- a/app/workers/fork_registrator_worker.rb
+++ b/app/workers/fork_registration_worker.rb
@@ -1,4 +1,4 @@
-class ForkRegistratorWorker
+class ForkRegistrationWorker
include Sidekiq::Worker
sidekiq_options queue: :default
@@ -7,6 +7,6 @@ class ForkRegistratorWorker
from_project = Project.find(from_project_id)
to_project = Project.find(to_project_id)
- from_project.gitlab_ci_service.register_fork(to_project, private_token)
+ from_project.gitlab_ci_service.fork_registration(to_project, private_token)
end
end