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
fc57d360
Commit
fc57d360
authored
May 04, 2016
by
Grzegorz Bizon
Committed by
Robert Speicher
May 29, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor changes in note validation specs
parent
99ef3a84
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
19 deletions
+22
-19
spec/factories/notes.rb
spec/factories/notes.rb
+12
-10
spec/models/concerns/issuable_spec.rb
spec/models/concerns/issuable_spec.rb
+4
-2
spec/models/merge_request_spec.rb
spec/models/merge_request_spec.rb
+0
-2
spec/models/note_spec.rb
spec/models/note_spec.rb
+6
-5
No files found.
spec/factories/notes.rb
View file @
fc57d360
...
...
@@ -9,9 +9,9 @@ FactoryGirl.define do
author
noteable
{
create
(
:issue
,
project:
project
)
}
factory
:note_on_issue
,
traits:
[
:on_issue
],
aliases:
[
:votable_note
]
factory
:note_on_commit
,
traits:
[
:on_commit
]
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_diff
,
traits:
[
:on_merge_request
,
:on_diff
],
class:
LegacyDiffNote
factory
:note_on_project_snippet
,
traits:
[
:on_project_snippet
]
...
...
@@ -19,14 +19,20 @@ FactoryGirl.define do
factory
:downvote_note
,
traits:
[
:award
,
:downvote
]
factory
:upvote_note
,
traits:
[
:award
,
:upvote
]
trait
:on_issue
do
noteable_type
'Issue'
end
trait
:on_commit
do
noteable
nil
noteable_type
'Commit'
noteable_id
nil
commit_id
RepoHelpers
.
sample_commit
.
id
noteable_type
"Commit"
end
trait
:on_diff
do
line_code
"0_184_184"
end
trait
:on_issue
do
noteable_type
'Issue'
noteable
{
create
(
:issue
,
project:
project
)
}
end
trait
:on_merge_request
do
...
...
@@ -42,10 +48,6 @@ FactoryGirl.define do
noteable
{
create
(
:snippet
,
project:
project
)
}
end
trait
:on_diff
do
line_code
"0_184_184"
end
trait
:system
do
system
true
end
...
...
spec/models/concerns/issuable_spec.rb
View file @
fc57d360
...
...
@@ -228,9 +228,11 @@ describe Issue, "Issuable" do
end
describe
"votes"
do
let
(
:project
)
{
issue
.
project
}
before
do
issue
.
notes
.
awards
.
create!
(
note:
"thumbsup"
,
author:
user
,
project:
issue
.
project
)
issue
.
notes
.
awards
.
create!
(
note:
"thumbsdown"
,
author:
user
,
project:
issue
.
project
)
issue
.
notes
.
awards
.
create!
(
note:
"thumbsup"
,
author:
user
,
project:
project
)
issue
.
notes
.
awards
.
create!
(
note:
"thumbsdown"
,
author:
user
,
project:
project
)
end
it
"returns correct values"
do
...
...
spec/models/merge_request_spec.rb
View file @
fc57d360
...
...
@@ -120,7 +120,6 @@ describe MergeRequest, models: true do
before
do
allow
(
merge_request
).
to
receive
(
:commits
)
{
[
merge_request
.
source_project
.
repository
.
commit
]
}
create
(
:note_on_commit
,
commit_id:
merge_request
.
commits
.
first
.
id
,
noteable_type:
'Commit'
,
project:
merge_request
.
project
)
create
(
:note
,
noteable:
merge_request
,
project:
merge_request
.
project
)
end
...
...
@@ -132,7 +131,6 @@ describe MergeRequest, models: true do
it
"should include notes for commits from target project as well"
do
create
(
:note_on_commit
,
commit_id:
merge_request
.
commits
.
first
.
id
,
noteable_type:
'Commit'
,
project:
merge_request
.
target_project
)
expect
(
merge_request
.
commits
).
not_to
be_empty
...
...
spec/models/note_spec.rb
View file @
fc57d360
...
...
@@ -13,29 +13,30 @@ describe Note, models: true do
it
{
is_expected
.
to
validate_presence_of
(
:note
)
}
it
{
is_expected
.
to
validate_presence_of
(
:project
)
}
context
'when note is
comment
on commit'
do
context
'when note is on commit'
do
before
{
allow
(
subject
).
to
receive
(
:for_commit?
).
and_return
(
true
)
}
it
{
is_expected
.
to
validate_presence_of
(
:commit_id
)
}
it
{
is_expected
.
to_not
validate_presence_of
(
:noteable_id
)
}
end
context
'when note is not
comment
on commit'
do
context
'when note is not on commit'
do
before
{
allow
(
subject
).
to
receive
(
:for_commit?
).
and_return
(
false
)
}
it
{
is_expected
.
to_not
validate_presence_of
(
:commit_id
)
}
it
{
is_expected
.
to
validate_presence_of
(
:noteable_id
)
}
end
context
'when noteable and note project
is different
'
do
context
'when noteable and note project
differ
'
do
subject
do
build
(
:note
,
noteable:
create
(
:issue
),
project:
create
(
:project
))
build
(
:note
,
noteable:
build_stubbed
(
:issue
),
project:
build_stubbed
(
:project
))
end
it
{
is_expected
.
to
be_invalid
}
end
context
'when noteable and note project
is the same on
e'
do
context
'when noteable and note project
are the sam
e'
do
subject
{
create
(
:note
)
}
it
{
is_expected
.
to
be_valid
}
end
...
...
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