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
25012e7d
Commit
25012e7d
authored
Oct 05, 2020
by
Peter Leitzen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Speed up notes helper spec
parent
3934a31b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
33 deletions
+26
-33
spec/helpers/notes_helper_spec.rb
spec/helpers/notes_helper_spec.rb
+26
-33
No files found.
spec/helpers/notes_helper_spec.rb
View file @
25012e7d
...
...
@@ -5,19 +5,19 @@ require "spec_helper"
RSpec
.
describe
NotesHelper
do
include
RepoHelpers
let
(
:owner
)
{
create
(
:owner
)
}
let
(
:group
)
{
create
(
:group
)
}
let
(
:project
)
{
create
(
:project
,
namespace:
group
)
}
let
(
:maintainer
)
{
create
(
:user
)
}
let
(
:reporter
)
{
create
(
:user
)
}
let
(
:guest
)
{
create
(
:user
)
}
let
(
:owner_note
)
{
create
(
:note
,
author:
owner
,
project:
project
)
}
let
(
:maintainer_note
)
{
create
(
:note
,
author:
maintainer
,
project:
project
)
}
let
(
:reporter_note
)
{
create
(
:note
,
author:
reporter
,
project:
project
)
}
let
_it_be
(
:owner
)
{
create
(
:owner
)
}
let
_it_be
(
:group
)
{
create
(
:group
)
}
let
_it_be
(
:project
)
{
create
(
:project
,
namespace:
group
)
}
let
_it_be
(
:maintainer
)
{
create
(
:user
)
}
let
_it_be
(
:reporter
)
{
create
(
:user
)
}
let
_it_be
(
:guest
)
{
create
(
:user
)
}
let
_it_be
(
:owner_note
)
{
create
(
:note
,
author:
owner
,
project:
project
)
}
let
_it_be
(
:maintainer_note
)
{
create
(
:note
,
author:
maintainer
,
project:
project
)
}
let
_it_be
(
:reporter_note
)
{
create
(
:note
,
author:
reporter
,
project:
project
)
}
let!
(
:notes
)
{
[
owner_note
,
maintainer_note
,
reporter_note
]
}
before
do
before
_all
do
group
.
add_owner
(
owner
)
project
.
add_maintainer
(
maintainer
)
project
.
add_reporter
(
reporter
)
...
...
@@ -72,14 +72,14 @@ RSpec.describe NotesHelper do
end
describe
'#discussion_path'
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
_it_be
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:anchor
)
{
discussion
.
line_code
}
context
'for a merge request discusion'
do
let
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
,
target_project:
project
,
importing:
true
)
}
let
!
(
:merge_request_diff1
)
{
merge_request
.
merge_request_diffs
.
create!
(
head_commit_sha:
'6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9'
)
}
let
!
(
:merge_request_diff2
)
{
merge_request
.
merge_request_diffs
.
create!
(
head_commit_sha:
nil
)
}
let
!
(
:merge_request_diff3
)
{
merge_request
.
merge_request_diffs
.
create!
(
head_commit_sha:
'5937ac0a7beb003549fc5fd26fc247adbce4a52e'
)
}
let
_it_be
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
,
target_project:
project
,
importing:
true
)
}
let
_it_be
(
:merge_request_diff1
)
{
merge_request
.
merge_request_diffs
.
create!
(
head_commit_sha:
'6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9'
)
}
let
_it_be
(
:merge_request_diff2
)
{
merge_request
.
merge_request_diffs
.
create!
(
head_commit_sha:
nil
)
}
let
_it_be
(
:merge_request_diff3
)
{
merge_request
.
merge_request_diffs
.
create!
(
head_commit_sha:
'5937ac0a7beb003549fc5fd26fc247adbce4a52e'
)
}
context
'for a diff discussion'
do
context
'when the discussion is active'
do
...
...
@@ -229,20 +229,18 @@ RSpec.describe NotesHelper do
end
it
'return project notes path for project snippet'
do
namespace
=
create
(
:namespace
,
path:
'nm'
)
@project
=
create
(
:project
,
path:
'test'
,
namespace:
namespace
)
@project
=
project
@snippet
=
create
(
:project_snippet
,
project:
@project
)
@noteable
=
@snippet
expect
(
helper
.
notes_url
).
to
eq
(
"/
nm/test
/noteable/project_snippet/
#{
@noteable
.
id
}
/notes"
)
expect
(
helper
.
notes_url
).
to
eq
(
"/
#{
project
.
full_path
}
/noteable/project_snippet/
#{
@noteable
.
id
}
/notes"
)
end
it
'return project notes path for other noteables'
do
namespace
=
create
(
:namespace
,
path:
'nm'
)
@project
=
create
(
:project
,
path:
'test'
,
namespace:
namespace
)
@project
=
project
@noteable
=
create
(
:issue
,
project:
@project
)
expect
(
helper
.
notes_url
).
to
eq
(
"/
nm/test
/noteable/issue/
#{
@noteable
.
id
}
/notes"
)
expect
(
helper
.
notes_url
).
to
eq
(
"/
#{
@project
.
full_path
}
/noteable/issue/
#{
@noteable
.
id
}
/notes"
)
end
end
...
...
@@ -254,19 +252,17 @@ RSpec.describe NotesHelper do
end
it
'return project notes path for project snippet'
do
namespace
=
create
(
:namespace
,
path:
'nm'
)
@project
=
create
(
:project
,
path:
'test'
,
namespace:
namespace
)
@project
=
project
note
=
create
(
:note_on_project_snippet
,
project:
@project
)
expect
(
helper
.
note_url
(
note
)).
to
eq
(
"/
nm/test
/notes/
#{
note
.
id
}
"
)
expect
(
helper
.
note_url
(
note
)).
to
eq
(
"/
#{
project
.
full_path
}
/notes/
#{
note
.
id
}
"
)
end
it
'return project notes path for other noteables'
do
namespace
=
create
(
:namespace
,
path:
'nm'
)
@project
=
create
(
:project
,
path:
'test'
,
namespace:
namespace
)
@project
=
project
note
=
create
(
:note_on_issue
,
project:
@project
)
expect
(
helper
.
note_url
(
note
)).
to
eq
(
"/
nm/test
/notes/
#{
note
.
id
}
"
)
expect
(
helper
.
note_url
(
note
)).
to
eq
(
"/
#{
project
.
full_path
}
/notes/
#{
note
.
id
}
"
)
end
end
...
...
@@ -279,8 +275,7 @@ RSpec.describe NotesHelper do
end
it
'returns namespace, project and note for project snippet'
do
namespace
=
create
(
:namespace
,
path:
'nm'
)
@project
=
create
(
:project
,
path:
'test'
,
namespace:
namespace
)
@project
=
project
@snippet
=
create
(
:project_snippet
,
project:
@project
)
@note
=
create
(
:note_on_personal_snippet
)
...
...
@@ -288,8 +283,7 @@ RSpec.describe NotesHelper do
end
it
'returns namespace, project and note path for other noteables'
do
namespace
=
create
(
:namespace
,
path:
'nm'
)
@project
=
create
(
:project
,
path:
'test'
,
namespace:
namespace
)
@project
=
project
@note
=
create
(
:note_on_issue
,
project:
@project
)
expect
(
helper
.
form_resources
).
to
eq
([
@project
,
@note
])
...
...
@@ -297,7 +291,6 @@ RSpec.describe NotesHelper do
end
describe
'#noteable_note_url'
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:issue
)
{
create
(
:issue
,
project:
project
)
}
let
(
:note
)
{
create
(
:note_on_issue
,
noteable:
issue
,
project:
project
)
}
...
...
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