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 @@
Rails/SaveBang
:
Exclude
:
-
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/repository_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
it
"doesn't call the update lifetime service"
do
expect
(
::
PersonalAccessTokens
::
Instance
::
UpdateLifetimeService
).
not_to
receive
(
:new
)
setting
.
save
setting
.
save
!
end
end
...
...
@@ -770,7 +770,7 @@ RSpec.describe ApplicationSetting do
expect
(
service
).
to
receive
(
:execute
)
end
setting
.
save
setting
.
save
!
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
expect
(
rule
).
not_to
be_valid
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
...
...
@@ -264,7 +264,7 @@ RSpec.describe ApprovalMergeRequestRule, factory_default: :keep do
context
'when project merge_requests_author_approval is true'
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
)
end
...
...
@@ -272,7 +272,7 @@ RSpec.describe ApprovalMergeRequestRule, factory_default: :keep do
context
'when project merge_requests_author_approval is false'
do
before
do
merge_request
.
project
.
update
(
merge_requests_author_approval:
false
)
merge_request
.
project
.
update
!
(
merge_requests_author_approval:
false
)
end
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
expect
(
rule
).
not_to
be_valid
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
...
...
@@ -273,28 +273,28 @@ RSpec.describe ApprovalProjectRule do
end
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'
}
it_behaves_like
'auditable'
end
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'
}
it_behaves_like
'auditable'
end
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'
}
it_behaves_like
'auditable'
end
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'
}
it_behaves_like
'auditable'
...
...
ee/spec/models/burndown_spec.rb
View file @
67db38fc
...
...
@@ -39,7 +39,7 @@ RSpec.describe Burndown do
let_it_be
(
:non_member
)
{
create
(
:user
)
}
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
}
end
...
...
@@ -57,13 +57,13 @@ RSpec.describe Burndown do
end
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
([])
end
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
([])
end
...
...
ee/spec/models/elasticsearch_indexed_namespace_spec.rb
View file @
67db38fc
...
...
@@ -37,7 +37,7 @@ RSpec.describe ElasticsearchIndexedNamespace, :saas do
context
'with plans'
do
Plan
::
PAID_HOSTED_PLANS
.
each
do
|
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
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
using
RSpec
::
Parameterized
::
TableSyntax
%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
describe
'default values'
,
:freeze_time
do
...
...
ee/spec/models/issue_spec.rb
View file @
67db38fc
...
...
@@ -546,7 +546,7 @@ RSpec.describe Issue do
award_emoji
=
create
(
:award_emoji
,
:upvote
,
awardable:
issue
)
award_emoji
.
destroy
award_emoji
.
destroy
!
end
end
end
...
...
@@ -620,7 +620,7 @@ RSpec.describe Issue do
end
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
)
[
issue
,
issue1
].
each
(
&
:reset
)
...
...
@@ -630,7 +630,7 @@ RSpec.describe Issue do
end
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
)
[
issue
,
issue1
].
each
(
&
:reset
)
...
...
@@ -640,8 +640,8 @@ RSpec.describe Issue do
end
it
'positions issue in the middle of other two if distance is big enough'
do
issue
.
update
relative_position:
6000
issue1
.
update
relative_position:
10000
issue
.
update
!
relative_position:
6000
issue1
.
update
!
relative_position:
10000
new_issue
.
move_between
(
issue
,
issue1
)
...
...
@@ -662,8 +662,8 @@ RSpec.describe Issue do
end
it
'positions issue in the middle of other two if distance is not big enough'
do
issue
.
update
relative_position:
100
issue1
.
update
relative_position:
400
issue
.
update
!
relative_position:
100
issue1
.
update
!
relative_position:
400
new_issue
.
move_between
(
issue
,
issue1
)
...
...
@@ -671,8 +671,8 @@ RSpec.describe Issue do
end
it
'positions issue in the middle of other two is there is no place'
do
issue
.
update
relative_position:
100
issue1
.
update
relative_position:
101
issue
.
update
!
relative_position:
100
issue1
.
update
!
relative_position:
101
new_issue
.
move_between
(
issue
,
issue1
)
[
issue
,
issue1
].
each
(
&
:reset
)
...
...
@@ -682,10 +682,10 @@ RSpec.describe Issue do
end
it
'uses rebalancing if there is no place'
do
issue
.
update
relative_position:
100
issue1
.
update
relative_position:
101
issue
.
update
!
relative_position:
100
issue1
.
update
!
relative_position:
101
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
.
save!
...
...
@@ -698,10 +698,10 @@ RSpec.describe Issue do
end
it
'positions issue right if we pass non-sequential parameters'
do
issue
.
update
relative_position:
99
issue1
.
update
relative_position:
101
issue
.
update
!
relative_position:
99
issue1
.
update
!
relative_position:
101
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
.
save!
...
...
@@ -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_3
,
link_type:
IssueLink
::
TYPE_BLOCKS
)
# 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!
}
.
to
change
{
issue
.
blocking_issues_count
}.
from
(
0
).
to
(
3
)
...
...
@@ -871,7 +871,7 @@ RSpec.describe Issue do
end
before
do
blocked_issue
.
update
(
blocking_issues_count:
0
)
blocked_issue
.
update
!
(
blocking_issues_count:
0
)
end
context
'when blocked issue is closed'
do
...
...
@@ -887,9 +887,9 @@ RSpec.describe Issue do
context
'when blocked issue is reopened'
do
before
do
blocked_issue
.
close
blocked_issue
.
update
(
blocking_issues_count:
0
)
blocking_issue1
.
update
(
blocking_issues_count:
0
)
blocking_issue2
.
update
(
blocking_issues_count:
0
)
blocked_issue
.
update
!
(
blocking_issues_count:
0
)
blocking_issue1
.
update
!
(
blocking_issues_count:
0
)
blocking_issue2
.
update
!
(
blocking_issues_count:
0
)
end
it
'updates blocking and blocked issues cache'
do
...
...
@@ -1021,7 +1021,7 @@ RSpec.describe Issue do
before
do
stub_licensed_features
(
incident_sla:
license_available
)
issue_type
=
incident_type
?
'incident'
:
'issue'
issue
.
update
(
issue_type:
issue_type
)
issue
.
update
!
(
issue_type:
issue_type
)
end
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