Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
e9ccf9c7
Commit
e9ccf9c7
authored
Sep 04, 2019
by
Ash McKenzie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use stub_rails_env for Rails.env stubbing
RailsHelpers.stub_rails_env takes care of stubbing Rails.env
parent
8d848869
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
26 additions
and
46 deletions
+26
-46
ee/spec/models/concerns/ee/sha_attribute_spec.rb
ee/spec/models/concerns/ee/sha_attribute_spec.rb
+1
-1
spec/features/help_pages_spec.rb
spec/features/help_pages_spec.rb
+1
-1
spec/features/user_can_display_performance_bar_spec.rb
spec/features/user_can_display_performance_bar_spec.rb
+1
-1
spec/helpers/icons_helper_spec.rb
spec/helpers/icons_helper_spec.rb
+3
-4
spec/helpers/version_check_helper_spec.rb
spec/helpers/version_check_helper_spec.rb
+2
-2
spec/lib/gitlab/database/migration_helpers_spec.rb
spec/lib/gitlab/database/migration_helpers_spec.rb
+3
-17
spec/lib/gitlab/favicon_spec.rb
spec/lib/gitlab/favicon_spec.rb
+0
-2
spec/lib/gitlab/gitaly_client_spec.rb
spec/lib/gitlab/gitaly_client_spec.rb
+1
-1
spec/lib/gitlab/query_limiting/transaction_spec.rb
spec/lib/gitlab/query_limiting/transaction_spec.rb
+1
-3
spec/lib/gitlab/query_limiting_spec.rb
spec/lib/gitlab/query_limiting_spec.rb
+4
-5
spec/lib/gitlab_spec.rb
spec/lib/gitlab_spec.rb
+0
-2
spec/models/concerns/cacheable_attributes_spec.rb
spec/models/concerns/cacheable_attributes_spec.rb
+2
-2
spec/models/concerns/sha_attribute_spec.rb
spec/models/concerns/sha_attribute_spec.rb
+2
-2
spec/models/internal_id_spec.rb
spec/models/internal_id_spec.rb
+2
-1
spec/spec_helper.rb
spec/spec_helper.rb
+1
-0
spec/tasks/gitlab/gitaly_rake_spec.rb
spec/tasks/gitlab/gitaly_rake_spec.rb
+2
-2
No files found.
ee/spec/models/concerns/ee/sha_attribute_spec.rb
View file @
e9ccf9c7
...
@@ -17,7 +17,7 @@ describe EE::ShaAttribute do
...
@@ -17,7 +17,7 @@ describe EE::ShaAttribute do
describe
'#sha_attribute'
do
describe
'#sha_attribute'
do
context
'when in non-production'
do
context
'when in non-production'
do
before
do
before
do
allow
(
Rails
.
env
).
to
receive
(
:production?
).
and_return
(
false
)
stub_rails_env
(
'production'
)
end
end
context
'when Geo database is not configured'
do
context
'when Geo database is not configured'
do
...
...
spec/features/help_pages_spec.rb
View file @
e9ccf9c7
...
@@ -58,7 +58,7 @@ describe 'Help Pages' do
...
@@ -58,7 +58,7 @@ describe 'Help Pages' do
before
do
before
do
stub_application_setting
(
version_check_enabled:
true
)
stub_application_setting
(
version_check_enabled:
true
)
allow
(
Rails
.
env
).
to
receive
(
:production?
).
and_return
(
true
)
stub_rails_env
(
'production'
)
allow
(
VersionCheck
).
to
receive
(
:url
).
and_return
(
'/version-check-url'
)
allow
(
VersionCheck
).
to
receive
(
:url
).
and_return
(
'/version-check-url'
)
sign_in
(
create
(
:user
))
sign_in
(
create
(
:user
))
...
...
spec/features/user_can_display_performance_bar_spec.rb
View file @
e9ccf9c7
...
@@ -37,7 +37,7 @@ describe 'User can display performance bar', :js do
...
@@ -37,7 +37,7 @@ describe 'User can display performance bar', :js do
shared_examples
'performance bar is enabled by default in development'
do
shared_examples
'performance bar is enabled by default in development'
do
before
do
before
do
allow
(
Rails
.
env
).
to
receive
(
:development?
).
and_return
(
true
)
stub_rails_env
(
'development'
)
end
end
it
'shows the performance bar by default'
do
it
'shows the performance bar by default'
do
...
...
spec/helpers/icons_helper_spec.rb
View file @
e9ccf9c7
...
@@ -60,20 +60,19 @@ describe IconsHelper do
...
@@ -60,20 +60,19 @@ describe IconsHelper do
non_existing
=
'non_existing_icon_sprite'
non_existing
=
'non_existing_icon_sprite'
it
'raises in development mode'
do
it
'raises in development mode'
do
allow
(
Rails
.
env
).
to
receive
(
:development?
).
and_return
(
true
)
stub_rails_env
(
'development'
)
expect
{
sprite_icon
(
non_existing
)
}.
to
raise_error
(
ArgumentError
,
/is not a known icon/
)
expect
{
sprite_icon
(
non_existing
)
}.
to
raise_error
(
ArgumentError
,
/is not a known icon/
)
end
end
it
'raises in test mode'
do
it
'raises in test mode'
do
allow
(
Rails
.
env
).
to
receive
(
:test?
).
and_return
(
true
)
stub_rails_env
(
'test'
)
expect
{
sprite_icon
(
non_existing
)
}.
to
raise_error
(
ArgumentError
,
/is not a known icon/
)
expect
{
sprite_icon
(
non_existing
)
}.
to
raise_error
(
ArgumentError
,
/is not a known icon/
)
end
end
it
'does not raise in production mode'
do
it
'does not raise in production mode'
do
allow
(
Rails
.
env
).
to
receive
(
:test?
).
and_return
(
false
)
stub_rails_env
(
'production'
)
allow
(
Rails
.
env
).
to
receive
(
:development?
).
and_return
(
false
)
expect
{
sprite_icon
(
non_existing
)
}.
not_to
raise_error
expect
{
sprite_icon
(
non_existing
)
}.
not_to
raise_error
end
end
...
...
spec/helpers/version_check_helper_spec.rb
View file @
e9ccf9c7
...
@@ -3,7 +3,7 @@ require 'spec_helper'
...
@@ -3,7 +3,7 @@ require 'spec_helper'
describe
VersionCheckHelper
do
describe
VersionCheckHelper
do
describe
'#version_status_badge'
do
describe
'#version_status_badge'
do
it
'returns nil if not dev environment and not enabled'
do
it
'returns nil if not dev environment and not enabled'
do
allow
(
Rails
.
env
).
to
receive
(
:production?
)
{
false
}
stub_rails_env
(
'development'
)
allow
(
Gitlab
::
CurrentSettings
.
current_application_settings
).
to
receive
(
:version_check_enabled
)
{
false
}
allow
(
Gitlab
::
CurrentSettings
.
current_application_settings
).
to
receive
(
:version_check_enabled
)
{
false
}
expect
(
helper
.
version_status_badge
).
to
be
(
nil
)
expect
(
helper
.
version_status_badge
).
to
be
(
nil
)
...
@@ -11,7 +11,7 @@ describe VersionCheckHelper do
...
@@ -11,7 +11,7 @@ describe VersionCheckHelper do
context
'when production and enabled'
do
context
'when production and enabled'
do
before
do
before
do
allow
(
Rails
.
env
).
to
receive
(
:production?
)
{
true
}
stub_rails_env
(
'production'
)
allow
(
Gitlab
::
CurrentSettings
.
current_application_settings
).
to
receive
(
:version_check_enabled
)
{
true
}
allow
(
Gitlab
::
CurrentSettings
.
current_application_settings
).
to
receive
(
:version_check_enabled
)
{
true
}
allow
(
VersionCheck
).
to
receive
(
:url
)
{
'https://version.host.com/check.svg?gitlab_info=xxx'
}
allow
(
VersionCheck
).
to
receive
(
:url
)
{
'https://version.host.com/check.svg?gitlab_info=xxx'
}
end
end
...
...
spec/lib/gitlab/database/migration_helpers_spec.rb
View file @
e9ccf9c7
...
@@ -1283,33 +1283,19 @@ describe Gitlab::Database::MigrationHelpers do
...
@@ -1283,33 +1283,19 @@ describe Gitlab::Database::MigrationHelpers do
describe
'#perform_background_migration_inline?'
do
describe
'#perform_background_migration_inline?'
do
it
'returns true in a test environment'
do
it
'returns true in a test environment'
do
allow
(
Rails
.
env
)
stub_rails_env
(
'test'
)
.
to
receive
(
:test?
)
.
and_return
(
true
)
expect
(
model
.
perform_background_migration_inline?
).
to
eq
(
true
)
expect
(
model
.
perform_background_migration_inline?
).
to
eq
(
true
)
end
end
it
'returns true in a development environment'
do
it
'returns true in a development environment'
do
allow
(
Rails
.
env
)
stub_rails_env
(
'development'
)
.
to
receive
(
:test?
)
.
and_return
(
false
)
allow
(
Rails
.
env
)
.
to
receive
(
:development?
)
.
and_return
(
true
)
expect
(
model
.
perform_background_migration_inline?
).
to
eq
(
true
)
expect
(
model
.
perform_background_migration_inline?
).
to
eq
(
true
)
end
end
it
'returns false in a production environment'
do
it
'returns false in a production environment'
do
allow
(
Rails
.
env
)
stub_rails_env
(
'production'
)
.
to
receive
(
:test?
)
.
and_return
(
false
)
allow
(
Rails
.
env
)
.
to
receive
(
:development?
)
.
and_return
(
false
)
expect
(
model
.
perform_background_migration_inline?
).
to
eq
(
false
)
expect
(
model
.
perform_background_migration_inline?
).
to
eq
(
false
)
end
end
...
...
spec/lib/gitlab/favicon_spec.rb
View file @
e9ccf9c7
require
'spec_helper'
require
'spec_helper'
RSpec
.
describe
Gitlab
::
Favicon
,
:request_store
do
RSpec
.
describe
Gitlab
::
Favicon
,
:request_store
do
include
RailsHelpers
describe
'.main'
do
describe
'.main'
do
it
'defaults to favicon.png'
do
it
'defaults to favicon.png'
do
stub_rails_env
(
'production'
)
stub_rails_env
(
'production'
)
...
...
spec/lib/gitlab/gitaly_client_spec.rb
View file @
e9ccf9c7
...
@@ -265,7 +265,7 @@ describe Gitlab::GitalyClient do
...
@@ -265,7 +265,7 @@ describe Gitlab::GitalyClient do
context
'in production and when RequestStore is enabled'
,
:request_store
do
context
'in production and when RequestStore is enabled'
,
:request_store
do
before
do
before
do
allow
(
Rails
.
env
).
to
receive
(
:production?
).
and_return
(
true
)
stub_rails_env
(
'production'
)
end
end
context
'when the maximum number of calls is enforced by a feature flag'
do
context
'when the maximum number of calls is enforced by a feature flag'
do
...
...
spec/lib/gitlab/query_limiting/transaction_spec.rb
View file @
e9ccf9c7
...
@@ -86,9 +86,7 @@ describe Gitlab::QueryLimiting::Transaction do
...
@@ -86,9 +86,7 @@ describe Gitlab::QueryLimiting::Transaction do
it
'returns false in a production environment'
do
it
'returns false in a production environment'
do
transaction
=
described_class
.
new
transaction
=
described_class
.
new
expect
(
Rails
.
env
)
stub_rails_env
(
'production'
)
.
to
receive
(
:test?
)
.
and_return
(
false
)
expect
(
transaction
.
raise_error?
).
to
eq
(
false
)
expect
(
transaction
.
raise_error?
).
to
eq
(
false
)
end
end
...
...
spec/lib/gitlab/query_limiting_spec.rb
View file @
e9ccf9c7
...
@@ -9,14 +9,14 @@ describe Gitlab::QueryLimiting do
...
@@ -9,14 +9,14 @@ describe Gitlab::QueryLimiting do
end
end
it
'returns true in a development environment'
do
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
)
expect
(
described_class
.
enable?
).
to
eq
(
true
)
end
end
it
'returns false on GitLab.com'
do
it
'returns false on GitLab.com'
do
expect
(
Rails
.
env
).
to
receive
(
:development?
).
and_return
(
false
)
stub_rails_env
(
'production'
)
expect
(
Rails
.
env
).
to
receive
(
:test?
).
and_return
(
false
)
allow
(
Gitlab
).
to
receive
(
:com?
).
and_return
(
true
)
allow
(
Gitlab
).
to
receive
(
:com?
).
and_return
(
true
)
expect
(
described_class
.
enable?
).
to
eq
(
false
)
expect
(
described_class
.
enable?
).
to
eq
(
false
)
...
@@ -24,8 +24,7 @@ describe Gitlab::QueryLimiting do
...
@@ -24,8 +24,7 @@ describe Gitlab::QueryLimiting do
it
'returns false in a non GitLab.com'
do
it
'returns false in a non GitLab.com'
do
allow
(
Gitlab
).
to
receive
(
:com?
).
and_return
(
false
)
allow
(
Gitlab
).
to
receive
(
:com?
).
and_return
(
false
)
expect
(
Rails
.
env
).
to
receive
(
:development?
).
and_return
(
false
)
stub_rails_env
(
'production'
)
expect
(
Rails
.
env
).
to
receive
(
:test?
).
and_return
(
false
)
expect
(
described_class
.
enable?
).
to
eq
(
false
)
expect
(
described_class
.
enable?
).
to
eq
(
false
)
end
end
...
...
spec/lib/gitlab_spec.rb
View file @
e9ccf9c7
...
@@ -3,8 +3,6 @@
...
@@ -3,8 +3,6 @@
require
'spec_helper'
require
'spec_helper'
describe
Gitlab
do
describe
Gitlab
do
include
RailsHelpers
describe
'.root'
do
describe
'.root'
do
it
'returns the root path of the app'
do
it
'returns the root path of the app'
do
expect
(
described_class
.
root
).
to
eq
(
Pathname
.
new
(
File
.
expand_path
(
'../..'
,
__dir__
)))
expect
(
described_class
.
root
).
to
eq
(
Pathname
.
new
(
File
.
expand_path
(
'../..'
,
__dir__
)))
...
...
spec/models/concerns/cacheable_attributes_spec.rb
View file @
e9ccf9c7
...
@@ -131,7 +131,7 @@ describe CacheableAttributes do
...
@@ -131,7 +131,7 @@ describe CacheableAttributes do
context
'in production environment'
do
context
'in production environment'
do
before
do
before
do
expect
(
Rails
.
env
).
to
receive
(
:production?
).
and_return
(
true
)
stub_rails_env
(
'production'
)
end
end
it
'returns an uncached record and logs a warning'
do
it
'returns an uncached record and logs a warning'
do
...
@@ -143,7 +143,7 @@ describe CacheableAttributes do
...
@@ -143,7 +143,7 @@ describe CacheableAttributes do
context
'in other environments'
do
context
'in other environments'
do
before
do
before
do
expect
(
Rails
.
env
).
to
receive
(
:production?
).
and_return
(
false
)
stub_rails_env
(
'development'
)
end
end
it
'returns an uncached record and logs a warning'
do
it
'returns an uncached record and logs a warning'
do
...
...
spec/models/concerns/sha_attribute_spec.rb
View file @
e9ccf9c7
...
@@ -17,7 +17,7 @@ describe ShaAttribute do
...
@@ -17,7 +17,7 @@ describe ShaAttribute do
describe
'#sha_attribute'
do
describe
'#sha_attribute'
do
context
'when in non-production'
do
context
'when in non-production'
do
before
do
before
do
allow
(
Rails
.
env
).
to
receive
(
:production?
).
and_return
(
false
)
stub_rails_env
(
'development'
)
end
end
context
'when the table exists'
do
context
'when the table exists'
do
...
@@ -76,7 +76,7 @@ describe ShaAttribute do
...
@@ -76,7 +76,7 @@ describe ShaAttribute do
context
'when in production'
do
context
'when in production'
do
before
do
before
do
allow
(
Rails
.
env
).
to
receive
(
:production?
).
and_return
(
true
)
stub_rails_env
(
'production'
)
end
end
it
'defines a SHA attribute'
do
it
'defines a SHA attribute'
do
...
...
spec/models/internal_id_spec.rb
View file @
e9ccf9c7
...
@@ -106,7 +106,8 @@ describe InternalId do
...
@@ -106,7 +106,8 @@ describe InternalId do
end
end
it
'always attempts to generate internal IDs in production mode'
do
it
'always attempts to generate internal IDs in production mode'
do
allow
(
Rails
.
env
).
to
receive
(
:test?
).
and_return
(
false
)
stub_rails_env
(
'production'
)
val
=
rand
(
1
..
100
)
val
=
rand
(
1
..
100
)
generator
=
double
(
generate:
val
)
generator
=
double
(
generate:
val
)
expect
(
InternalId
::
InternalIdGenerator
).
to
receive
(
:new
).
and_return
(
generator
)
expect
(
InternalId
::
InternalIdGenerator
).
to
receive
(
:new
).
and_return
(
generator
)
...
...
spec/spec_helper.rb
View file @
e9ccf9c7
...
@@ -111,6 +111,7 @@ RSpec.configure do |config|
...
@@ -111,6 +111,7 @@ RSpec.configure do |config|
config
.
include
PolicyHelpers
,
type: :policy
config
.
include
PolicyHelpers
,
type: :policy
config
.
include
MemoryUsageHelper
config
.
include
MemoryUsageHelper
config
.
include
ExpectRequestWithStatus
,
type: :request
config
.
include
ExpectRequestWithStatus
,
type: :request
config
.
include
RailsHelpers
if
ENV
[
'CI'
]
if
ENV
[
'CI'
]
# This includes the first try, i.e. tests will be run 4 times before failing.
# This includes the first try, i.e. tests will be run 4 times before failing.
...
...
spec/tasks/gitlab/gitaly_rake_spec.rb
View file @
e9ccf9c7
...
@@ -57,7 +57,7 @@ describe 'gitlab:gitaly namespace rake task' do
...
@@ -57,7 +57,7 @@ describe 'gitlab:gitaly namespace rake task' do
stub_env
(
'CI'
,
false
)
stub_env
(
'CI'
,
false
)
FileUtils
.
mkdir_p
(
clone_path
)
FileUtils
.
mkdir_p
(
clone_path
)
expect
(
Dir
).
to
receive
(
:chdir
).
with
(
clone_path
).
and_call_original
expect
(
Dir
).
to
receive
(
:chdir
).
with
(
clone_path
).
and_call_original
allow
(
Rails
.
env
).
to
receive
(
:test?
).
and_return
(
false
)
stub_rails_env
(
'development'
)
end
end
context
'gmake is available'
do
context
'gmake is available'
do
...
@@ -93,7 +93,7 @@ describe 'gitlab:gitaly namespace rake task' do
...
@@ -93,7 +93,7 @@ describe 'gitlab:gitaly namespace rake task' do
end
end
before
do
before
do
allow
(
Rails
.
env
).
to
receive
(
:test?
).
and_return
(
true
)
stub_rails_env
(
'test'
)
end
end
it
'calls make in the gitaly directory with --no-deployment flag for bundle'
do
it
'calls make in the gitaly directory with --no-deployment flag for bundle'
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment