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
ab85b805
Commit
ab85b805
authored
Jan 21, 2021
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ban attributes_for for migration specs
We'll rewrite the offenders later.
parent
ba4bac42
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
23 additions
and
23 deletions
+23
-23
ee/spec/lib/ee/gitlab/background_migration/remove_duplicate_cs_findings_spec.rb
...background_migration/remove_duplicate_cs_findings_spec.rb
+1
-1
ee/spec/lib/ee/gitlab/background_migration/remove_duplicated_cs_findings_without_vulnerability_id_spec.rb
...e_duplicated_cs_findings_without_vulnerability_id_spec.rb
+1
-1
ee/spec/lib/ee/gitlab/background_migration/remove_undefined_occurrence_confidence_level_spec.rb
...tion/remove_undefined_occurrence_confidence_level_spec.rb
+1
-1
ee/spec/lib/ee/gitlab/background_migration/remove_undefined_occurrence_severity_level_spec.rb
...ration/remove_undefined_occurrence_severity_level_spec.rb
+1
-1
ee/spec/lib/ee/gitlab/background_migration/update_location_fingerprint_for_container_scanning_findings_spec.rb
...ation_fingerprint_for_container_scanning_findings_spec.rb
+1
-1
ee/spec/lib/ee/gitlab/background_migration/update_vulnerability_confidence_spec.rb
...kground_migration/update_vulnerability_confidence_spec.rb
+1
-1
ee/spec/migrations/remove_duplicated_cs_findings_spec.rb
ee/spec/migrations/remove_duplicated_cs_findings_spec.rb
+1
-1
ee/spec/migrations/remove_duplicated_cs_findings_without_vulnerability_id_spec.rb
...e_duplicated_cs_findings_without_vulnerability_id_spec.rb
+1
-1
ee/spec/migrations/update_cs_vulnerability_confidence_column_spec.rb
...rations/update_cs_vulnerability_confidence_column_spec.rb
+2
-2
ee/spec/migrations/update_location_fingerprint_column_for_cs_spec.rb
...rations/update_location_fingerprint_column_for_cs_spec.rb
+1
-1
ee/spec/migrations/update_occurrence_severity_column_spec.rb
ee/spec/migrations/update_occurrence_severity_column_spec.rb
+2
-2
ee/spec/migrations/update_undefined_confidence_from_occurrences_spec.rb
...ions/update_undefined_confidence_from_occurrences_spec.rb
+3
-2
rubocop/cop/rspec/factories_in_migration_specs.rb
rubocop/cop/rspec/factories_in_migration_specs.rb
+1
-1
spec/migrations/schedule_migrate_security_scans_spec.rb
spec/migrations/schedule_migrate_security_scans_spec.rb
+5
-6
spec/rubocop/cop/rspec/factories_in_migration_specs_spec.rb
spec/rubocop/cop/rspec/factories_in_migration_specs_spec.rb
+1
-1
No files found.
ee/spec/lib/ee/gitlab/background_migration/remove_duplicate_cs_findings_spec.rb
View file @
ab85b805
...
...
@@ -106,7 +106,7 @@ RSpec.describe Gitlab::BackgroundMigration::RemoveDuplicateCsFindings, :migratio
end
def
finding_params
(
primary_identifier_id
,
project_id
)
attrs
=
attributes_for
(
:vulnerabilities_finding
)
attrs
=
attributes_for
(
:vulnerabilities_finding
)
# rubocop: disable RSpec/FactoriesInMigrationSpecs
{
severity:
0
,
confidence:
5
,
...
...
ee/spec/lib/ee/gitlab/background_migration/remove_duplicated_cs_findings_without_vulnerability_id_spec.rb
View file @
ab85b805
...
...
@@ -76,7 +76,7 @@ RSpec.describe Gitlab::BackgroundMigration::RemoveDuplicatedCsFindingsWithoutVul
end
def
finding_params
(
primary_identifier_id
,
project_id
)
attrs
=
attributes_for
(
:vulnerabilities_finding
)
attrs
=
attributes_for
(
:vulnerabilities_finding
)
# rubocop: disable RSpec/FactoriesInMigrationSpecs
{
severity:
0
,
confidence:
5
,
...
...
ee/spec/lib/ee/gitlab/background_migration/remove_undefined_occurrence_confidence_level_spec.rb
View file @
ab85b805
...
...
@@ -34,7 +34,7 @@ RSpec.describe Gitlab::BackgroundMigration::RemoveUndefinedOccurrenceConfidenceL
end
def
vuln_params
(
primary_identifier_id
)
attrs
=
attributes_for
(
:vulnerabilities_finding
)
attrs
=
attributes_for
(
:vulnerabilities_finding
)
# rubocop: disable RSpec/FactoriesInMigrationSpecs
{
confidence:
0
,
...
...
ee/spec/lib/ee/gitlab/background_migration/remove_undefined_occurrence_severity_level_spec.rb
View file @
ab85b805
...
...
@@ -34,7 +34,7 @@ RSpec.describe Gitlab::BackgroundMigration::RemoveUndefinedOccurrenceSeverityLev
end
def
vuln_params
(
primary_identifier_id
)
attrs
=
attributes_for
(
:vulnerabilities_finding
)
attrs
=
attributes_for
(
:vulnerabilities_finding
)
# rubocop: disable RSpec/FactoriesInMigrationSpecs
{
severity:
0
,
...
...
ee/spec/lib/ee/gitlab/background_migration/update_location_fingerprint_for_container_scanning_findings_spec.rb
View file @
ab85b805
...
...
@@ -82,7 +82,7 @@ RSpec.describe Gitlab::BackgroundMigration::UpdateLocationFingerprintForContaine
end
def
finding_params
(
primary_identifier_id
)
attrs
=
attributes_for
(
:vulnerabilities_finding
)
attrs
=
attributes_for
(
:vulnerabilities_finding
)
# rubocop: disable RSpec/FactoriesInMigrationSpecs
{
severity:
0
,
confidence:
5
,
...
...
ee/spec/lib/ee/gitlab/background_migration/update_vulnerability_confidence_spec.rb
View file @
ab85b805
...
...
@@ -36,7 +36,7 @@ RSpec.describe Gitlab::BackgroundMigration::UpdateVulnerabilityConfidence, schem
end
def
container_scanning_vuln_params
(
primary_identifier_id
)
attrs
=
attributes_for
(
:vulnerabilities_finding
)
attrs
=
attributes_for
(
:vulnerabilities_finding
)
# rubocop: disable RSpec/FactoriesInMigrationSpecs
{
severity:
2
,
...
...
ee/spec/migrations/remove_duplicated_cs_findings_spec.rb
View file @
ab85b805
...
...
@@ -90,7 +90,7 @@ RSpec.describe RemoveDuplicatedCsFindings, :migration do
end
def
finding_params
(
primary_identifier_id
,
project_id
)
attrs
=
attributes_for
(
:vulnerabilities_finding
)
attrs
=
attributes_for
(
:vulnerabilities_finding
)
# rubocop: disable RSpec/FactoriesInMigrationSpecs
{
severity:
0
,
confidence:
5
,
...
...
ee/spec/migrations/remove_duplicated_cs_findings_without_vulnerability_id_spec.rb
View file @
ab85b805
...
...
@@ -99,7 +99,7 @@ RSpec.describe RemoveDuplicatedCsFindingsWithoutVulnerabilityId, :migration do
end
def
finding_params
(
primary_identifier_id
,
project_id
)
attrs
=
attributes_for
(
:vulnerabilities_finding
)
attrs
=
attributes_for
(
:vulnerabilities_finding
)
# rubocop: disable RSpec/FactoriesInMigrationSpecs
{
severity:
0
,
confidence:
5
,
...
...
ee/spec/migrations/update_cs_vulnerability_confidence_column_spec.rb
View file @
ab85b805
...
...
@@ -8,8 +8,8 @@ RSpec.describe UpdateCsVulnerabilityConfidenceColumn do
let
(
:identifiers
)
{
table
(
:vulnerability_identifiers
)
}
let
(
:scanners
)
{
table
(
:vulnerability_scanners
)
}
let
(
:projects
)
{
table
(
:projects
)
}
let
(
:vul1
)
{
attributes_for
(
:vulnerabilities_finding
,
id:
1
,
report_type:
2
,
confidence:
5
)
}
let
(
:vul2
)
{
attributes_for
(
:vulnerabilities_finding
,
id:
2
,
report_type:
2
,
confidence:
5
)
}
let
(
:vul1
)
{
attributes_for
(
:vulnerabilities_finding
,
id:
1
,
report_type:
2
,
confidence:
5
)
}
# rubocop: disable RSpec/FactoriesInMigrationSpecs
let
(
:vul2
)
{
attributes_for
(
:vulnerabilities_finding
,
id:
2
,
report_type:
2
,
confidence:
5
)
}
# rubocop: disable RSpec/FactoriesInMigrationSpecs
before
do
stub_const
(
"
#{
described_class
}
::BATCH_SIZE"
,
2
)
...
...
ee/spec/migrations/update_location_fingerprint_column_for_cs_spec.rb
View file @
ab85b805
...
...
@@ -77,7 +77,7 @@ RSpec.describe UpdateLocationFingerprintColumnForCs, :migration do
end
def
finding_params
(
primary_identifier_id
)
attrs
=
attributes_for
(
:vulnerabilities_finding
)
attrs
=
attributes_for
(
:vulnerabilities_finding
)
# rubocop: disable RSpec/FactoriesInMigrationSpecs
{
severity:
0
,
confidence:
5
,
...
...
ee/spec/migrations/update_occurrence_severity_column_spec.rb
View file @
ab85b805
...
...
@@ -8,8 +8,8 @@ RSpec.describe UpdateOccurrenceSeverityColumn do
let
(
:identifiers
)
{
table
(
:vulnerability_identifiers
)
}
let
(
:scanners
)
{
table
(
:vulnerability_scanners
)
}
let
(
:projects
)
{
table
(
:projects
)
}
let
(
:vul1
)
{
attributes_for
(
:vulnerabilities_finding
,
id:
1
,
report_type:
2
,
confidence:
5
)
}
let
(
:vul2
)
{
attributes_for
(
:vulnerabilities_finding
,
id:
2
,
report_type:
2
,
confidence:
5
)
}
let
(
:vul1
)
{
attributes_for
(
:vulnerabilities_finding
,
id:
1
,
report_type:
2
,
confidence:
5
)
}
# rubocop: disable RSpec/FactoriesInMigrationSpecs
let
(
:vul2
)
{
attributes_for
(
:vulnerabilities_finding
,
id:
2
,
report_type:
2
,
confidence:
5
)
}
# rubocop: disable RSpec/FactoriesInMigrationSpecs
before
do
stub_const
(
"
#{
described_class
}
::BATCH_SIZE"
,
2
)
...
...
ee/spec/migrations/update_undefined_confidence_from_occurrences_spec.rb
View file @
ab85b805
...
...
@@ -8,8 +8,9 @@ RSpec.describe UpdateUndefinedConfidenceFromOccurrences, :migration do
let
(
:identifiers
)
{
table
(
:vulnerability_identifiers
)
}
let
(
:scanners
)
{
table
(
:vulnerability_scanners
)
}
let
(
:projects
)
{
table
(
:projects
)
}
let
(
:vul1
)
{
attributes_for
(
:vulnerabilities_finding
,
id:
1
,
report_type:
2
,
confidence:
5
)
}
let
(
:vul2
)
{
attributes_for
(
:vulnerabilities_finding
,
id:
2
,
report_type:
2
,
confidence:
5
)
}
let
(
:vul1
)
{
attributes_for
(
:vulnerabilities_finding
,
id:
1
,
report_type:
2
,
confidence:
5
)
}
# rubocop: disable RSpec/FactoriesInMigrationSpecs
let
(
:vul2
)
{
attributes_for
(
:vulnerabilities_finding
,
id:
2
,
report_type:
2
,
confidence:
5
)
}
# rubocop: disable RSpec/FactoriesInMigrationSpecs
before
do
stub_const
(
"
#{
described_class
}
::BATCH_SIZE"
,
2
)
...
...
rubocop/cop/rspec/factories_in_migration_specs.rb
View file @
ab85b805
...
...
@@ -15,7 +15,7 @@ module RuboCop
# let(:user) { users.create!(name: 'User 1', username: 'user1') }
class
FactoriesInMigrationSpecs
<
RuboCop
::
Cop
::
Cop
MESSAGE
=
"Don't use FactoryBot.%s in migration specs, use `table` instead."
.
freeze
FORBIDDEN_METHODS
=
%i[build build_list create create_list]
.
freeze
FORBIDDEN_METHODS
=
%i[build build_list create create_list
attributes_for
]
.
freeze
def_node_search
:forbidden_factory_usage?
,
<<~
PATTERN
(send {(const nil? :FactoryBot) nil?} {
#{
FORBIDDEN_METHODS
.
map
(
&
:inspect
).
join
(
' '
)
}
} ...)
...
...
spec/migrations/schedule_migrate_security_scans_spec.rb
View file @
ab85b805
...
...
@@ -3,7 +3,6 @@
require
'spec_helper'
require
Rails
.
root
.
join
(
'db'
,
'post_migrate'
,
'20200217225719_schedule_migrate_security_scans.rb'
)
# rubocop: disable RSpec/FactoriesInMigrationSpecs
RSpec
.
describe
ScheduleMigrateSecurityScans
,
:sidekiq
do
let
(
:migration
)
{
described_class
.
new
}
let
(
:namespaces
)
{
table
(
:namespaces
)
}
...
...
@@ -13,7 +12,7 @@ RSpec.describe ScheduleMigrateSecurityScans, :sidekiq do
let
(
:namespace
)
{
namespaces
.
create!
(
name:
"foo"
,
path:
"bar"
)
}
let
(
:project
)
{
projects
.
create!
(
namespace_id:
namespace
.
id
)
}
let
(
:
build
)
{
builds
.
create!
}
let
(
:
job
)
{
builds
.
create!
}
before
do
stub_const
(
"
#{
described_class
.
name
}
::BATCH_SIZE"
,
1
)
...
...
@@ -35,8 +34,8 @@ RSpec.describe ScheduleMigrateSecurityScans, :sidekiq do
end
context
'has security job artifacts'
do
let!
(
:job_artifact_1
)
{
job_artifacts
.
create!
(
project_id:
project
.
id
,
job_id:
build
.
id
,
file_type:
5
)
}
let!
(
:job_artifact_2
)
{
job_artifacts
.
create!
(
project_id:
project
.
id
,
job_id:
build
.
id
,
file_type:
8
)
}
let!
(
:job_artifact_1
)
{
job_artifacts
.
create!
(
project_id:
project
.
id
,
job_id:
job
.
id
,
file_type:
5
)
}
let!
(
:job_artifact_2
)
{
job_artifacts
.
create!
(
project_id:
project
.
id
,
job_id:
job
.
id
,
file_type:
8
)
}
it
'schedules migration of security scans'
do
Sidekiq
::
Testing
.
fake!
do
...
...
@@ -52,8 +51,8 @@ RSpec.describe ScheduleMigrateSecurityScans, :sidekiq do
end
context
'has non-security job artifacts'
do
let!
(
:job_artifact_1
)
{
job_artifacts
.
create!
(
project_id:
project
.
id
,
job_id:
build
.
id
,
file_type:
4
)
}
let!
(
:job_artifact_2
)
{
job_artifacts
.
create!
(
project_id:
project
.
id
,
job_id:
build
.
id
,
file_type:
9
)
}
let!
(
:job_artifact_1
)
{
job_artifacts
.
create!
(
project_id:
project
.
id
,
job_id:
job
.
id
,
file_type:
4
)
}
let!
(
:job_artifact_2
)
{
job_artifacts
.
create!
(
project_id:
project
.
id
,
job_id:
job
.
id
,
file_type:
9
)
}
it
'schedules migration of security scans'
do
Sidekiq
::
Testing
.
fake!
do
...
...
spec/rubocop/cop/rspec/factories_in_migration_specs_spec.rb
View file @
ab85b805
...
...
@@ -13,7 +13,7 @@ RSpec.describe RuboCop::Cop::RSpec::FactoriesInMigrationSpecs do
subject
(
:cop
)
{
described_class
.
new
}
shared_examples
'an offensive factory call'
do
|
namespace
|
%i[build build_list create create_list]
.
each
do
|
forbidden_method
|
%i[build build_list create create_list
attributes_for
]
.
each
do
|
forbidden_method
|
namespaced_forbidden_method
=
"
#{
namespace
}#{
forbidden_method
}
(:user)"
it
"registers an offense for
#{
namespaced_forbidden_method
}
"
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