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
12f070da
Commit
12f070da
authored
Mar 19, 2020
by
Ryan Cobb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix leaky rspec constants
The first of many MRs to address the new RSpec/LeakyConstantDeclaration cop.
parent
ecc53e94
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
75 additions
and
67 deletions
+75
-67
.rubocop.yml
.rubocop.yml
+14
-1
ee/spec/controllers/operations_controller_spec.rb
ee/spec/controllers/operations_controller_spec.rb
+7
-8
ee/spec/elastic_integration/global_search_spec.rb
ee/spec/elastic_integration/global_search_spec.rb
+1
-2
ee/spec/features/admin/admin_sends_notification_spec.rb
ee/spec/features/admin/admin_sends_notification_spec.rb
+2
-1
ee/spec/features/user_unsubscribes_from_admin_notifications_spec.rb
...atures/user_unsubscribes_from_admin_notifications_spec.rb
+2
-2
ee/spec/finders/security/pipeline_vulnerabilities_finder_spec.rb
.../finders/security/pipeline_vulnerabilities_finder_spec.rb
+1
-11
ee/spec/graphql/mutations/design_management/delete_spec.rb
ee/spec/graphql/mutations/design_management/delete_spec.rb
+5
-3
ee/spec/lib/csv_builder_spec.rb
ee/spec/lib/csv_builder_spec.rb
+7
-3
ee/spec/lib/gitlab/geo/cron_manager_spec.rb
ee/spec/lib/gitlab/geo/cron_manager_spec.rb
+36
-36
No files found.
.rubocop.yml
View file @
12f070da
...
...
@@ -302,8 +302,21 @@ RSpec/LeakyConstantDeclaration:
Enabled
:
true
Exclude
:
-
'
spec/**/*.rb'
-
'
ee/spec/**/*.rb'
-
'
qa/spec/**/*.rb'
-
'
ee/spec/lib/gitlab/geo/log_cursor/logger_spec.rb'
-
'
ee/spec/lib/gitlab/geo/log_helpers_spec.rb'
-
'
ee/spec/lib/gitlab/geo/replicator_spec.rb'
-
'
ee/spec/mailers/emails/service_desk_spec.rb'
-
'
ee/spec/migrations/remove_creations_in_gitlab_subscription_histories_spec.rb'
-
'
ee/spec/migrations/set_resolved_state_on_vulnerabilities_spec.rb'
-
'
ee/spec/models/repository_spec.rb'
-
'
ee/spec/presenters/security/vulnerable_project_presenter_spec.rb'
-
'
ee/spec/serializers/vulnerable_project_entity_spec.rb'
-
'
ee/spec/services/clusters/applications/check_upgrade_progress_service_spec.rb'
-
'
ee/spec/services/dashboard/projects/list_service_spec.rb'
-
'
ee/spec/services/metrics/dashboard/clone_dashboard_service_spec.rb'
-
'
ee/spec/support/shared_contexts/epic_aggregate_constants.rb'
-
'
ee/spec/workers/elastic_namespace_rollout_worker_spec.rb'
RSpec/EmptyLineAfterHook
:
Enabled
:
false
...
...
ee/spec/controllers/operations_controller_spec.rb
View file @
12f070da
...
...
@@ -5,11 +5,15 @@ require 'spec_helper'
describe
OperationsController
do
include
Rails
.
application
.
routes
.
url_helpers
PUBLIC
=
Gitlab
::
VisibilityLevel
::
PUBLIC
PRIVATE
=
Gitlab
::
VisibilityLevel
::
PRIVATE
let
(
:user
)
{
create
(
:user
)
}
before
do
stub_const
(
'PUBLIC'
,
Gitlab
::
VisibilityLevel
::
PUBLIC
)
stub_const
(
'PRIVATE'
,
Gitlab
::
VisibilityLevel
::
PRIVATE
)
stub_licensed_features
(
operations_dashboard:
true
)
sign_in
(
user
)
end
shared_examples
'unlicensed'
do
|
http_method
,
action
|
before
do
stub_licensed_features
(
operations_dashboard:
false
)
...
...
@@ -22,11 +26,6 @@ describe OperationsController do
end
end
before
do
stub_licensed_features
(
operations_dashboard:
true
)
sign_in
(
user
)
end
describe
'GET #index'
do
it_behaves_like
'unlicensed'
,
:get
,
:index
...
...
ee/spec/elastic_integration/global_search_spec.rb
View file @
12f070da
...
...
@@ -14,6 +14,7 @@ describe 'GlobalSearch', :elastic do
before
do
stub_ee_application_setting
(
elasticsearch_search:
true
,
elasticsearch_indexing:
true
)
stub_const
(
'POSSIBLE_FEATURES'
,
%i(issues merge_requests wiki_blobs blobs commits)
.
freeze
)
project
.
add_developer
(
member
)
project
.
add_developer
(
external_member
)
...
...
@@ -166,8 +167,6 @@ describe 'GlobalSearch', :elastic do
expect_items_to_be_found
(
user
,
except: :all
)
end
POSSIBLE_FEATURES
=
%i(issues merge_requests wiki_blobs blobs commits)
.
freeze
def
expect_items_to_be_found
(
user
,
only:
nil
,
except:
nil
)
arr
=
if
only
[
only
].
flatten
.
compact
...
...
ee/spec/features/admin/admin_sends_notification_spec.rb
View file @
12f070da
...
...
@@ -9,6 +9,8 @@ describe "Admin sends notification", :js, :sidekiq_might_not_need_inline do
let
(
:user
)
{
create
(
:user
)
}
before
do
stub_const
(
'NOTIFICATION_TEXT'
,
'Your project has been moved.'
.
freeze
)
group
.
add_developer
(
user
)
sign_in
(
admin
)
...
...
@@ -20,7 +22,6 @@ describe "Admin sends notification", :js, :sidekiq_might_not_need_inline do
it
"sends notification"
do
perform_enqueued_jobs
do
NOTIFICATION_TEXT
=
"Your project has been moved."
.
freeze
body
=
find
(
:xpath
,
"//body"
)
page
.
within
(
"form#new-admin-email"
)
do
...
...
ee/spec/features/user_unsubscribes_from_admin_notifications_spec.rb
View file @
12f070da
...
...
@@ -7,14 +7,14 @@ describe "Admin unsubscribes from notification" do
let_it_be
(
:urlsafe_email
)
{
Base64
.
urlsafe_encode64
(
user
.
email
)
}
before
do
stub_const
(
'NOTIFICATION_TEXT'
,
'You have been unsubscribed from receiving GitLab administrator notifications.'
.
freeze
)
sign_in
(
user
)
visit
(
unsubscribe_path
(
urlsafe_email
))
end
it
"unsubscribes from notifications"
do
NOTIFICATION_TEXT
=
"You have been unsubscribed from receiving GitLab administrator notifications."
.
freeze
perform_enqueued_jobs
do
click_button
(
"Unsubscribe"
)
end
...
...
ee/spec/finders/security/pipeline_vulnerabilities_finder_spec.rb
View file @
12f070da
...
...
@@ -3,19 +3,9 @@
require
'spec_helper'
describe
Security
::
PipelineVulnerabilitiesFinder
do
class
NoDeduplicationMergeReportsService
def
initialize
(
*
source_reports
)
@source_reports
=
source_reports
end
def
execute
@source_reports
.
last
end
end
def
disable_deduplication
allow
(
::
Security
::
MergeReportsService
).
to
receive
(
:new
)
do
|*
args
|
NoDeduplicationMergeReportsService
.
new
(
*
args
)
instance_double
(
'NoDeduplicationMergeReportsService'
,
execute:
args
.
last
)
end
end
...
...
ee/spec/graphql/mutations/design_management/delete_spec.rb
View file @
12f070da
...
...
@@ -5,8 +5,6 @@ require 'spec_helper'
describe
Mutations
::
DesignManagement
::
Delete
do
include
DesignManagementTestHelpers
Errors
=
Gitlab
::
Graphql
::
Errors
let
(
:issue
)
{
create
(
:issue
)
}
let
(
:current_designs
)
{
issue
.
designs
.
current
}
let
(
:user
)
{
issue
.
author
}
...
...
@@ -18,6 +16,10 @@ describe Mutations::DesignManagement::Delete do
let
(
:mutation
)
{
described_class
.
new
(
object:
nil
,
context:
{
current_user:
user
},
field:
nil
)
}
before
do
stub_const
(
'Errors'
,
Gitlab
::
Graphql
::
Errors
,
transfer_nested_constants:
true
)
end
def
run_mutation
mutation
=
described_class
.
new
(
object:
nil
,
context:
{
current_user:
user
},
field:
nil
)
mutation
.
resolve
(
project_path:
project
.
full_path
,
iid:
issue
.
iid
,
filenames:
filenames
)
...
...
@@ -28,7 +30,7 @@ describe Mutations::DesignManagement::Delete do
{
errors:
[],
version:
DesignManagement
::
Version
.
for_issue
(
issue
).
ordered
.
first
}
end
shared_examples
"failures"
do
|
error:
Errors
::
ResourceNotAvailable
|
shared_examples
"failures"
do
|
error:
Gitlab
::
Graphql
::
Errors
::
ResourceNotAvailable
|
it
"raises
#{
error
.
name
}
"
do
expect
{
run_mutation
}.
to
raise_error
(
error
)
end
...
...
ee/spec/lib/csv_builder_spec.rb
View file @
12f070da
...
...
@@ -8,9 +8,13 @@ describe CsvBuilder do
let
(
:subject
)
{
described_class
.
new
(
fake_relation
,
'Q & A'
=>
:question
,
'Reversed'
=>
->
(
o
)
{
o
.
question
.
to_s
.
reverse
})
}
let
(
:csv_data
)
{
subject
.
render
}
class
FakeRelation
<
Array
def
find_each
(
&
block
)
each
(
&
block
)
before
do
stub_const
(
'FakeRelation'
,
Array
)
FakeRelation
.
class_eval
do
def
find_each
(
&
block
)
each
(
&
block
)
end
end
end
...
...
ee/spec/lib/gitlab/geo/cron_manager_spec.rb
View file @
12f070da
...
...
@@ -5,6 +5,19 @@ require 'spec_helper'
describe
Gitlab
::
Geo
::
CronManager
,
:geo
do
include
::
EE
::
GeoHelpers
jobs
=
%w[
ldap_test
repository_check_worker
geo_repository_verification_primary_batch_worker
geo_repository_sync_worker
geo_file_download_dispatch_worker
geo_container_repository_sync_worker
geo_repository_verification_secondary_scheduler_worker
geo_metrics_update_worker
geo_prune_event_log_worker
geo_migrated_local_files_clean_up_worker
]
.
freeze
def
job
(
name
)
Sidekiq
::
Cron
::
Job
.
find
(
name
)
end
...
...
@@ -15,41 +28,6 @@ describe Gitlab::Geo::CronManager, :geo do
let_it_be
(
:primary
)
{
create
(
:geo_node
,
:primary
)
}
let_it_be
(
:secondary
)
{
create
(
:geo_node
)
}
def
init_cron_job
(
job_name
,
class_name
)
job
=
Sidekiq
::
Cron
::
Job
.
new
(
name:
job_name
,
cron:
'0 * * * *'
,
class:
class_name
)
job
.
enable!
end
def
count_enabled
JOBS
.
count
{
|
job_name
|
job
(
job_name
).
enabled?
}
end
JOBS
=
%w[
ldap_test
repository_check_worker
geo_repository_verification_primary_batch_worker
geo_repository_sync_worker
geo_file_download_dispatch_worker
geo_container_repository_sync_worker
geo_repository_verification_secondary_scheduler_worker
geo_metrics_update_worker
geo_prune_event_log_worker
geo_migrated_local_files_clean_up_worker
]
.
freeze
before
(
:all
)
do
JOBS
.
each
{
|
name
|
init_cron_job
(
name
,
name
.
camelize
)
}
end
after
(
:all
)
do
JOBS
.
each
{
|
name
|
job
(
name
)
&
.
destroy
}
end
let
(
:common_jobs
)
{
[
job
(
'geo_metrics_update_worker'
),
job
(
'repository_check_worker'
)]
}
let
(
:ldap_test_job
)
{
job
(
'ldap_test'
)
}
let
(
:primary_jobs
)
{
[
job
(
'geo_repository_verification_primary_batch_worker'
)]
}
...
...
@@ -64,6 +42,28 @@ describe Gitlab::Geo::CronManager, :geo do
]
end
before
(
:all
)
do
jobs
.
each
{
|
name
|
init_cron_job
(
name
,
name
.
camelize
)
}
end
after
(
:all
)
do
jobs
.
each
{
|
name
|
job
(
name
)
&
.
destroy
}
end
def
init_cron_job
(
job_name
,
class_name
)
job
=
Sidekiq
::
Cron
::
Job
.
new
(
name:
job_name
,
cron:
'0 * * * *'
,
class:
class_name
)
job
.
enable!
end
def
count_enabled
(
jobs
)
jobs
.
count
{
|
job_name
|
job
(
job_name
).
enabled?
}
end
context
'on a Geo primary'
do
before
do
stub_current_geo_node
(
primary
)
...
...
@@ -91,7 +91,7 @@ describe Gitlab::Geo::CronManager, :geo do
it
'does not change current job configuration'
do
allow
(
Geo
).
to
receive
(
:connected?
).
and_return
(
false
)
expect
{
manager
.
execute
}.
not_to
change
{
count_enabled
}
expect
{
manager
.
execute
}.
not_to
change
{
count_enabled
(
jobs
)
}
end
end
end
...
...
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