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
60ed3271
Commit
60ed3271
authored
May 17, 2021
by
Suraj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed Rails Save Bang offenses in few spec/models/* files
parent
a7608d29
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
19 deletions
+27
-19
.rubocop_manual_todo.yml
.rubocop_manual_todo.yml
+0
-3
spec/models/appearance_spec.rb
spec/models/appearance_spec.rb
+2
-2
spec/models/application_record_spec.rb
spec/models/application_record_spec.rb
+8
-5
spec/models/application_setting_spec.rb
spec/models/application_setting_spec.rb
+17
-9
No files found.
.rubocop_manual_todo.yml
View file @
60ed3271
...
...
@@ -165,9 +165,6 @@ Rails/SaveBang:
-
'
spec/lib/gitlab/middleware/go_spec.rb'
-
'
spec/lib/gitlab/shard_health_cache_spec.rb'
-
'
spec/mailers/notify_spec.rb'
-
'
spec/models/appearance_spec.rb'
-
'
spec/models/application_record_spec.rb'
-
'
spec/models/application_setting_spec.rb'
-
'
spec/models/clusters/applications/helm_spec.rb'
-
'
spec/models/container_repository_spec.rb'
-
'
spec/models/design_management/version_spec.rb'
...
...
spec/models/appearance_spec.rb
View file @
60ed3271
...
...
@@ -15,7 +15,7 @@ RSpec.describe Appearance do
create
(
:appearance
)
new_row
=
build
(
:appearance
)
new_row
.
save
expect
{
new_row
.
save!
}.
to
raise_error
(
ActiveRecord
::
RecordInvalid
,
'Validation failed: Only 1 appearances row can exist'
)
expect
(
new_row
.
valid?
).
to
eq
(
false
)
end
...
...
@@ -39,7 +39,7 @@ RSpec.describe Appearance do
end
it
'returns the path when the upload has been orphaned'
do
appearance
.
send
(
logo_type
).
upload
.
destroy
appearance
.
send
(
logo_type
).
upload
.
destroy
!
appearance
.
reload
expect
(
appearance
.
send
(
"
#{
logo_type
}
_path"
)).
to
eq
(
expected_path
)
...
...
spec/models/application_record_spec.rb
View file @
60ed3271
...
...
@@ -13,20 +13,23 @@ RSpec.describe ApplicationRecord do
describe
'.safe_ensure_unique'
do
let
(
:model
)
{
build
(
:suggestion
)
}
let_it_be
(
:note
)
{
create
(
:diff_note_on_merge_request
)
}
let
(
:klass
)
{
model
.
class
}
before
do
allow
(
model
).
to
receive
(
:save
).
and_raise
(
ActiveRecord
::
RecordNotUnique
)
allow
(
model
).
to
receive
(
:save
!
).
and_raise
(
ActiveRecord
::
RecordNotUnique
)
end
it
'returns false when ActiveRecord::RecordNotUnique is raised'
do
expect
(
model
).
to
receive
(
:save
).
once
expect
(
klass
.
safe_ensure_unique
{
model
.
save
}).
to
be_falsey
expect
(
model
).
to
receive
(
:save!
).
once
model
.
note_id
=
note
.
id
expect
(
klass
.
safe_ensure_unique
{
model
.
save!
}).
to
be_falsey
end
it
'retries based on retry count specified'
do
expect
(
model
).
to
receive
(
:save
).
exactly
(
3
).
times
expect
(
klass
.
safe_ensure_unique
(
retries:
2
)
{
model
.
save
}).
to
be_falsey
expect
(
model
).
to
receive
(
:save!
).
exactly
(
3
).
times
model
.
note_id
=
note
.
id
expect
(
klass
.
safe_ensure_unique
(
retries:
2
)
{
model
.
save!
}).
to
be_falsey
end
end
...
...
spec/models/application_setting_spec.rb
View file @
60ed3271
...
...
@@ -252,7 +252,9 @@ RSpec.describe ApplicationSetting do
context
"when user accepted let's encrypt terms of service"
do
before
do
setting
.
update
(
lets_encrypt_terms_of_service_accepted:
true
)
expect
{
setting
.
update!
(
lets_encrypt_terms_of_service_accepted:
true
)
}.
to
raise_error
(
ActiveRecord
::
RecordInvalid
,
"Validation failed: Lets encrypt notification email can't be blank"
)
end
it
{
is_expected
.
not_to
allow_value
(
nil
).
for
(
:lets_encrypt_notification_email
)
}
...
...
@@ -302,26 +304,30 @@ RSpec.describe ApplicationSetting do
describe
'default_artifacts_expire_in'
do
it
'sets an error if it cannot parse'
do
setting
.
update
(
default_artifacts_expire_in:
'a'
)
expect
{
setting
.
update!
(
default_artifacts_expire_in:
'a'
)
}.
to
raise_error
(
ActiveRecord
::
RecordInvalid
,
"Validation failed: Default artifacts expire in is not a correct duration"
)
expect_invalid
end
it
'sets an error if it is blank'
do
setting
.
update
(
default_artifacts_expire_in:
' '
)
expect
{
setting
.
update!
(
default_artifacts_expire_in:
' '
)
}.
to
raise_error
(
ActiveRecord
::
RecordInvalid
,
"Validation failed: Default artifacts expire in can't be blank"
)
expect_invalid
end
it
'sets the value if it is valid'
do
setting
.
update
(
default_artifacts_expire_in:
'30 days'
)
setting
.
update
!
(
default_artifacts_expire_in:
'30 days'
)
expect
(
setting
).
to
be_valid
expect
(
setting
.
default_artifacts_expire_in
).
to
eq
(
'30 days'
)
end
it
'sets the value if it is 0'
do
setting
.
update
(
default_artifacts_expire_in:
'0'
)
setting
.
update
!
(
default_artifacts_expire_in:
'0'
)
expect
(
setting
).
to
be_valid
expect
(
setting
.
default_artifacts_expire_in
).
to
eq
(
'0'
)
...
...
@@ -400,18 +406,18 @@ RSpec.describe ApplicationSetting do
context
'auto_devops_domain setting'
do
context
'when auto_devops_enabled? is true'
do
before
do
setting
.
update
(
auto_devops_enabled:
true
)
setting
.
update
!
(
auto_devops_enabled:
true
)
end
it
'can be blank'
do
setting
.
update
(
auto_devops_domain:
''
)
setting
.
update
!
(
auto_devops_domain:
''
)
expect
(
setting
).
to
be_valid
end
context
'with a valid value'
do
before
do
setting
.
update
(
auto_devops_domain:
'domain.com'
)
setting
.
update
!
(
auto_devops_domain:
'domain.com'
)
end
it
'is valid'
do
...
...
@@ -421,7 +427,9 @@ RSpec.describe ApplicationSetting do
context
'with an invalid value'
do
before
do
setting
.
update
(
auto_devops_domain:
'definitelynotahostname'
)
expect
{
setting
.
update!
(
auto_devops_domain:
'definitelynotahostname'
)
}.
to
raise_error
(
ActiveRecord
::
RecordInvalid
,
"Validation failed: Auto devops domain is not a fully qualified domain name"
)
end
it
'is invalid'
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