summaryrefslogtreecommitdiff
path: root/spec/finders
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-05-15 12:08:28 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-05-15 12:08:28 +0000
commit927df95cc4453bdacbc59960df32008b02c4e28a (patch)
tree24c2af26a0b7a06661bdf077c3d0300684602e39 /spec/finders
parente5731d5194e20deb33725943248c5899e4fdf05d (diff)
downloadgitlab-ce-927df95cc4453bdacbc59960df32008b02c4e28a.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/finders')
-rw-r--r--spec/finders/freeze_periods_finder_spec.rb59
-rw-r--r--spec/finders/projects/serverless/functions_finder_spec.rb1
2 files changed, 60 insertions, 0 deletions
diff --git a/spec/finders/freeze_periods_finder_spec.rb b/spec/finders/freeze_periods_finder_spec.rb
new file mode 100644
index 00000000000..4ff356b85b7
--- /dev/null
+++ b/spec/finders/freeze_periods_finder_spec.rb
@@ -0,0 +1,59 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe FreezePeriodsFinder do
+ subject(:finder) { described_class.new(project, user).execute }
+
+ let(:project) { create(:project, :private) }
+ let(:user) { create(:user) }
+ let!(:freeze_period_1) { create(:ci_freeze_period, project: project, created_at: 2.days.ago) }
+ let!(:freeze_period_2) { create(:ci_freeze_period, project: project, created_at: 1.day.ago) }
+
+ shared_examples_for 'returns nothing' do
+ specify do
+ is_expected.to be_empty
+ end
+ end
+
+ shared_examples_for 'returns freeze_periods ordered by created_at asc' do
+ it 'returns freeze_periods ordered by created_at' do
+ expect(subject.count).to eq(2)
+ expect(subject.pluck('id')).to eq([freeze_period_1.id, freeze_period_2.id])
+ end
+ end
+
+ context 'when user is a maintainer' do
+ before do
+ project.add_maintainer(user)
+ end
+
+ it_behaves_like 'returns freeze_periods ordered by created_at asc'
+ end
+
+ context 'when user is a guest' do
+ before do
+ project.add_guest(user)
+ end
+
+ it_behaves_like 'returns nothing'
+ end
+
+ context 'when user is a developer' do
+ before do
+ project.add_developer(user)
+ end
+
+ it_behaves_like 'returns nothing'
+ end
+
+ context 'when user is not a project member' do
+ it_behaves_like 'returns nothing'
+
+ context 'when project is public' do
+ let(:project) { create(:project, :public) }
+
+ it_behaves_like 'returns nothing'
+ end
+ end
+end
diff --git a/spec/finders/projects/serverless/functions_finder_spec.rb b/spec/finders/projects/serverless/functions_finder_spec.rb
index 4e9f3d371ce..1f0e3cd2eda 100644
--- a/spec/finders/projects/serverless/functions_finder_spec.rb
+++ b/spec/finders/projects/serverless/functions_finder_spec.rb
@@ -48,6 +48,7 @@ describe Projects::Serverless::FunctionsFinder do
expect(function_finder.knative_installed).to be false
end
end
+
context 'when project level cluster is present and enabled' do
it_behaves_like 'before first deployment' do
let(:cluster) { create(:cluster, :project, :provided_by_gcp, enabled: true) }