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
c3a54560
Commit
c3a54560
authored
Mar 24, 2022
by
Peter Leitzen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use let_it_be and non_existing_record_id in FinderMethods specs
parent
cbe50977
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
8 deletions
+9
-8
spec/finders/concerns/finder_methods_spec.rb
spec/finders/concerns/finder_methods_spec.rb
+9
-8
No files found.
spec/finders/concerns/finder_methods_spec.rb
View file @
c3a54560
...
@@ -21,12 +21,13 @@ RSpec.describe FinderMethods do
...
@@ -21,12 +21,13 @@ RSpec.describe FinderMethods do
end
end
end
end
let
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:user
)
{
create
(
:user
)
}
let
(
:finder
)
{
finder_class
.
new
(
user
)
}
let_it_be
(
:authorized_project
)
{
create
(
:project
)
}
let
(
:authorized_project
)
{
create
(
:project
)
}
let_it_be
(
:unauthorized_project
)
{
create
(
:project
)
}
let
(
:unauthorized_project
)
{
create
(
:project
)
}
before
do
subject
(
:finder
)
{
finder_class
.
new
(
user
)
}
before_all
do
authorized_project
.
add_developer
(
user
)
authorized_project
.
add_developer
(
user
)
end
end
...
@@ -37,7 +38,7 @@ RSpec.describe FinderMethods do
...
@@ -37,7 +38,7 @@ RSpec.describe FinderMethods do
end
end
it
'raises not found when the project is not found'
do
it
'raises not found when the project is not found'
do
expect
{
finder
.
find_by!
(
id:
0
)
}.
to
raise_error
(
ActiveRecord
::
RecordNotFound
)
expect
{
finder
.
find_by!
(
id:
non_existing_record_id
)
}.
to
raise_error
(
ActiveRecord
::
RecordNotFound
)
end
end
it
'raises not found the user does not have access'
do
it
'raises not found the user does not have access'
do
...
@@ -62,7 +63,7 @@ RSpec.describe FinderMethods do
...
@@ -62,7 +63,7 @@ RSpec.describe FinderMethods do
end
end
it
'raises not found when the project is not found'
do
it
'raises not found when the project is not found'
do
expect
{
finder
.
find
(
0
)
}.
to
raise_error
(
ActiveRecord
::
RecordNotFound
)
expect
{
finder
.
find
(
non_existing_record_id
)
}.
to
raise_error
(
ActiveRecord
::
RecordNotFound
)
end
end
it
'raises not found the user does not have access'
do
it
'raises not found the user does not have access'
do
...
@@ -76,7 +77,7 @@ RSpec.describe FinderMethods do
...
@@ -76,7 +77,7 @@ RSpec.describe FinderMethods do
end
end
it
'returns nil when the project is not found'
do
it
'returns nil when the project is not found'
do
expect
(
finder
.
find_by
(
id:
0
)).
to
be_nil
expect
(
finder
.
find_by
(
id:
non_existing_record_id
)).
to
be_nil
end
end
it
'returns nil when the user does not have access'
do
it
'returns nil when the user does not have access'
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