diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-10-18 18:48:27 +0300 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-10-18 18:48:27 +0300 |
commit | 19300a1a3dff8974a3e653d71dcc9d528436efd8 (patch) | |
tree | c8e281ddae7fe430e521a339d5992a4b46bb82fc /spec/models | |
parent | 3032a0ca891808c9aa1ba69d540bf97e40a84670 (diff) | |
parent | 146e0cbc4dfb857e0eb44777c40da5df56f376e0 (diff) |
Merge remote-tracking branch 'origin/master' into 22191-delete-dynamic-envs-mr
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/ci/pipeline_spec.rb | 24 | ||||
-rw-r--r-- | spec/models/issue/metrics_spec.rb | 8 | ||||
-rw-r--r-- | spec/models/merge_request/metrics_spec.rb | 2 | ||||
-rw-r--r-- | spec/models/project_feature_spec.rb | 23 |
4 files changed, 46 insertions, 11 deletions
diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb index 163c0b5c516..43397c5ae39 100644 --- a/spec/models/ci/pipeline_spec.rb +++ b/spec/models/ci/pipeline_spec.rb @@ -88,24 +88,38 @@ describe Ci::Pipeline, models: true do context 'no failed builds' do before do - FactoryGirl.create :ci_build, name: "rspec", pipeline: pipeline, status: 'success' + create_build('rspec', 'success') end - it 'be not retryable' do + it 'is not retryable' do is_expected.to be_falsey end + + context 'one canceled job' do + before do + create_build('rubocop', 'canceled') + end + + it 'is retryable' do + is_expected.to be_truthy + end + end end context 'with failed builds' do before do - FactoryGirl.create :ci_build, name: "rspec", pipeline: pipeline, status: 'running' - FactoryGirl.create :ci_build, name: "rubocop", pipeline: pipeline, status: 'failed' + create_build('rspec', 'running') + create_build('rubocop', 'failed') end - it 'be retryable' do + it 'is retryable' do is_expected.to be_truthy end end + + def create_build(name, status) + create(:ci_build, name: name, status: status, pipeline: pipeline) + end end describe '#stages' do diff --git a/spec/models/issue/metrics_spec.rb b/spec/models/issue/metrics_spec.rb index e170b087ebc..2459a49f095 100644 --- a/spec/models/issue/metrics_spec.rb +++ b/spec/models/issue/metrics_spec.rb @@ -13,7 +13,7 @@ describe Issue::Metrics, models: true do metrics = subject.metrics expect(metrics).to be_present - expect(metrics.first_associated_with_milestone_at).to be_within(1.second).of(time) + expect(metrics.first_associated_with_milestone_at).to be_like_time(time) end it "does not record the second time an issue is associated with a milestone" do @@ -24,7 +24,7 @@ describe Issue::Metrics, models: true do metrics = subject.metrics expect(metrics).to be_present - expect(metrics.first_associated_with_milestone_at).to be_within(1.second).of(time) + expect(metrics.first_associated_with_milestone_at).to be_like_time(time) end end @@ -36,7 +36,7 @@ describe Issue::Metrics, models: true do metrics = subject.metrics expect(metrics).to be_present - expect(metrics.first_added_to_board_at).to be_within(1.second).of(time) + expect(metrics.first_added_to_board_at).to be_like_time(time) end it "does not record the second time an issue is associated with a list label" do @@ -48,7 +48,7 @@ describe Issue::Metrics, models: true do metrics = subject.metrics expect(metrics).to be_present - expect(metrics.first_added_to_board_at).to be_within(1.second).of(time) + expect(metrics.first_added_to_board_at).to be_like_time(time) end end end diff --git a/spec/models/merge_request/metrics_spec.rb b/spec/models/merge_request/metrics_spec.rb index a79dd215d41..255db41cb19 100644 --- a/spec/models/merge_request/metrics_spec.rb +++ b/spec/models/merge_request/metrics_spec.rb @@ -12,7 +12,7 @@ describe MergeRequest::Metrics, models: true do metrics = subject.metrics expect(metrics).to be_present - expect(metrics.merged_at).to be_within(1.second).of(time) + expect(metrics.merged_at).to be_like_time(time) end end end diff --git a/spec/models/project_feature_spec.rb b/spec/models/project_feature_spec.rb index 8d554a01be5..a55d43ab2f9 100644 --- a/spec/models/project_feature_spec.rb +++ b/spec/models/project_feature_spec.rb @@ -5,7 +5,7 @@ describe ProjectFeature do let(:user) { create(:user) } describe '#feature_available?' do - let(:features) { %w(issues wiki builds merge_requests snippets) } + let(:features) { %w(issues wiki builds merge_requests snippets repository) } context 'when features are disabled' do it "returns false" do @@ -64,6 +64,27 @@ describe ProjectFeature do end end + context 'repository related features' do + before do + project.project_feature.update_attributes( + merge_requests_access_level: ProjectFeature::DISABLED, + builds_access_level: ProjectFeature::DISABLED, + repository_access_level: ProjectFeature::PRIVATE + ) + end + + it "does not allow repository related features have higher level" do + features = %w(builds merge_requests) + project_feature = project.project_feature + + features.each do |feature| + field = "#{feature}_access_level".to_sym + project_feature.update_attribute(field, ProjectFeature::ENABLED) + expect(project_feature.valid?).to be_falsy + end + end + end + describe '#*_enabled?' do let(:features) { %w(wiki builds merge_requests) } |