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
67db38fc
Commit
67db38fc
authored
Dec 04, 2021
by
Siddharth Asthana
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Rails/SaveBang offenses
Changelog: other EE: true
parent
c7673c25
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
36 additions
and
43 deletions
+36
-43
.rubocop_todo/rails/save_bang.yml
.rubocop_todo/rails/save_bang.yml
+0
-7
ee/spec/models/application_setting_spec.rb
ee/spec/models/application_setting_spec.rb
+2
-2
ee/spec/models/approval_merge_request_rule_spec.rb
ee/spec/models/approval_merge_request_rule_spec.rb
+3
-3
ee/spec/models/approval_project_rule_spec.rb
ee/spec/models/approval_project_rule_spec.rb
+5
-5
ee/spec/models/burndown_spec.rb
ee/spec/models/burndown_spec.rb
+3
-3
ee/spec/models/elasticsearch_indexed_namespace_spec.rb
ee/spec/models/elasticsearch_indexed_namespace_spec.rb
+1
-1
ee/spec/models/gitlab_subscription_spec.rb
ee/spec/models/gitlab_subscription_spec.rb
+1
-1
ee/spec/models/issue_spec.rb
ee/spec/models/issue_spec.rb
+21
-21
No files found.
.rubocop_todo/rails/save_bang.yml
View file @
67db38fc
...
@@ -2,13 +2,6 @@
...
@@ -2,13 +2,6 @@
Rails/SaveBang
:
Rails/SaveBang
:
Exclude
:
Exclude
:
-
ee/spec/lib/analytics/merge_request_metrics_calculator_spec.rb
-
ee/spec/lib/analytics/merge_request_metrics_calculator_spec.rb
-
ee/spec/models/application_setting_spec.rb
-
ee/spec/models/approval_merge_request_rule_spec.rb
-
ee/spec/models/approval_project_rule_spec.rb
-
ee/spec/models/burndown_spec.rb
-
ee/spec/models/elasticsearch_indexed_namespace_spec.rb
-
ee/spec/models/gitlab_subscription_spec.rb
-
ee/spec/models/issue_spec.rb
-
ee/spec/models/protected_environment_spec.rb
-
ee/spec/models/protected_environment_spec.rb
-
ee/spec/models/repository_spec.rb
-
ee/spec/models/repository_spec.rb
-
ee/spec/models/scim_identity_spec.rb
-
ee/spec/models/scim_identity_spec.rb
...
...
ee/spec/models/application_setting_spec.rb
View file @
67db38fc
...
@@ -755,7 +755,7 @@ RSpec.describe ApplicationSetting do
...
@@ -755,7 +755,7 @@ RSpec.describe ApplicationSetting do
it
"doesn't call the update lifetime service"
do
it
"doesn't call the update lifetime service"
do
expect
(
::
PersonalAccessTokens
::
Instance
::
UpdateLifetimeService
).
not_to
receive
(
:new
)
expect
(
::
PersonalAccessTokens
::
Instance
::
UpdateLifetimeService
).
not_to
receive
(
:new
)
setting
.
save
setting
.
save
!
end
end
end
end
...
@@ -770,7 +770,7 @@ RSpec.describe ApplicationSetting do
...
@@ -770,7 +770,7 @@ RSpec.describe ApplicationSetting do
expect
(
service
).
to
receive
(
:execute
)
expect
(
service
).
to
receive
(
:execute
)
end
end
setting
.
save
setting
.
save
!
end
end
end
end
end
end
...
...
ee/spec/models/approval_merge_request_rule_spec.rb
View file @
67db38fc
...
@@ -78,7 +78,7 @@ RSpec.describe ApprovalMergeRequestRule, factory_default: :keep do
...
@@ -78,7 +78,7 @@ RSpec.describe ApprovalMergeRequestRule, factory_default: :keep do
expect
(
rule
).
not_to
be_valid
expect
(
rule
).
not_to
be_valid
expect
(
rule
.
errors
.
messages
).
to
eq
(
rule_type:
[
'any-approver for the merge request already exists'
])
expect
(
rule
.
errors
.
messages
).
to
eq
(
rule_type:
[
'any-approver for the merge request already exists'
])
expect
{
rule
.
save
(
validate:
false
)
}.
to
raise_error
(
ActiveRecord
::
RecordNotUnique
)
expect
{
rule
.
save
!
(
validate:
false
)
}.
to
raise_error
(
ActiveRecord
::
RecordNotUnique
)
end
end
end
end
end
end
...
@@ -264,7 +264,7 @@ RSpec.describe ApprovalMergeRequestRule, factory_default: :keep do
...
@@ -264,7 +264,7 @@ RSpec.describe ApprovalMergeRequestRule, factory_default: :keep do
context
'when project merge_requests_author_approval is true'
do
context
'when project merge_requests_author_approval is true'
do
it
'contains author'
do
it
'contains author'
do
merge_request
.
project
.
update
(
merge_requests_author_approval:
true
)
merge_request
.
project
.
update
!
(
merge_requests_author_approval:
true
)
expect
(
subject
.
approvers
).
to
contain_exactly
(
merge_request
.
author
)
expect
(
subject
.
approvers
).
to
contain_exactly
(
merge_request
.
author
)
end
end
...
@@ -272,7 +272,7 @@ RSpec.describe ApprovalMergeRequestRule, factory_default: :keep do
...
@@ -272,7 +272,7 @@ RSpec.describe ApprovalMergeRequestRule, factory_default: :keep do
context
'when project merge_requests_author_approval is false'
do
context
'when project merge_requests_author_approval is false'
do
before
do
before
do
merge_request
.
project
.
update
(
merge_requests_author_approval:
false
)
merge_request
.
project
.
update
!
(
merge_requests_author_approval:
false
)
end
end
it
'does not contain author'
do
it
'does not contain author'
do
...
...
ee/spec/models/approval_project_rule_spec.rb
View file @
67db38fc
...
@@ -233,7 +233,7 @@ RSpec.describe ApprovalProjectRule do
...
@@ -233,7 +233,7 @@ RSpec.describe ApprovalProjectRule do
expect
(
rule
).
not_to
be_valid
expect
(
rule
).
not_to
be_valid
expect
(
rule
.
errors
.
messages
).
to
eq
(
rule_type:
[
'any-approver for the project already exists'
])
expect
(
rule
.
errors
.
messages
).
to
eq
(
rule_type:
[
'any-approver for the project already exists'
])
expect
{
rule
.
save
(
validate:
false
)
}.
to
raise_error
(
ActiveRecord
::
RecordNotUnique
)
expect
{
rule
.
save
!
(
validate:
false
)
}.
to
raise_error
(
ActiveRecord
::
RecordNotUnique
)
end
end
end
end
...
@@ -273,28 +273,28 @@ RSpec.describe ApprovalProjectRule do
...
@@ -273,28 +273,28 @@ RSpec.describe ApprovalProjectRule do
end
end
describe
'#audit_add users after :add'
do
describe
'#audit_add users after :add'
do
let
(
:action!
)
{
rule
.
update
(
users:
[
user
,
new_user
])
}
let
(
:action!
)
{
rule
.
update
!
(
users:
[
user
,
new_user
])
}
let
(
:message
)
{
'Added User Spiderman to approval group on Vulnerability rule'
}
let
(
:message
)
{
'Added User Spiderman to approval group on Vulnerability rule'
}
it_behaves_like
'auditable'
it_behaves_like
'auditable'
end
end
describe
'#audit_remove users after :remove'
do
describe
'#audit_remove users after :remove'
do
let
(
:action!
)
{
rule
.
update
(
users:
[])
}
let
(
:action!
)
{
rule
.
update
!
(
users:
[])
}
let
(
:message
)
{
'Removed User Batman from approval group on Vulnerability rule'
}
let
(
:message
)
{
'Removed User Batman from approval group on Vulnerability rule'
}
it_behaves_like
'auditable'
it_behaves_like
'auditable'
end
end
describe
'#audit_add groups after :add'
do
describe
'#audit_add groups after :add'
do
let
(
:action!
)
{
rule
.
update
(
groups:
[
group
,
new_group
])
}
let
(
:action!
)
{
rule
.
update
!
(
groups:
[
group
,
new_group
])
}
let
(
:message
)
{
'Added Group Avengers to approval group on Vulnerability rule'
}
let
(
:message
)
{
'Added Group Avengers to approval group on Vulnerability rule'
}
it_behaves_like
'auditable'
it_behaves_like
'auditable'
end
end
describe
'#audit_remove groups after :remove'
do
describe
'#audit_remove groups after :remove'
do
let
(
:action!
)
{
rule
.
update
(
groups:
[])
}
let
(
:action!
)
{
rule
.
update
!
(
groups:
[])
}
let
(
:message
)
{
'Removed Group Justice League from approval group on Vulnerability rule'
}
let
(
:message
)
{
'Removed Group Justice League from approval group on Vulnerability rule'
}
it_behaves_like
'auditable'
it_behaves_like
'auditable'
...
...
ee/spec/models/burndown_spec.rb
View file @
67db38fc
...
@@ -39,7 +39,7 @@ RSpec.describe Burndown do
...
@@ -39,7 +39,7 @@ RSpec.describe Burndown do
let_it_be
(
:non_member
)
{
create
(
:user
)
}
let_it_be
(
:non_member
)
{
create
(
:user
)
}
subject
do
subject
do
project
.
update
(
visibility_level:
Gitlab
::
VisibilityLevel
::
PUBLIC
)
project
.
update
!
(
visibility_level:
Gitlab
::
VisibilityLevel
::
PUBLIC
)
described_class
.
new
(
milestone
.
issues_visible_to_user
(
non_member
),
milestone
.
start_date
,
milestone
.
due_date
).
as_json
.
each
{
|
event
|
event
[
:created_at
]
=
event
[
:created_at
].
to_date
}
described_class
.
new
(
milestone
.
issues_visible_to_user
(
non_member
),
milestone
.
start_date
,
milestone
.
due_date
).
as_json
.
each
{
|
event
|
event
[
:created_at
]
=
event
[
:created_at
].
to_date
}
end
end
...
@@ -57,13 +57,13 @@ RSpec.describe Burndown do
...
@@ -57,13 +57,13 @@ RSpec.describe Burndown do
end
end
it
"returns empty array if milestone start date is nil"
do
it
"returns empty array if milestone start date is nil"
do
milestone
.
update
(
start_date:
nil
)
milestone
.
update
!
(
start_date:
nil
)
expect
(
subject
).
to
eq
([])
expect
(
subject
).
to
eq
([])
end
end
it
"returns empty array if milestone due date is nil"
do
it
"returns empty array if milestone due date is nil"
do
milestone
.
update
(
due_date:
nil
)
milestone
.
update
!
(
due_date:
nil
)
expect
(
subject
).
to
eq
([])
expect
(
subject
).
to
eq
([])
end
end
...
...
ee/spec/models/elasticsearch_indexed_namespace_spec.rb
View file @
67db38fc
...
@@ -37,7 +37,7 @@ RSpec.describe ElasticsearchIndexedNamespace, :saas do
...
@@ -37,7 +37,7 @@ RSpec.describe ElasticsearchIndexedNamespace, :saas do
context
'with plans'
do
context
'with plans'
do
Plan
::
PAID_HOSTED_PLANS
.
each
do
|
plan
|
Plan
::
PAID_HOSTED_PLANS
.
each
do
|
plan
|
plan_factory
=
"
#{
plan
}
_plan"
plan_factory
=
"
#{
plan
}
_plan"
let_it_be
(
plan_factory
)
{
create
(
plan_factory
)
}
let_it_be
(
plan_factory
)
{
create
(
plan_factory
)
}
# rubocop:disable Rails/SaveBang
end
end
let_it_be
(
:namespaces
)
{
create_list
(
:namespace
,
3
)
}
let_it_be
(
:namespaces
)
{
create_list
(
:namespace
,
3
)
}
...
...
ee/spec/models/gitlab_subscription_spec.rb
View file @
67db38fc
...
@@ -6,7 +6,7 @@ RSpec.describe GitlabSubscription, :saas do
...
@@ -6,7 +6,7 @@ RSpec.describe GitlabSubscription, :saas do
using
RSpec
::
Parameterized
::
TableSyntax
using
RSpec
::
Parameterized
::
TableSyntax
%i[free_plan bronze_plan premium_plan ultimate_plan]
.
each
do
|
plan
|
%i[free_plan bronze_plan premium_plan ultimate_plan]
.
each
do
|
plan
|
let_it_be
(
plan
)
{
create
(
plan
)
}
let_it_be
(
plan
)
{
create
(
plan
)
}
# rubocop:disable Rails/SaveBang
end
end
describe
'default values'
,
:freeze_time
do
describe
'default values'
,
:freeze_time
do
...
...
ee/spec/models/issue_spec.rb
View file @
67db38fc
...
@@ -546,7 +546,7 @@ RSpec.describe Issue do
...
@@ -546,7 +546,7 @@ RSpec.describe Issue do
award_emoji
=
create
(
:award_emoji
,
:upvote
,
awardable:
issue
)
award_emoji
=
create
(
:award_emoji
,
:upvote
,
awardable:
issue
)
award_emoji
.
destroy
award_emoji
.
destroy
!
end
end
end
end
end
end
...
@@ -620,7 +620,7 @@ RSpec.describe Issue do
...
@@ -620,7 +620,7 @@ RSpec.describe Issue do
end
end
it
'positions issues even when after and before positions are the same'
do
it
'positions issues even when after and before positions are the same'
do
issue1
.
update
relative_position:
issue
.
relative_position
issue1
.
update
!
relative_position:
issue
.
relative_position
new_issue
.
move_between
(
issue
,
issue1
)
new_issue
.
move_between
(
issue
,
issue1
)
[
issue
,
issue1
].
each
(
&
:reset
)
[
issue
,
issue1
].
each
(
&
:reset
)
...
@@ -630,7 +630,7 @@ RSpec.describe Issue do
...
@@ -630,7 +630,7 @@ RSpec.describe Issue do
end
end
it
'positions issues between other two if distance is 1'
do
it
'positions issues between other two if distance is 1'
do
issue1
.
update
relative_position:
issue
.
relative_position
+
1
issue1
.
update
!
relative_position:
issue
.
relative_position
+
1
new_issue
.
move_between
(
issue
,
issue1
)
new_issue
.
move_between
(
issue
,
issue1
)
[
issue
,
issue1
].
each
(
&
:reset
)
[
issue
,
issue1
].
each
(
&
:reset
)
...
@@ -640,8 +640,8 @@ RSpec.describe Issue do
...
@@ -640,8 +640,8 @@ RSpec.describe Issue do
end
end
it
'positions issue in the middle of other two if distance is big enough'
do
it
'positions issue in the middle of other two if distance is big enough'
do
issue
.
update
relative_position:
6000
issue
.
update
!
relative_position:
6000
issue1
.
update
relative_position:
10000
issue1
.
update
!
relative_position:
10000
new_issue
.
move_between
(
issue
,
issue1
)
new_issue
.
move_between
(
issue
,
issue1
)
...
@@ -662,8 +662,8 @@ RSpec.describe Issue do
...
@@ -662,8 +662,8 @@ RSpec.describe Issue do
end
end
it
'positions issue in the middle of other two if distance is not big enough'
do
it
'positions issue in the middle of other two if distance is not big enough'
do
issue
.
update
relative_position:
100
issue
.
update
!
relative_position:
100
issue1
.
update
relative_position:
400
issue1
.
update
!
relative_position:
400
new_issue
.
move_between
(
issue
,
issue1
)
new_issue
.
move_between
(
issue
,
issue1
)
...
@@ -671,8 +671,8 @@ RSpec.describe Issue do
...
@@ -671,8 +671,8 @@ RSpec.describe Issue do
end
end
it
'positions issue in the middle of other two is there is no place'
do
it
'positions issue in the middle of other two is there is no place'
do
issue
.
update
relative_position:
100
issue
.
update
!
relative_position:
100
issue1
.
update
relative_position:
101
issue1
.
update
!
relative_position:
101
new_issue
.
move_between
(
issue
,
issue1
)
new_issue
.
move_between
(
issue
,
issue1
)
[
issue
,
issue1
].
each
(
&
:reset
)
[
issue
,
issue1
].
each
(
&
:reset
)
...
@@ -682,10 +682,10 @@ RSpec.describe Issue do
...
@@ -682,10 +682,10 @@ RSpec.describe Issue do
end
end
it
'uses rebalancing if there is no place'
do
it
'uses rebalancing if there is no place'
do
issue
.
update
relative_position:
100
issue
.
update
!
relative_position:
100
issue1
.
update
relative_position:
101
issue1
.
update
!
relative_position:
101
issue2
=
create
(
:issue
,
relative_position:
102
,
project:
project
)
issue2
=
create
(
:issue
,
relative_position:
102
,
project:
project
)
new_issue
.
update
relative_position:
103
new_issue
.
update
!
relative_position:
103
new_issue
.
move_between
(
issue1
,
issue2
)
new_issue
.
move_between
(
issue1
,
issue2
)
new_issue
.
save!
new_issue
.
save!
...
@@ -698,10 +698,10 @@ RSpec.describe Issue do
...
@@ -698,10 +698,10 @@ RSpec.describe Issue do
end
end
it
'positions issue right if we pass non-sequential parameters'
do
it
'positions issue right if we pass non-sequential parameters'
do
issue
.
update
relative_position:
99
issue
.
update
!
relative_position:
99
issue1
.
update
relative_position:
101
issue1
.
update
!
relative_position:
101
issue2
=
create
(
:issue
,
relative_position:
102
,
project:
project
)
issue2
=
create
(
:issue
,
relative_position:
102
,
project:
project
)
new_issue
.
update
relative_position:
103
new_issue
.
update
!
relative_position:
103
new_issue
.
move_between
(
issue
,
issue2
)
new_issue
.
move_between
(
issue
,
issue2
)
new_issue
.
save!
new_issue
.
save!
...
@@ -849,7 +849,7 @@ RSpec.describe Issue do
...
@@ -849,7 +849,7 @@ RSpec.describe Issue do
create
(
:issue_link
,
source:
issue
,
target:
blocked_issue_2
,
link_type:
IssueLink
::
TYPE_BLOCKS
)
create
(
:issue_link
,
source:
issue
,
target:
blocked_issue_2
,
link_type:
IssueLink
::
TYPE_BLOCKS
)
create
(
:issue_link
,
source:
issue
,
target:
blocked_issue_3
,
link_type:
IssueLink
::
TYPE_BLOCKS
)
create
(
:issue_link
,
source:
issue
,
target:
blocked_issue_3
,
link_type:
IssueLink
::
TYPE_BLOCKS
)
# Set to 0 for proper testing, this is being set by IssueLink callbacks.
# Set to 0 for proper testing, this is being set by IssueLink callbacks.
issue
.
update
(
blocking_issues_count:
0
)
issue
.
update
!
(
blocking_issues_count:
0
)
expect
{
issue
.
update_blocking_issues_count!
}
expect
{
issue
.
update_blocking_issues_count!
}
.
to
change
{
issue
.
blocking_issues_count
}.
from
(
0
).
to
(
3
)
.
to
change
{
issue
.
blocking_issues_count
}.
from
(
0
).
to
(
3
)
...
@@ -871,7 +871,7 @@ RSpec.describe Issue do
...
@@ -871,7 +871,7 @@ RSpec.describe Issue do
end
end
before
do
before
do
blocked_issue
.
update
(
blocking_issues_count:
0
)
blocked_issue
.
update
!
(
blocking_issues_count:
0
)
end
end
context
'when blocked issue is closed'
do
context
'when blocked issue is closed'
do
...
@@ -887,9 +887,9 @@ RSpec.describe Issue do
...
@@ -887,9 +887,9 @@ RSpec.describe Issue do
context
'when blocked issue is reopened'
do
context
'when blocked issue is reopened'
do
before
do
before
do
blocked_issue
.
close
blocked_issue
.
close
blocked_issue
.
update
(
blocking_issues_count:
0
)
blocked_issue
.
update
!
(
blocking_issues_count:
0
)
blocking_issue1
.
update
(
blocking_issues_count:
0
)
blocking_issue1
.
update
!
(
blocking_issues_count:
0
)
blocking_issue2
.
update
(
blocking_issues_count:
0
)
blocking_issue2
.
update
!
(
blocking_issues_count:
0
)
end
end
it
'updates blocking and blocked issues cache'
do
it
'updates blocking and blocked issues cache'
do
...
@@ -1021,7 +1021,7 @@ RSpec.describe Issue do
...
@@ -1021,7 +1021,7 @@ RSpec.describe Issue do
before
do
before
do
stub_licensed_features
(
incident_sla:
license_available
)
stub_licensed_features
(
incident_sla:
license_available
)
issue_type
=
incident_type
?
'incident'
:
'issue'
issue_type
=
incident_type
?
'incident'
:
'issue'
issue
.
update
(
issue_type:
issue_type
)
issue
.
update
!
(
issue_type:
issue_type
)
end
end
it
'returns the expected value'
do
it
'returns the expected value'
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