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
124bad7b
Commit
124bad7b
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
0fca70a4
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
25 additions
and
45 deletions
+25
-45
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.
spec/features/help_pages_spec.rb
View file @
124bad7b
...
...
@@ -58,7 +58,7 @@ describe 'Help Pages' do
before
do
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'
)
sign_in
(
create
(
:user
))
...
...
spec/features/user_can_display_performance_bar_spec.rb
View file @
124bad7b
...
...
@@ -37,7 +37,7 @@ describe 'User can display performance bar', :js do
shared_examples
'performance bar is enabled by default in development'
do
before
do
allow
(
Rails
.
env
).
to
receive
(
:development?
).
and_return
(
true
)
stub_rails_env
(
'development'
)
end
it
'shows the performance bar by default'
do
...
...
spec/helpers/icons_helper_spec.rb
View file @
124bad7b
...
...
@@ -60,20 +60,19 @@ describe IconsHelper do
non_existing
=
'non_existing_icon_sprite'
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/
)
end
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/
)
end
it
'does not raise in production mode'
do
allow
(
Rails
.
env
).
to
receive
(
:test?
).
and_return
(
false
)
allow
(
Rails
.
env
).
to
receive
(
:development?
).
and_return
(
false
)
stub_rails_env
(
'production'
)
expect
{
sprite_icon
(
non_existing
)
}.
not_to
raise_error
end
...
...
spec/helpers/version_check_helper_spec.rb
View file @
124bad7b
...
...
@@ -3,7 +3,7 @@ require 'spec_helper'
describe
VersionCheckHelper
do
describe
'#version_status_badge'
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
}
expect
(
helper
.
version_status_badge
).
to
be
(
nil
)
...
...
@@ -11,7 +11,7 @@ describe VersionCheckHelper do
context
'when production and enabled'
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
(
VersionCheck
).
to
receive
(
:url
)
{
'https://version.host.com/check.svg?gitlab_info=xxx'
}
end
...
...
spec/lib/gitlab/database/migration_helpers_spec.rb
View file @
124bad7b
...
...
@@ -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
...
...
spec/lib/gitlab/favicon_spec.rb
View file @
124bad7b
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'
)
...
...
spec/lib/gitlab/gitaly_client_spec.rb
View file @
124bad7b
...
...
@@ -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
...
...
spec/lib/gitlab/query_limiting/transaction_spec.rb
View file @
124bad7b
...
...
@@ -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
...
...
spec/lib/gitlab/query_limiting_spec.rb
View file @
124bad7b
...
...
@@ -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
...
...
spec/lib/gitlab_spec.rb
View file @
124bad7b
...
...
@@ -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__
)))
...
...
spec/models/concerns/cacheable_attributes_spec.rb
View file @
124bad7b
...
...
@@ -131,7 +131,7 @@ describe CacheableAttributes do
context
'in production environment'
do
before
do
expect
(
Rails
.
env
).
to
receive
(
:production?
).
and_return
(
true
)
stub_rails_env
(
'production'
)
end
it
'returns an uncached record and logs a warning'
do
...
...
@@ -143,7 +143,7 @@ describe CacheableAttributes do
context
'in other environments'
do
before
do
expect
(
Rails
.
env
).
to
receive
(
:production?
).
and_return
(
false
)
stub_rails_env
(
'development'
)
end
it
'returns an uncached record and logs a warning'
do
...
...
spec/models/concerns/sha_attribute_spec.rb
View file @
124bad7b
...
...
@@ -17,7 +17,7 @@ describe ShaAttribute do
describe
'#sha_attribute'
do
context
'when in non-production'
do
before
do
allow
(
Rails
.
env
).
to
receive
(
:production?
).
and_return
(
false
)
stub_rails_env
(
'development'
)
end
context
'when the table exists'
do
...
...
@@ -76,7 +76,7 @@ describe ShaAttribute do
context
'when in production'
do
before
do
allow
(
Rails
.
env
).
to
receive
(
:production?
).
and_return
(
true
)
stub_rails_env
(
'production'
)
end
it
'defines a SHA attribute'
do
...
...
spec/models/internal_id_spec.rb
View file @
124bad7b
...
...
@@ -106,7 +106,8 @@ describe InternalId do
end
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
)
generator
=
double
(
generate:
val
)
expect
(
InternalId
::
InternalIdGenerator
).
to
receive
(
:new
).
and_return
(
generator
)
...
...
spec/spec_helper.rb
View file @
124bad7b
...
...
@@ -109,6 +109,7 @@ RSpec.configure do |config|
config
.
include
PolicyHelpers
,
type: :policy
config
.
include
MemoryUsageHelper
config
.
include
ExpectRequestWithStatus
,
type: :request
config
.
include
RailsHelpers
if
ENV
[
'CI'
]
# This includes the first try, i.e. tests will be run 4 times before failing.
...
...
spec/tasks/gitlab/gitaly_rake_spec.rb
View file @
124bad7b
...
...
@@ -57,7 +57,7 @@ describe 'gitlab:gitaly namespace rake task' do
stub_env
(
'CI'
,
false
)
FileUtils
.
mkdir_p
(
clone_path
)
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
context
'gmake is available'
do
...
...
@@ -93,7 +93,7 @@ describe 'gitlab:gitaly namespace rake task' do
end
before
do
allow
(
Rails
.
env
).
to
receive
(
:test?
).
and_return
(
true
)
stub_rails_env
(
'test'
)
end
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