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
diff options
context:
space:
mode:
authorValery Sizov <vsv2711@gmail.com>2015-09-15 16:00:45 +0300
committerValery Sizov <vsv2711@gmail.com>2015-09-15 16:29:36 +0300
commit88b3195ecfd2d0d74c4e76ce79961cb6db2f8643 (patch)
tree837d7b6fb71675890f34996c23bb5153b5754e5e
parente2cbb36ba9751021174fd188d1c29e736f7b5d3d (diff)
fix specs. Stage 6
-rw-r--r--spec/mailers/ci/notify_spec.rb12
-rw-r--r--spec/models/ci/project_services/hip_chat_service_spec.rb4
-rw-r--r--spec/services/ci/create_project_service_spec.rb12
-rw-r--r--spec/services/ci/create_trigger_request_service_spec.rb14
-rw-r--r--spec/services/ci/event_service_spec.rb6
-rw-r--r--spec/services/ci/image_for_build_service_spec.rb86
-rw-r--r--spec/services/ci/register_build_service_spec.rb154
-rw-r--r--spec/services/ci/web_hook_service_spec.rb4
8 files changed, 148 insertions, 144 deletions
diff --git a/spec/mailers/ci/notify_spec.rb b/spec/mailers/ci/notify_spec.rb
index 6a2c845cd0e..20d8ddcd135 100644
--- a/spec/mailers/ci/notify_spec.rb
+++ b/spec/mailers/ci/notify_spec.rb
@@ -1,17 +1,17 @@
require 'spec_helper'
-describe Notify do
+describe Ci::Notify do
include EmailSpec::Helpers
include EmailSpec::Matchers
before do
- @project = FactoryGirl.create :project
- @commit = FactoryGirl.create :commit, project: @project
- @build = FactoryGirl.create :build, commit: @commit
+ @project = FactoryGirl.create :ci_project
+ @commit = FactoryGirl.create :ci_commit, project: @project
+ @build = FactoryGirl.create :ci_build, commit: @commit
end
describe 'build success' do
- subject { Notify.build_success_email(@build.id, 'wow@example.com') }
+ subject { Ci::Notify.build_success_email(@build.id, 'wow@example.com') }
it 'has the correct subject' do
should have_subject /Build success for/
@@ -23,7 +23,7 @@ describe Notify do
end
describe 'build fail' do
- subject { Notify.build_fail_email(@build.id, 'wow@example.com') }
+ subject { Ci::Notify.build_fail_email(@build.id, 'wow@example.com') }
it 'has the correct subject' do
should have_subject /Build failed for/
diff --git a/spec/models/ci/project_services/hip_chat_service_spec.rb b/spec/models/ci/project_services/hip_chat_service_spec.rb
index 59deb19c23a..063d46b84d4 100644
--- a/spec/models/ci/project_services/hip_chat_service_spec.rb
+++ b/spec/models/ci/project_services/hip_chat_service_spec.rb
@@ -53,13 +53,13 @@ describe Ci::HipChatService do
it "should call the HipChat API" do
service.execute(build)
- HipChatNotifierWorker.drain
+ Ci::HipChatNotifierWorker.drain
expect( WebMock ).to have_requested(:post, api_url).once
end
it "calls the worker with expected arguments" do
- expect( HipChatNotifierWorker ).to receive(:perform_async) \
+ expect( Ci::HipChatNotifierWorker ).to receive(:perform_async) \
.with(an_instance_of(String), hash_including(
token: 'a1b2c3d4e5f6',
room: 123,
diff --git a/spec/services/ci/create_project_service_spec.rb b/spec/services/ci/create_project_service_spec.rb
index c4b62e4fa9e..234a778f8cc 100644
--- a/spec/services/ci/create_project_service_spec.rb
+++ b/spec/services/ci/create_project_service_spec.rb
@@ -5,14 +5,14 @@ describe Ci::CreateProjectService do
let(:current_user) { double.as_null_object }
let(:project_dump) { YAML.load File.read(Rails.root.join('spec/support/gitlab_stubs/raw_project.yml')) }
- before { Network.any_instance.stub(enable_ci: true) }
+ before { allow_any_instance_of(Network).to receive_messages(enable_ci: true) }
describe :execute do
context 'valid params' do
let(:project) { service.execute(current_user, project_dump, 'http://localhost/projects/:project_id') }
- it { project.should be_kind_of(Project) }
- it { project.should be_persisted }
+ it { expect(project).to be_kind_of(Project) }
+ it { expect(project).to be_persisted }
end
context 'without project dump' do
@@ -31,9 +31,9 @@ describe Ci::CreateProjectService do
project = service.execute(current_user, project_dump, 'http://localhost/projects/:project_id', origin_project)
- project.shared_runners_enabled.should be_true
- project.public.should be_true
- project.allow_git_fetch.should be_true
+ expect(project.shared_runners_enabled).to be_truthy
+ expect(project.public).to be_truthy
+ expect(project.allow_git_fetch).to be_truthy
end
end
end
diff --git a/spec/services/ci/create_trigger_request_service_spec.rb b/spec/services/ci/create_trigger_request_service_spec.rb
index c874697c456..9082c741ead 100644
--- a/spec/services/ci/create_trigger_request_service_spec.rb
+++ b/spec/services/ci/create_trigger_request_service_spec.rb
@@ -13,14 +13,14 @@ describe Ci::CreateTriggerRequestService do
@commit = FactoryGirl.create :commit, project: project
end
- it { subject.should be_kind_of(TriggerRequest) }
- it { subject.commit.should == @commit }
+ it { expect(subject).to be_kind_of(TriggerRequest) }
+ it { expect(subject.commit).to eq(@commit) }
end
context 'no commit for ref' do
subject { service.execute(project, trigger, 'other-branch') }
- it { subject.should be_nil }
+ it { expect(subject).to be_nil }
end
context 'no builds created' do
@@ -30,7 +30,7 @@ describe Ci::CreateTriggerRequestService do
FactoryGirl.create :commit_without_jobs, project: project
end
- it { subject.should be_nil }
+ it { expect(subject).to be_nil }
end
context 'for multiple commits' do
@@ -43,9 +43,9 @@ describe Ci::CreateTriggerRequestService do
end
context 'retries latest one' do
- it { subject.should be_kind_of(TriggerRequest) }
- it { subject.should be_persisted }
- it { subject.commit.should == @commit2 }
+ it { expect(subject).to be_kind_of(TriggerRequest) }
+ it { expect(subject).to be_persisted }
+ it { expect(subject.commit).to eq(@commit2) }
end
end
end
diff --git a/spec/services/ci/event_service_spec.rb b/spec/services/ci/event_service_spec.rb
index bdebab1ac24..c8c4c45cc31 100644
--- a/spec/services/ci/event_service_spec.rb
+++ b/spec/services/ci/event_service_spec.rb
@@ -12,7 +12,7 @@ describe Ci::EventService do
it "creates event" do
EventService.new.remove_project(user, project)
- Event.admin.last.description.should == "Project \"GitLab / gitlab-shell\" has been removed by root"
+ expect(Event.admin.last.description).to eq("Project \"GitLab / gitlab-shell\" has been removed by root")
end
end
@@ -20,7 +20,7 @@ describe Ci::EventService do
it "creates event" do
EventService.new.create_project(user, project)
- Event.admin.last.description.should == "Project \"GitLab / gitlab-shell\" has been created by root"
+ expect(Event.admin.last.description).to eq("Project \"GitLab / gitlab-shell\" has been created by root")
end
end
@@ -28,7 +28,7 @@ describe Ci::EventService do
it "creates event" do
EventService.new.change_project_settings(user, project)
- Event.last.description.should == "User \"root\" updated projects settings"
+ expect(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 dadc919bae1..fdeb754d689 100644
--- a/spec/services/ci/image_for_build_service_spec.rb
+++ b/spec/services/ci/image_for_build_service_spec.rb
@@ -1,46 +1,48 @@
require 'spec_helper'
-describe Ci::ImageForBuildService do
- let(:service) { ImageForBuildService.new }
- let(:project) { FactoryGirl.create(:project) }
- let(:commit) { FactoryGirl.create(:commit, project: project, ref: 'master') }
- let(:build) { FactoryGirl.create(:build, commit: commit) }
-
- describe :execute do
- before { build }
-
- context 'branch name' do
- before { build.run! }
- let(:image) { service.execute(project, ref: 'master') }
-
- it { image.should be_kind_of(OpenStruct) }
- it { image.path.to_s.should include('public/build-running.svg') }
- it { image.name.should == 'build-running.svg' }
- end
-
- context 'unknown branch name' do
- let(:image) { service.execute(project, ref: 'feature') }
-
- it { image.should be_kind_of(OpenStruct) }
- it { image.path.to_s.should include('public/build-unknown.svg') }
- it { image.name.should == 'build-unknown.svg' }
- end
-
- context 'commit sha' do
- before { build.run! }
- let(:image) { service.execute(project, sha: build.sha) }
-
- it { image.should be_kind_of(OpenStruct) }
- it { image.path.to_s.should include('public/build-running.svg') }
- it { image.name.should == 'build-running.svg' }
- end
-
- context 'unknown commit sha' do
- let(:image) { service.execute(project, sha: '0000000') }
-
- it { image.should be_kind_of(OpenStruct) }
- it { image.path.to_s.should include('public/build-unknown.svg') }
- it { image.name.should == 'build-unknown.svg' }
+module Ci
+ describe ImageForBuildService do
+ let(:service) { ImageForBuildService.new }
+ let(:project) { FactoryGirl.create(:ci_project) }
+ let(:commit) { FactoryGirl.create(:ci_commit, project: project, ref: 'master') }
+ let(:build) { FactoryGirl.create(:ci_build, commit: commit) }
+
+ describe :execute do
+ before { build }
+
+ context 'branch name' do
+ before { build.run! }
+ let(:image) { service.execute(project, ref: 'master') }
+
+ it { expect(image).to be_kind_of(OpenStruct) }
+ it { expect(image.path.to_s).to include('public/ci/build-running.svg') }
+ it { expect(image.name).to eq('build-running.svg') }
+ end
+
+ context 'unknown branch name' do
+ let(:image) { service.execute(project, ref: 'feature') }
+
+ it { expect(image).to be_kind_of(OpenStruct) }
+ it { expect(image.path.to_s).to include('public/ci/build-unknown.svg') }
+ it { expect(image.name).to eq('build-unknown.svg') }
+ end
+
+ context 'commit sha' do
+ before { build.run! }
+ let(:image) { service.execute(project, sha: build.sha) }
+
+ it { expect(image).to be_kind_of(OpenStruct) }
+ it { expect(image.path.to_s).to include('public/ci/build-running.svg') }
+ it { expect(image.name).to eq('build-running.svg') }
+ end
+
+ context 'unknown commit sha' do
+ let(:image) { service.execute(project, sha: '0000000') }
+
+ it { expect(image).to be_kind_of(OpenStruct) }
+ it { expect(image.path.to_s).to include('public/ci/build-unknown.svg') }
+ it { expect(image.name).to eq('build-unknown.svg') }
+ end
end
end
-end
+end \ No newline at end of file
diff --git a/spec/services/ci/register_build_service_spec.rb b/spec/services/ci/register_build_service_spec.rb
index 6d0ae76a241..7d665d9a112 100644
--- a/spec/services/ci/register_build_service_spec.rb
+++ b/spec/services/ci/register_build_service_spec.rb
@@ -1,88 +1,90 @@
-require 'spec_helper'
-
-describe Ci::RegisterBuildService do
- let!(:service) { RegisterBuildService.new }
- let!(:project) { FactoryGirl.create :project }
- let!(:commit) { FactoryGirl.create :commit, project: project }
- let!(:pending_build) { FactoryGirl.create :build, project: project, commit: commit }
- let!(:shared_runner) { FactoryGirl.create(:runner, is_shared: true) }
- let!(:specific_runner) { FactoryGirl.create(:runner, is_shared: false) }
-
- before do
- specific_runner.assign_to(project)
- end
-
- describe :execute do
- context 'runner follow tag list' do
- it "picks build with the same tag" do
- pending_build.tag_list = ["linux"]
- pending_build.save
- specific_runner.tag_list = ["linux"]
- service.execute(specific_runner).should == pending_build
- end
-
- it "does not pick build with different tag" do
- pending_build.tag_list = ["linux"]
- pending_build.save
- specific_runner.tag_list = ["win32"]
- service.execute(specific_runner).should be_false
- end
-
- it "picks build without tag" do
- service.execute(specific_runner).should == pending_build
- end
-
- it "does not pick build with tag" do
- pending_build.tag_list = ["linux"]
- pending_build.save
- service.execute(specific_runner).should be_false
- end
-
- it "pick build without tag" do
- specific_runner.tag_list = ["win32"]
- service.execute(specific_runner).should == pending_build
- end
+ require 'spec_helper'
+
+module Ci
+ describe RegisterBuildService do
+ let!(:service) { RegisterBuildService.new }
+ let!(:project) { FactoryGirl.create :ci_project }
+ let!(:commit) { FactoryGirl.create :ci_commit, project: project }
+ let!(:pending_build) { FactoryGirl.create :ci_build, project: project, 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(project)
end
- context 'allow shared runners' do
- before do
- project.shared_runners_enabled = true
- project.save
- end
-
- context 'shared runner' do
- let(:build) { service.execute(shared_runner) }
-
- it { build.should be_kind_of(Build) }
- it { build.should be_valid }
- it { build.should be_running }
- it { build.runner.should == shared_runner }
+ describe :execute do
+ context 'runner follow tag list' do
+ it "picks build with the same tag" do
+ pending_build.tag_list = ["linux"]
+ pending_build.save
+ specific_runner.tag_list = ["linux"]
+ expect(service.execute(specific_runner)).to eq(pending_build)
+ end
+
+ it "does not pick build with different tag" do
+ pending_build.tag_list = ["linux"]
+ pending_build.save
+ specific_runner.tag_list = ["win32"]
+ expect(service.execute(specific_runner)).to be_falsey
+ end
+
+ it "picks build without tag" do
+ expect(service.execute(specific_runner)).to eq(pending_build)
+ end
+
+ it "does not pick build with tag" do
+ pending_build.tag_list = ["linux"]
+ pending_build.save
+ expect(service.execute(specific_runner)).to be_falsey
+ end
+
+ it "pick build without tag" do
+ specific_runner.tag_list = ["win32"]
+ expect(service.execute(specific_runner)).to eq(pending_build)
+ end
end
- context 'specific runner' do
- let(:build) { service.execute(specific_runner) }
-
- it { build.should be_kind_of(Build) }
- it { build.should be_valid }
- it { build.should be_running }
- it { build.runner.should == specific_runner }
+ context 'allow shared runners' do
+ before do
+ project.shared_runners_enabled = true
+ project.save
+ end
+
+ context 'shared runner' do
+ let(:build) { service.execute(shared_runner) }
+
+ it { expect(build).to be_kind_of(Build) }
+ it { expect(build).to be_valid }
+ it { expect(build).to be_running }
+ it { expect(build.runner).to eq(shared_runner) }
+ end
+
+ context 'specific runner' do
+ let(:build) { service.execute(specific_runner) }
+
+ it { expect(build).to be_kind_of(Build) }
+ it { expect(build).to be_valid }
+ it { expect(build).to be_running }
+ it { expect(build.runner).to eq(specific_runner) }
+ end
end
- end
- context 'disallow shared runners' do
- context 'shared runner' do
- let(:build) { service.execute(shared_runner) }
+ context 'disallow shared runners' do
+ context 'shared runner' do
+ let(:build) { service.execute(shared_runner) }
- it { build.should be_nil }
- end
+ it { expect(build).to be_nil }
+ end
- context 'specific runner' do
- let(:build) { service.execute(specific_runner) }
+ context 'specific runner' do
+ let(:build) { service.execute(specific_runner) }
- it { build.should be_kind_of(Build) }
- it { build.should be_valid }
- it { build.should be_running }
- it { build.runner.should == specific_runner }
+ it { expect(build).to be_kind_of(Build) }
+ it { expect(build).to be_valid }
+ it { expect(build).to be_running }
+ it { expect(build.runner).to eq(specific_runner) }
+ end
end
end
end
diff --git a/spec/services/ci/web_hook_service_spec.rb b/spec/services/ci/web_hook_service_spec.rb
index d2f08959cb1..b893b1f23f2 100644
--- a/spec/services/ci/web_hook_service_spec.rb
+++ b/spec/services/ci/web_hook_service_spec.rb
@@ -9,13 +9,13 @@ describe Ci::WebHookService do
describe :execute do
it "should execute successfully" do
stub_request(:post, hook.url).to_return(status: 200)
- WebHookService.new.build_end(build).should be_true
+ expect(WebHookService.new.build_end(build)).to be_truthy
end
end
context 'build_data' do
it "contains all needed fields" do
- build_data(build).should include(
+ expect(build_data(build)).to include(
:build_id,
:project_id,
:ref,