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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
bf0b51d2
Commit
bf0b51d2
authored
Apr 26, 2016
by
Grzegorz Bizon
Committed by
Robert Speicher
May 29, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update note factory to include noteable association
parent
87c44b0e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
15 deletions
+9
-15
spec/factories/notes.rb
spec/factories/notes.rb
+6
-12
spec/models/note_spec.rb
spec/models/note_spec.rb
+3
-3
No files found.
spec/factories/notes.rb
View file @
bf0b51d2
...
@@ -4,13 +4,14 @@ include ActionDispatch::TestProcess
...
@@ -4,13 +4,14 @@ include ActionDispatch::TestProcess
FactoryGirl
.
define
do
FactoryGirl
.
define
do
factory
:note
do
factory
:note
do
project
note
"Note"
note
"Note"
author
author
noteable
{
create
(
:issue
)
}
project
{
noteable
.
project
}
factory
:note_on_issue
,
aliases:
[
:votable_note
]
factory
:note_on_commit
,
traits:
[
:on_commit
]
factory
:note_on_commit
,
traits:
[
:on_commit
]
factory
:note_on_commit_diff
,
traits:
[
:on_commit
,
:on_diff
],
class:
LegacyDiffNote
factory
:note_on_commit_diff
,
traits:
[
:on_commit
,
:on_diff
],
class:
LegacyDiffNote
factory
:note_on_issue
,
traits:
[
:on_issue
],
aliases:
[
:votable_note
]
factory
:note_on_merge_request
,
traits:
[
:on_merge_request
]
factory
:note_on_merge_request
,
traits:
[
:on_merge_request
]
factory
:note_on_merge_request_diff
,
traits:
[
:on_merge_request
,
:on_diff
],
class:
LegacyDiffNote
factory
:note_on_merge_request_diff
,
traits:
[
:on_merge_request
,
:on_diff
],
class:
LegacyDiffNote
factory
:note_on_project_snippet
,
traits:
[
:on_project_snippet
]
factory
:note_on_project_snippet
,
traits:
[
:on_project_snippet
]
...
@@ -20,6 +21,7 @@ FactoryGirl.define do
...
@@ -20,6 +21,7 @@ FactoryGirl.define do
trait
:on_commit
do
trait
:on_commit
do
project
project
noteable
nil
commit_id
RepoHelpers
.
sample_commit
.
id
commit_id
RepoHelpers
.
sample_commit
.
id
noteable_type
"Commit"
noteable_type
"Commit"
end
end
...
@@ -29,19 +31,11 @@ FactoryGirl.define do
...
@@ -29,19 +31,11 @@ FactoryGirl.define do
end
end
trait
:on_merge_request
do
trait
:on_merge_request
do
project
noteable
{
create
(
:merge_request
)
}
noteable_id
1
noteable_type
"MergeRequest"
end
trait
:on_issue
do
noteable_id
1
noteable_type
"Issue"
end
end
trait
:on_project_snippet
do
trait
:on_project_snippet
do
noteable_id
1
noteable
{
create
(
:snippet
)
}
noteable_type
"Snippet"
end
end
trait
:system
do
trait
:system
do
...
...
spec/models/note_spec.rb
View file @
bf0b51d2
...
@@ -89,8 +89,8 @@ describe Note, models: true do
...
@@ -89,8 +89,8 @@ describe Note, models: true do
end
end
describe
"#all_references"
do
describe
"#all_references"
do
let!
(
:note1
)
{
create
(
:note
)
}
let!
(
:note1
)
{
create
(
:note
_on_issue
)
}
let!
(
:note2
)
{
create
(
:note
)
}
let!
(
:note2
)
{
create
(
:note
_on_issue
)
}
it
"reads the rendered note body from the cache"
do
it
"reads the rendered note body from the cache"
do
expect
(
Banzai
::
Renderer
).
to
receive
(
:render
).
with
(
note1
.
note
,
pipeline: :note
,
cache_key:
[
note1
,
"note"
],
project:
note1
.
project
)
expect
(
Banzai
::
Renderer
).
to
receive
(
:render
).
with
(
note1
.
note
,
pipeline: :note
,
cache_key:
[
note1
,
"note"
],
project:
note1
.
project
)
...
@@ -102,7 +102,7 @@ describe Note, models: true do
...
@@ -102,7 +102,7 @@ describe Note, models: true do
end
end
describe
'.search'
do
describe
'.search'
do
let
(
:note
)
{
create
(
:note
,
note:
'WoW'
)
}
let
(
:note
)
{
create
(
:note
_on_issue
,
note:
'WoW'
)
}
it
'returns notes with matching content'
do
it
'returns notes with matching content'
do
expect
(
described_class
.
search
(
note
.
note
)).
to
eq
([
note
])
expect
(
described_class
.
search
(
note
.
note
)).
to
eq
([
note
])
...
...
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