summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/ci/projects_controller_spec.rb43
-rw-r--r--spec/lib/gitlab/backend/grack_auth_spec.rb1
-rw-r--r--spec/models/project_services/buildkite_service_spec.rb14
-rw-r--r--spec/models/project_services/gitlab_ci_service_spec.rb50
-rw-r--r--spec/requests/api/projects_spec.rb2
-rw-r--r--spec/requests/api/services_spec.rb4
-rw-r--r--spec/requests/ci/api/forks_spec.rb59
-rw-r--r--spec/services/ci/create_project_service_spec.rb4
-rw-r--r--spec/services/projects/fork_service_spec.rb3
-rw-r--r--spec/workers/fork_registration_worker_spec.rb10
10 files changed, 16 insertions, 174 deletions
diff --git a/spec/controllers/ci/projects_controller_spec.rb b/spec/controllers/ci/projects_controller_spec.rb
index c7a3cd50c20..3e579f9a7d6 100644
--- a/spec/controllers/ci/projects_controller_spec.rb
+++ b/spec/controllers/ci/projects_controller_spec.rb
@@ -5,49 +5,6 @@ describe Ci::ProjectsController do
@project = FactoryGirl.create :ci_project
end
- describe "POST #build" do
- it 'should respond 200 if params is ok' do
- post :build, {
- id: @project.id,
- ref: 'master',
- before: '2aa371379db71ac89ae20843fcff3b3477cf1a1d',
- after: '1c8a9df454ef68c22c2a33cca8232bb50849e5c5',
- token: @project.token,
- ci_yaml_file: gitlab_ci_yaml,
- commits: [ { message: "Message" } ]
- }
-
- expect(response).to be_success
- expect(response.code).to eq('201')
- end
-
- it 'should respond 400 if push about removed branch' do
- post :build, {
- id: @project.id,
- ref: 'master',
- before: '2aa371379db71ac89ae20843fcff3b3477cf1a1d',
- after: '0000000000000000000000000000000000000000',
- token: @project.token,
- ci_yaml_file: gitlab_ci_yaml
- }
-
- expect(response).not_to be_success
- expect(response.code).to eq('400')
- end
-
- it 'should respond 400 if some params missed' do
- post :build, id: @project.id, token: @project.token, ci_yaml_file: gitlab_ci_yaml
- expect(response).not_to be_success
- expect(response.code).to eq('400')
- end
-
- it 'should respond 403 if token is wrong' do
- post :build, id: @project.id, token: 'invalid-token'
- expect(response).not_to be_success
- expect(response.code).to eq('403')
- end
- end
-
describe "POST /projects" do
let(:project_dump) { OpenStruct.new({ id: @project.gitlab_id }) }
diff --git a/spec/lib/gitlab/backend/grack_auth_spec.rb b/spec/lib/gitlab/backend/grack_auth_spec.rb
index d9676445908..9bed8f8ee5c 100644
--- a/spec/lib/gitlab/backend/grack_auth_spec.rb
+++ b/spec/lib/gitlab/backend/grack_auth_spec.rb
@@ -180,7 +180,6 @@ describe Grack::Auth do
gitlab_ci_service = project.build_gitlab_ci_service
gitlab_ci_service.active = true
gitlab_ci_service.token = token
- gitlab_ci_service.project_url = "http://google.com"
gitlab_ci_service.save
env["HTTP_AUTHORIZATION"] = ActionController::HttpAuthentication::Basic.encode_credentials("gitlab-ci-token", token)
diff --git a/spec/models/project_services/buildkite_service_spec.rb b/spec/models/project_services/buildkite_service_spec.rb
index 9445d96c337..230807ea672 100644
--- a/spec/models/project_services/buildkite_service_spec.rb
+++ b/spec/models/project_services/buildkite_service_spec.rb
@@ -63,19 +63,5 @@ describe BuildkiteService do
)
end
end
-
- describe :builds_page do
- it 'returns the correct path to the builds page' do
- expect(@service.builds_path).to eq(
- 'https://buildkite.com/account-name/example-project/builds?branch=default-brancho'
- )
- end
- end
-
- describe :status_img_path do
- it 'returns the correct path to the status image' do
- expect(@service.status_img_path).to eq('https://badge.buildkite.com/secret-sauce-status-token.svg')
- end
- end
end
end
diff --git a/spec/models/project_services/gitlab_ci_service_spec.rb b/spec/models/project_services/gitlab_ci_service_spec.rb
index a14384c87b4..e0da04a3f40 100644
--- a/spec/models/project_services/gitlab_ci_service_spec.rb
+++ b/spec/models/project_services/gitlab_ci_service_spec.rb
@@ -26,51 +26,21 @@ describe GitlabCiService do
it { is_expected.to have_one(:service_hook) }
end
- describe 'validations' do
- context 'active' do
- before { allow(subject).to receive(:activated?).and_return(true) }
-
- it { is_expected.to validate_presence_of(:token) }
- it { is_expected.to validate_presence_of(:project_url) }
- it { is_expected.to allow_value('ewf9843kdnfdfs89234n').for(:token) }
- it { is_expected.to allow_value('http://ci.example.com/project/1').for(:project_url) }
- it { is_expected.not_to allow_value('token with spaces').for(:token) }
- it { is_expected.not_to allow_value('token/with%spaces').for(:token) }
- it { is_expected.not_to allow_value('this is not url').for(:project_url) }
- it { is_expected.not_to allow_value('http//noturl').for(:project_url) }
- it { is_expected.not_to allow_value('ftp://ci.example.com/projects/3').for(:project_url) }
- end
-
- context 'inactive' do
- before { allow(subject).to receive(:activated?).and_return(false) }
-
- it { is_expected.not_to validate_presence_of(:token) }
- it { is_expected.not_to validate_presence_of(:project_url) }
- it { is_expected.to allow_value('ewf9843kdnfdfs89234n').for(:token) }
- it { is_expected.to allow_value('http://ci.example.com/project/1').for(:project_url) }
- it { is_expected.to allow_value('token with spaces').for(:token) }
- it { is_expected.to allow_value('ftp://ci.example.com/projects/3').for(:project_url) }
- end
- end
-
describe 'commits methods' do
before do
+ @ci_project = create(:ci_project)
@service = GitlabCiService.new
allow(@service).to receive_messages(
service_hook: true,
project_url: 'http://ci.gitlab.org/projects/2',
- token: 'verySecret'
+ token: 'verySecret',
+ project: @ci_project.gl_project
)
end
- describe :commit_status_path do
- it { expect(@service.commit_status_path("2ab7834c", 'master')).to eq("http://ci.gitlab.org/projects/2/refs/master/commits/2ab7834c/status.json?token=verySecret")}
- it { expect(@service.commit_status_path("issue#2", 'master')).to eq("http://ci.gitlab.org/projects/2/refs/master/commits/issue%232/status.json?token=verySecret")}
- end
-
describe :build_page do
- it { expect(@service.build_page("2ab7834c", 'master')).to eq("http://ci.gitlab.org/projects/2/refs/master/commits/2ab7834c")}
- it { expect(@service.build_page("issue#2", 'master')).to eq("http://ci.gitlab.org/projects/2/refs/master/commits/issue%232")}
+ it { expect(@service.build_page("2ab7834c", 'master')).to eq("/ci/projects/#{@ci_project.id}/refs/master/commits/2ab7834c")}
+ it { expect(@service.build_page("issue#2", 'master')).to eq("/ci/projects/#{@ci_project.id}/refs/master/commits/issue%232")}
end
describe "execute" do
@@ -80,8 +50,6 @@ describe GitlabCiService do
it "calls ci_yaml_file" do
service_hook = double
- expect(service_hook).to receive(:execute)
- expect(@service).to receive(:service_hook).and_return(service_hook)
expect(@service).to receive(:ci_yaml_file).with(push_sample_data[:checkout_sha])
@service.execute(push_sample_data)
@@ -91,7 +59,7 @@ describe GitlabCiService do
describe "Fork registration" do
before do
- @old_project = create(:empty_project)
+ @old_project = create(:ci_project).gl_project
@project = create(:empty_project)
@user = create(:user)
@@ -104,9 +72,9 @@ describe GitlabCiService do
)
end
- it "performs http reuquest to ci" do
- stub_request(:post, "http://ci.gitlab.org/api/v1/forks")
- @service.fork_registration(@project, @user.private_token)
+ it "creates fork on CI" do
+ expect_any_instance_of(Ci::CreateProjectService).to receive(:execute)
+ @service.fork_registration(@project, @user)
end
end
end
diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb
index 5bd8206b890..3007a15b0b1 100644
--- a/spec/requests/api/projects_spec.rb
+++ b/spec/requests/api/projects_spec.rb
@@ -89,7 +89,7 @@ describe API::API, api: true do
it 'returns projects in the correct order when ci_enabled_first parameter is passed' do
[project, project2, project3].each{ |project| project.build_missing_services }
- project2.gitlab_ci_service.update(active: true, token: "token", project_url: "http://ci.example.com/projects/1")
+ project2.gitlab_ci_service.update(active: true, token: "token")
get api('/projects', user), { ci_enabled_first: 'true' }
expect(response.status).to eq(200)
expect(json_response).to be_an Array
diff --git a/spec/requests/api/services_spec.rb b/spec/requests/api/services_spec.rb
index fb3b235446f..9aa60826f21 100644
--- a/spec/requests/api/services_spec.rb
+++ b/spec/requests/api/services_spec.rb
@@ -17,9 +17,9 @@ describe API::API, api: true do
it "should return if required fields missing" do
attrs = service_attrs
-
+
required_attributes = service_attrs_list.select do |attr|
- service_klass.validators_on(attr).any? do |v|
+ service_klass.validators_on(attr).any? do |v|
v.class == ActiveRecord::Validations::PresenceValidator
end
end
diff --git a/spec/requests/ci/api/forks_spec.rb b/spec/requests/ci/api/forks_spec.rb
deleted file mode 100644
index 37fa1e82f25..00000000000
--- a/spec/requests/ci/api/forks_spec.rb
+++ /dev/null
@@ -1,59 +0,0 @@
-require 'spec_helper'
-
-describe Ci::API::API do
- include ApiHelpers
-
- let(:project) { FactoryGirl.create(:ci_project) }
- let(:private_token) { create(:user).private_token }
-
- let(:options) do
- {
- private_token: private_token,
- url: GitlabCi.config.gitlab_ci.url
- }
- end
-
- before do
- stub_gitlab_calls
- end
-
-
- describe "POST /forks" do
- let(:project_info) do
- {
- project_id: project.gitlab_id,
- project_token: project.token,
- data: {
- id: create(:empty_project).id,
- name_with_namespace: "Gitlab.org / Underscore",
- path_with_namespace: "gitlab-org/underscore",
- default_branch: "master",
- ssh_url_to_repo: "git@example.com:gitlab-org/underscore"
- }
- }
- end
-
- context "with valid info" do
- before do
- options.merge!(project_info)
- end
-
- it "should create a project with valid data" do
- post ci_api("/forks"), options
- expect(response.status).to eq(201)
- expect(json_response['name']).to eq("Gitlab.org / Underscore")
- end
- end
-
- context "with invalid project info" do
- before do
- options.merge!({})
- end
-
- it "should error with invalid data" do
- post ci_api("/forks"), options
- expect(response.status).to eq(400)
- end
- end
- end
-end
diff --git a/spec/services/ci/create_project_service_spec.rb b/spec/services/ci/create_project_service_spec.rb
index 64041b8d5a2..c0af515aa8f 100644
--- a/spec/services/ci/create_project_service_spec.rb
+++ b/spec/services/ci/create_project_service_spec.rb
@@ -7,7 +7,7 @@ describe Ci::CreateProjectService do
describe :execute do
context 'valid params' do
- subject { service.execute(current_user, project, 'http://localhost/projects/:project_id') }
+ subject { service.execute(current_user, project) }
it { is_expected.to be_kind_of(Ci::Project) }
it { is_expected.to be_persisted }
@@ -24,7 +24,7 @@ describe Ci::CreateProjectService do
FactoryGirl.create(:ci_project, shared_runners_enabled: true, public: true, allow_git_fetch: true)
end
- subject { service.execute(current_user, project, 'http://localhost/projects/:project_id', ci_origin_project) }
+ subject { service.execute(current_user, project, ci_origin_project) }
it "uses project as a template for settings and jobs" do
expect(subject.shared_runners_enabled).to be_truthy
diff --git a/spec/services/projects/fork_service_spec.rb b/spec/services/projects/fork_service_spec.rb
index 7c4bb74b77f..18ab333c1d1 100644
--- a/spec/services/projects/fork_service_spec.rb
+++ b/spec/services/projects/fork_service_spec.rb
@@ -44,10 +44,11 @@ describe Projects::ForkService do
context 'GitLab CI is enabled' do
it "calls fork registrator for CI" do
+ create(:ci_project, gl_project: @from_project)
@from_project.build_missing_services
@from_project.gitlab_ci_service.update_attributes(active: true)
- expect(ForkRegistrationWorker).to receive(:perform_async)
+ expect_any_instance_of(Ci::CreateProjectService).to receive(:execute)
fork_project(@from_project, @to_user)
end
diff --git a/spec/workers/fork_registration_worker_spec.rb b/spec/workers/fork_registration_worker_spec.rb
deleted file mode 100644
index cc6f574b29c..00000000000
--- a/spec/workers/fork_registration_worker_spec.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-
-require 'spec_helper'
-
-describe ForkRegistrationWorker do
- context "as a resque worker" do
- it "reponds to #perform" do
- expect(ForkRegistrationWorker.new).to respond_to(:perform)
- end
- end
-end