diff options
author | Valery Sizov <vsv2711@gmail.com> | 2015-09-16 12:43:16 +0300 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2015-09-18 18:02:11 +0200 |
commit | a0c1a12dee276f5d587514d24432e7647e07aeec (patch) | |
tree | 8c5797f2fff43c72361343dbcd70d1cd13067a88 /spec | |
parent | bdfe6b9603a7a6947644929c4ea966018f98c840 (diff) | |
download | gitlab-ce-a0c1a12dee276f5d587514d24432e7647e07aeec.tar.gz |
remove API calls from CE to CIci_closer_integration
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/ci/projects_controller_spec.rb | 43 | ||||
-rw-r--r-- | spec/lib/gitlab/backend/grack_auth_spec.rb | 1 | ||||
-rw-r--r-- | spec/models/project_services/gitlab_ci_service_spec.rb | 37 | ||||
-rw-r--r-- | spec/requests/api/projects_spec.rb | 2 | ||||
-rw-r--r-- | spec/requests/api/services_spec.rb | 4 | ||||
-rw-r--r-- | spec/requests/ci/api/forks_spec.rb | 59 | ||||
-rw-r--r-- | spec/services/ci/create_project_service_spec.rb | 4 | ||||
-rw-r--r-- | spec/services/projects/fork_service_spec.rb | 3 | ||||
-rw-r--r-- | spec/workers/fork_registration_worker_spec.rb | 10 |
9 files changed, 11 insertions, 152 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/gitlab_ci_service_spec.rb b/spec/models/project_services/gitlab_ci_service_spec.rb index 516d1d4fc1d..e0da04a3f40 100644 --- a/spec/models/project_services/gitlab_ci_service_spec.rb +++ b/spec/models/project_services/gitlab_ci_service_spec.rb @@ -26,33 +26,6 @@ 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) @@ -77,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) @@ -88,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) @@ -101,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 |