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
path: root/spec/lib
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2019-09-05 11:02:44 +0300
committerRémy Coutable <remy@rymai.me>2019-09-05 11:02:44 +0300
commit09bd5142335c0aa3146d3de22137dd608580660b (patch)
tree505ca7d3f30453d76b3f45da799847704a548daa /spec/lib
parent151da98f246df5516baddbfbce94eb7485297a9d (diff)
parent124bad7bd88e7c329583ec3757eb0ba5fcec66e6 (diff)
Merge branch '66966-convert-rails-env-stub-usages-to-use-railshelpers-stub_rails_env-instead' into 'master'
Use stub_rails_env for Rails.env stubbing Closes #66966 See merge request gitlab-org/gitlab-ce!32625
Diffstat (limited to 'spec/lib')
-rw-r--r--spec/lib/gitlab/database/migration_helpers_spec.rb20
-rw-r--r--spec/lib/gitlab/favicon_spec.rb2
-rw-r--r--spec/lib/gitlab/gitaly_client_spec.rb2
-rw-r--r--spec/lib/gitlab/query_limiting/transaction_spec.rb4
-rw-r--r--spec/lib/gitlab/query_limiting_spec.rb9
-rw-r--r--spec/lib/gitlab_spec.rb2
6 files changed, 9 insertions, 30 deletions
diff --git a/spec/lib/gitlab/database/migration_helpers_spec.rb b/spec/lib/gitlab/database/migration_helpers_spec.rb
index cff4eb398bf..49f92f14559 100644
--- a/spec/lib/gitlab/database/migration_helpers_spec.rb
+++ b/spec/lib/gitlab/database/migration_helpers_spec.rb
@@ -1283,33 +1283,19 @@ describe Gitlab::Database::MigrationHelpers do
describe '#perform_background_migration_inline?' do
it 'returns true in a test environment' do
- allow(Rails.env)
- .to receive(:test?)
- .and_return(true)
+ stub_rails_env('test')
expect(model.perform_background_migration_inline?).to eq(true)
end
it 'returns true in a development environment' do
- allow(Rails.env)
- .to receive(:test?)
- .and_return(false)
-
- allow(Rails.env)
- .to receive(:development?)
- .and_return(true)
+ stub_rails_env('development')
expect(model.perform_background_migration_inline?).to eq(true)
end
it 'returns false in a production environment' do
- allow(Rails.env)
- .to receive(:test?)
- .and_return(false)
-
- allow(Rails.env)
- .to receive(:development?)
- .and_return(false)
+ stub_rails_env('production')
expect(model.perform_background_migration_inline?).to eq(false)
end
diff --git a/spec/lib/gitlab/favicon_spec.rb b/spec/lib/gitlab/favicon_spec.rb
index 63c26e29d73..d221f39c2ed 100644
--- a/spec/lib/gitlab/favicon_spec.rb
+++ b/spec/lib/gitlab/favicon_spec.rb
@@ -1,8 +1,6 @@
require 'spec_helper'
RSpec.describe Gitlab::Favicon, :request_store do
- include RailsHelpers
-
describe '.main' do
it 'defaults to favicon.png' do
stub_rails_env('production')
diff --git a/spec/lib/gitlab/gitaly_client_spec.rb b/spec/lib/gitlab/gitaly_client_spec.rb
index 99d563e03ec..1c5f72a4396 100644
--- a/spec/lib/gitlab/gitaly_client_spec.rb
+++ b/spec/lib/gitlab/gitaly_client_spec.rb
@@ -265,7 +265,7 @@ describe Gitlab::GitalyClient do
context 'in production and when RequestStore is enabled', :request_store do
before do
- allow(Rails.env).to receive(:production?).and_return(true)
+ stub_rails_env('production')
end
context 'when the maximum number of calls is enforced by a feature flag' do
diff --git a/spec/lib/gitlab/query_limiting/transaction_spec.rb b/spec/lib/gitlab/query_limiting/transaction_spec.rb
index 39d5a575efc..4e906314b5a 100644
--- a/spec/lib/gitlab/query_limiting/transaction_spec.rb
+++ b/spec/lib/gitlab/query_limiting/transaction_spec.rb
@@ -86,9 +86,7 @@ describe Gitlab::QueryLimiting::Transaction do
it 'returns false in a production environment' do
transaction = described_class.new
- expect(Rails.env)
- .to receive(:test?)
- .and_return(false)
+ stub_rails_env('production')
expect(transaction.raise_error?).to eq(false)
end
diff --git a/spec/lib/gitlab/query_limiting_spec.rb b/spec/lib/gitlab/query_limiting_spec.rb
index f0d0340cd6e..e9c6bbc35a3 100644
--- a/spec/lib/gitlab/query_limiting_spec.rb
+++ b/spec/lib/gitlab/query_limiting_spec.rb
@@ -9,14 +9,14 @@ describe Gitlab::QueryLimiting do
end
it 'returns true in a development environment' do
- allow(Rails.env).to receive(:development?).and_return(true)
+ stub_rails_env('development')
+ stub_rails_env('development')
expect(described_class.enable?).to eq(true)
end
it 'returns false on GitLab.com' do
- expect(Rails.env).to receive(:development?).and_return(false)
- expect(Rails.env).to receive(:test?).and_return(false)
+ stub_rails_env('production')
allow(Gitlab).to receive(:com?).and_return(true)
expect(described_class.enable?).to eq(false)
@@ -24,8 +24,7 @@ describe Gitlab::QueryLimiting do
it 'returns false in a non GitLab.com' do
allow(Gitlab).to receive(:com?).and_return(false)
- expect(Rails.env).to receive(:development?).and_return(false)
- expect(Rails.env).to receive(:test?).and_return(false)
+ stub_rails_env('production')
expect(described_class.enable?).to eq(false)
end
diff --git a/spec/lib/gitlab_spec.rb b/spec/lib/gitlab_spec.rb
index 74d4b12a070..589dac61528 100644
--- a/spec/lib/gitlab_spec.rb
+++ b/spec/lib/gitlab_spec.rb
@@ -3,8 +3,6 @@
require 'spec_helper'
describe Gitlab do
- include RailsHelpers
-
describe '.root' do
it 'returns the root path of the app' do
expect(described_class.root).to eq(Pathname.new(File.expand_path('../..', __dir__)))