summaryrefslogtreecommitdiff
path: root/spec/services
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2016-08-24 20:56:30 +0800
committerLin Jen-Shin <godfat@godfat.org>2016-08-24 20:56:30 +0800
commit616af0373e44b8577b0d6de0d438fd5555e9470d (patch)
tree2056538cfffe100788936c04e289680d864d4aab /spec/services
parent8f197315b3ec354cb0cc0af4acbe54d6aa01d71b (diff)
parent02591b043052eb4f8041f8cf51546fab272d7b61 (diff)
downloadgitlab-ce-616af0373e44b8577b0d6de0d438fd5555e9470d.tar.gz
Merge remote-tracking branch 'upstream/master' into artifacts-from-ref-and-build-name
* upstream/master: (192 commits) Added CHANGELOG Added unfold test to parallel and added 'diff discussion' context Fix Spinach branches spec Better first match on this MR also Change merge_error column from string to text type Fix typo in gitlab_flow.md entities: make Environment inherit EnvironmentBasic Updated to optimized specs from !5864 Added 'with an unfolded line should not allow commenting' scenario (line 125) Added addtional 'renderable' validator to check 'data-note-type' attr exists Allow passing an index to selectRowAtIndex Fixed enter key in search input not working Fix file links on project page Files view Fix incorrect "stopped impersonation" log message 8.11 is released, long live 8.12 Also check if Akismet is enabled, before showing the `Submit as spam` button. fix location of markdown help location Fix for update 8.10-to-8.11.md doc. Appease the linter. Add Ruby 2.3 upgrade notes. ...
Diffstat (limited to 'spec/services')
-rw-r--r--spec/services/ci/process_pipeline_service_spec.rb46
-rw-r--r--spec/services/notification_service_spec.rb40
2 files changed, 83 insertions, 3 deletions
diff --git a/spec/services/ci/process_pipeline_service_spec.rb b/spec/services/ci/process_pipeline_service_spec.rb
index ad8c2485888..8326e5cd313 100644
--- a/spec/services/ci/process_pipeline_service_spec.rb
+++ b/spec/services/ci/process_pipeline_service_spec.rb
@@ -3,8 +3,6 @@ require 'spec_helper'
describe Ci::ProcessPipelineService, services: true do
let(:pipeline) { create(:ci_pipeline, ref: 'master') }
let(:user) { create(:user) }
- let(:all_builds) { pipeline.builds }
- let(:builds) { all_builds.where.not(status: [:created, :skipped]) }
let(:config) { nil }
before do
@@ -12,6 +10,14 @@ describe Ci::ProcessPipelineService, services: true do
end
describe '#execute' do
+ def all_builds
+ pipeline.builds
+ end
+
+ def builds
+ all_builds.where.not(status: [:created, :skipped])
+ end
+
def create_builds
described_class.new(pipeline.project, user).execute(pipeline)
end
@@ -48,7 +54,7 @@ describe Ci::ProcessPipelineService, services: true do
it 'does not process pipeline if existing stage is running' do
expect(create_builds).to be_truthy
expect(builds.pending.count).to eq(2)
-
+
expect(create_builds).to be_falsey
expect(builds.pending.count).to eq(2)
end
@@ -224,6 +230,40 @@ describe Ci::ProcessPipelineService, services: true do
end
end
+ context 'when failed build in the middle stage is retried' do
+ context 'when failed build is the only unsuccessful build in the stage' do
+ before do
+ create(:ci_build, :created, pipeline: pipeline, name: 'build:1', stage_idx: 0)
+ create(:ci_build, :created, pipeline: pipeline, name: 'build:2', stage_idx: 0)
+ create(:ci_build, :created, pipeline: pipeline, name: 'test:1', stage_idx: 1)
+ create(:ci_build, :created, pipeline: pipeline, name: 'test:2', stage_idx: 1)
+ create(:ci_build, :created, pipeline: pipeline, name: 'deploy:1', stage_idx: 2)
+ create(:ci_build, :created, pipeline: pipeline, name: 'deploy:2', stage_idx: 2)
+ end
+
+ it 'does trigger builds in the next stage' do
+ expect(create_builds).to be_truthy
+ expect(builds.pluck(:name)).to contain_exactly('build:1', 'build:2')
+
+ pipeline.builds.running_or_pending.each(&:success)
+
+ expect(builds.pluck(:name))
+ .to contain_exactly('build:1', 'build:2', 'test:1', 'test:2')
+
+ pipeline.builds.find_by(name: 'test:1').success
+ pipeline.builds.find_by(name: 'test:2').drop
+
+ expect(builds.pluck(:name))
+ .to contain_exactly('build:1', 'build:2', 'test:1', 'test:2')
+
+ Ci::Build.retry(pipeline.builds.find_by(name: 'test:2')).success
+
+ expect(builds.pluck(:name)).to contain_exactly(
+ 'build:1', 'build:2', 'test:1', 'test:2', 'test:2', 'deploy:1', 'deploy:2')
+ end
+ end
+ end
+
context 'creates a builds from .gitlab-ci.yml' do
let(:config) do
YAML.dump({
diff --git a/spec/services/notification_service_spec.rb b/spec/services/notification_service_spec.rb
index 18da3b1b453..f81a58899fd 100644
--- a/spec/services/notification_service_spec.rb
+++ b/spec/services/notification_service_spec.rb
@@ -1113,6 +1113,46 @@ describe NotificationService, services: true do
end
end
+ describe 'GroupMember' do
+ describe '#decline_group_invite' do
+ let(:creator) { create(:user) }
+ let(:group) { create(:group) }
+ let(:member) { create(:user) }
+
+ before(:each) do
+ group.add_owner(creator)
+ group.add_developer(member, creator)
+ end
+
+ it do
+ group_member = group.members.first
+
+ expect do
+ notification.decline_group_invite(group_member)
+ end.to change { ActionMailer::Base.deliveries.size }.by(1)
+ end
+ end
+ end
+
+ describe 'ProjectMember' do
+ describe '#decline_group_invite' do
+ let(:project) { create(:project) }
+ let(:member) { create(:user) }
+
+ before(:each) do
+ project.team << [member, :developer, project.owner]
+ end
+
+ it do
+ project_member = project.members.first
+
+ expect do
+ notification.decline_project_invite(project_member)
+ end.to change { ActionMailer::Base.deliveries.size }.by(1)
+ end
+ end
+ end
+
def build_team(project)
@u_watcher = create_global_setting_for(create(:user), :watch)
@u_participating = create_global_setting_for(create(:user), :participating)