summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-31 12:08:09 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-31 12:08:09 +0000
commit0d0cddc9ce20c5a7d8a2723d0aa620ca184a711a (patch)
tree64f91b4d4ca74aa09d2a62ac5910820d087ed7cb /spec
parent6044caed20964a70c1ac6c5a3365d567ed96dfde (diff)
downloadgitlab-ce-0d0cddc9ce20c5a7d8a2723d0aa620ca184a711a.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/helpers/environments_helper_spec.rb13
-rw-r--r--spec/lib/feature/gitaly_spec.rb10
-rw-r--r--spec/lib/gitlab/git/tree_spec.rb9
-rw-r--r--spec/models/member_spec.rb11
-rw-r--r--spec/services/ci/retry_pipeline_service_spec.rb2
-rw-r--r--spec/views/projects/tree/_tree_row.html.haml_spec.rb4
6 files changed, 47 insertions, 2 deletions
diff --git a/spec/helpers/environments_helper_spec.rb b/spec/helpers/environments_helper_spec.rb
index 37713a04844..aaa90a7d2af 100644
--- a/spec/helpers/environments_helper_spec.rb
+++ b/spec/helpers/environments_helper_spec.rb
@@ -33,7 +33,8 @@ describe EnvironmentsHelper do
'tags-path' => project_tags_path(project),
'has-metrics' => "#{environment.has_metrics?}",
'prometheus-status' => "#{environment.prometheus_status}",
- 'external-dashboard-url' => nil
+ 'external-dashboard-url' => nil,
+ 'environment-state' => environment.state
)
end
@@ -46,5 +47,15 @@ describe EnvironmentsHelper do
expect(metrics_data['external-dashboard-url']).to eq('http://gitlab.com')
end
end
+
+ context 'when the environment is not available' do
+ before do
+ environment.stop
+ end
+
+ subject { metrics_data }
+
+ it { is_expected.to include('environment-state' => 'stopped') }
+ end
end
end
diff --git a/spec/lib/feature/gitaly_spec.rb b/spec/lib/feature/gitaly_spec.rb
index afb522d05e1..08651c42276 100644
--- a/spec/lib/feature/gitaly_spec.rb
+++ b/spec/lib/feature/gitaly_spec.rb
@@ -32,5 +32,15 @@ describe Feature::Gitaly do
it { is_expected.to be_a(Hash) }
it { is_expected.to eq("gitaly-feature-mep-mep" => "true") }
+
+ context 'when table does not exist' do
+ before do
+ allow(::Gitlab::Database).to receive(:cached_table_exists?).and_return(false)
+ end
+
+ it 'returns an empty Hash' do
+ expect(subject).to eq({})
+ end
+ end
end
end
diff --git a/spec/lib/gitlab/git/tree_spec.rb b/spec/lib/gitlab/git/tree_spec.rb
index d82acad866c..b254dd3f036 100644
--- a/spec/lib/gitlab/git/tree_spec.rb
+++ b/spec/lib/gitlab/git/tree_spec.rb
@@ -39,7 +39,10 @@ describe Gitlab::Git::Tree, :seed_helper do
it { expect(dir.flat_path).to eq('encoding') }
context :subdir do
+ # rubocop: disable Rails/FindBy
+ # This is not ActiveRecord where..first
let(:subdir) { Gitlab::Git::Tree.where(repository, SeedRepo::Commit::ID, 'files').first }
+ # rubocop: enable Rails/FindBy
it { expect(subdir).to be_kind_of Gitlab::Git::Tree }
it { expect(subdir.id).to eq('a1e8f8d745cc87e3a9248358d9352bb7f9a0aeba') }
@@ -50,7 +53,10 @@ describe Gitlab::Git::Tree, :seed_helper do
end
context :subdir_file do
+ # rubocop: disable Rails/FindBy
+ # This is not ActiveRecord where..first
let(:subdir_file) { Gitlab::Git::Tree.where(repository, SeedRepo::Commit::ID, 'files/ruby').first }
+ # rubocop: enable Rails/FindBy
it { expect(subdir_file).to be_kind_of Gitlab::Git::Tree }
it { expect(subdir_file.id).to eq('7e3e39ebb9b2bf433b4ad17313770fbe4051649c') }
@@ -63,7 +69,10 @@ describe Gitlab::Git::Tree, :seed_helper do
context :flat_path do
let(:filename) { 'files/flat/path/correct/content.txt' }
let(:oid) { create_file(filename) }
+ # rubocop: disable Rails/FindBy
+ # This is not ActiveRecord where..first
let(:subdir_file) { Gitlab::Git::Tree.where(repository, oid, 'files/flat').first }
+ # rubocop: enable Rails/FindBy
let(:repository_rugged) { Rugged::Repository.new(File.join(SEED_STORAGE_PATH, TEST_REPO_PATH)) }
it { expect(subdir_file.flat_path).to eq('files/flat/path/correct') }
diff --git a/spec/models/member_spec.rb b/spec/models/member_spec.rb
index 13a0426624b..0e8ae320405 100644
--- a/spec/models/member_spec.rb
+++ b/spec/models/member_spec.rb
@@ -342,6 +342,17 @@ describe Member do
expect(source.members.invite.pluck(:invite_email)).to include('user@example.com')
end
end
+
+ context 'when called with an unknown user email starting with a number' do
+ it 'creates an invited member', :aggregate_failures do
+ email_starting_with_number = "#{user.id}_email@example.com"
+
+ described_class.add_user(source, email_starting_with_number, :maintainer)
+
+ expect(source.members.invite.pluck(:invite_email)).to include(email_starting_with_number)
+ expect(source.users.reload).not_to include(user)
+ end
+ end
end
context 'when current_user can update member' do
diff --git a/spec/services/ci/retry_pipeline_service_spec.rb b/spec/services/ci/retry_pipeline_service_spec.rb
index 7db871adc9a..81a0b05f2c7 100644
--- a/spec/services/ci/retry_pipeline_service_spec.rb
+++ b/spec/services/ci/retry_pipeline_service_spec.rb
@@ -87,7 +87,7 @@ describe Ci::RetryPipelineService, '#execute' do
it 'creates a new job for report job in this case' do
service.execute(pipeline)
- expect(statuses.where(name: 'report 1').first).to be_retried
+ expect(statuses.find_by(name: 'report 1', status: 'failed')).to be_retried
end
end
diff --git a/spec/views/projects/tree/_tree_row.html.haml_spec.rb b/spec/views/projects/tree/_tree_row.html.haml_spec.rb
index ff2fe8aeb6c..864272fc146 100644
--- a/spec/views/projects/tree/_tree_row.html.haml_spec.rb
+++ b/spec/views/projects/tree/_tree_row.html.haml_spec.rb
@@ -5,7 +5,11 @@ require 'spec_helper'
describe 'projects/tree/_tree_row' do
let(:project) { create(:project, :repository) }
let(:repository) { project.repository }
+
+ # rubocop: disable Rails/FindBy
+ # This is not ActiveRecord where..first
let(:blob_item) { Gitlab::Git::Tree.where(repository, SeedRepo::Commit::ID, 'files/ruby').first }
+ # rubocop: enable Rails/FindBy
before do
assign(:project, project)