diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2015-12-04 14:55:23 +0300 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2015-12-11 20:02:09 +0300 |
commit | e80e3f5372d6bcad1fbe04a85b3086bb66794828 (patch) | |
tree | 16b1539cfd158ecac7fe05d595cbba30b8bc1a04 /spec/services | |
parent | 8b4cdc50fca816b4f56f8579e17c4dba836ec797 (diff) |
Migrate CI::Project to Project
Diffstat (limited to 'spec/services')
-rw-r--r-- | spec/services/ci/create_commit_service_spec.rb | 4 | ||||
-rw-r--r-- | spec/services/ci/create_trigger_request_service_spec.rb | 5 | ||||
-rw-r--r-- | spec/services/ci/event_service_spec.rb | 34 | ||||
-rw-r--r-- | spec/services/ci/image_for_build_service_spec.rb | 8 | ||||
-rw-r--r-- | spec/services/ci/register_build_service_spec.rb | 10 |
5 files changed, 13 insertions, 48 deletions
diff --git a/spec/services/ci/create_commit_service_spec.rb b/spec/services/ci/create_commit_service_spec.rb index c2fafca2ad2..7e2dcc503e5 100644 --- a/spec/services/ci/create_commit_service_spec.rb +++ b/spec/services/ci/create_commit_service_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' module Ci describe CreateCommitService, services: true do let(:service) { CreateCommitService.new } - let(:project) { FactoryGirl.create(:ci_project) } + let(:project) { FactoryGirl.create(:empty_project) } let(:user) { nil } before do @@ -24,7 +24,7 @@ module Ci it { expect(commit).to be_kind_of(Commit) } it { expect(commit).to be_valid } it { expect(commit).to be_persisted } - it { expect(commit).to eq(project.commits.last) } + it { expect(commit).to eq(project.ci_commits.last) } it { expect(commit.builds.first).to be_kind_of(Build) } end diff --git a/spec/services/ci/create_trigger_request_service_spec.rb b/spec/services/ci/create_trigger_request_service_spec.rb index c80cb58163a..dbdc5370bd8 100644 --- a/spec/services/ci/create_trigger_request_service_spec.rb +++ b/spec/services/ci/create_trigger_request_service_spec.rb @@ -2,8 +2,7 @@ require 'spec_helper' describe Ci::CreateTriggerRequestService, services: true do let(:service) { Ci::CreateTriggerRequestService.new } - let(:gl_project) { create(:project) } - let(:project) { gl_project.ensure_gitlab_ci_project } + let(:project) { create(:project) } let(:trigger) { create(:ci_trigger, project: project) } before do @@ -29,7 +28,7 @@ describe Ci::CreateTriggerRequestService, services: true do before do stub_ci_commit_yaml_file('{}') - FactoryGirl.create :ci_commit, gl_project: gl_project + FactoryGirl.create :ci_commit, project: project end it { expect(subject).to be_nil } diff --git a/spec/services/ci/event_service_spec.rb b/spec/services/ci/event_service_spec.rb deleted file mode 100644 index 32516c75cf3..00000000000 --- a/spec/services/ci/event_service_spec.rb +++ /dev/null @@ -1,34 +0,0 @@ -require 'spec_helper' - -describe Ci::EventService, services: true do - let(:project) { FactoryGirl.create :ci_project } - let(:user) { double(username: "root", id: 1) } - - before do - Event.destroy_all - end - - describe :remove_project do - it "creates event" do - Ci::EventService.new.remove_project(user, project) - - expect(Ci::Event.admin.last.description).to eq("Project \"#{project.name_with_namespace}\" has been removed by root") - end - end - - describe :create_project do - it "creates event" do - Ci::EventService.new.create_project(user, project) - - expect(Ci::Event.admin.last.description).to eq("Project \"#{project.name_with_namespace}\" has been created by root") - end - end - - describe :change_project_settings do - it "creates event" do - Ci::EventService.new.change_project_settings(user, project) - - expect(Ci::Event.last.description).to eq("User \"root\" updated projects settings") - end - end -end diff --git a/spec/services/ci/image_for_build_service_spec.rb b/spec/services/ci/image_for_build_service_spec.rb index b43cabb4ee4..870861ad20a 100644 --- a/spec/services/ci/image_for_build_service_spec.rb +++ b/spec/services/ci/image_for_build_service_spec.rb @@ -3,16 +3,16 @@ require 'spec_helper' module Ci describe ImageForBuildService, services: true do let(:service) { ImageForBuildService.new } - let(:project) { FactoryGirl.create(:ci_project) } - let(:gl_project) { FactoryGirl.create(:project, gitlab_ci_project: project) } - let(:commit_sha) { gl_project.commit('master').sha } - let(:commit) { gl_project.ensure_ci_commit(commit_sha) } + let(:project) { FactoryGirl.create(:empty_project) } + let(:commit_sha) { '01234567890123456789' } + let(:commit) { project.ensure_ci_commit(commit_sha) } let(:build) { FactoryGirl.create(:ci_build, commit: commit) } describe :execute do before { build } context 'branch name' do + before { allow(project).to receive(:commit).and_return(OpenStruct.new(sha: commit_sha)) } before { build.run! } let(:image) { service.execute(project, ref: 'master') } diff --git a/spec/services/ci/register_build_service_spec.rb b/spec/services/ci/register_build_service_spec.rb index 379e07982fb..e81f9e757ac 100644 --- a/spec/services/ci/register_build_service_spec.rb +++ b/spec/services/ci/register_build_service_spec.rb @@ -3,14 +3,14 @@ require 'spec_helper' module Ci describe RegisterBuildService, services: true do let!(:service) { RegisterBuildService.new } - let!(:gl_project) { FactoryGirl.create :empty_project } - let!(:commit) { FactoryGirl.create :ci_commit, gl_project: gl_project } + let!(:project) { FactoryGirl.create :empty_project, shared_runners_enabled: false } + let!(:commit) { FactoryGirl.create :ci_commit, project: project } let!(:pending_build) { FactoryGirl.create :ci_build, commit: commit } let!(:shared_runner) { FactoryGirl.create(:ci_runner, is_shared: true) } let!(:specific_runner) { FactoryGirl.create(:ci_runner, is_shared: false) } before do - specific_runner.assign_to(gl_project.ensure_gitlab_ci_project) + specific_runner.assign_to(project) end describe :execute do @@ -47,7 +47,7 @@ module Ci context 'allow shared runners' do before do - gl_project.gitlab_ci_project.update(shared_runners_enabled: true) + project.update(shared_runners_enabled: true) end context 'shared runner' do @@ -71,7 +71,7 @@ module Ci context 'disallow shared runners' do before do - gl_project.gitlab_ci_project.update(shared_runners_enabled: false) + project.update(shared_runners_enabled: false) end context 'shared runner' do |