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
21d0cddd
Commit
21d0cddd
authored
Apr 26, 2016
by
Grzegorz Bizon
Committed by
Robert Speicher
May 29, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not override foreign attributes in note factory
parent
0e613db7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
6 deletions
+5
-6
app/models/note.rb
app/models/note.rb
+1
-1
spec/factories/notes.rb
spec/factories/notes.rb
+4
-5
No files found.
app/models/note.rb
View file @
21d0cddd
...
@@ -34,7 +34,7 @@ class Note < ActiveRecord::Base
...
@@ -34,7 +34,7 @@ class Note < ActiveRecord::Base
validates
:author
,
presence:
true
validates
:author
,
presence:
true
validate
unless: :for_commit?
do
|
note
|
validate
unless: :for_commit?
do
|
note
|
unless
note
.
noteable
.
try
(
:project
)
==
project
unless
note
.
noteable
.
try
(
:project
)
==
note
.
project
errors
.
add
(
:invalid_project
,
'Note and noteable project mismatch'
)
errors
.
add
(
:invalid_project
,
'Note and noteable project mismatch'
)
end
end
end
end
...
...
spec/factories/notes.rb
View file @
21d0cddd
...
@@ -4,10 +4,10 @@ include ActionDispatch::TestProcess
...
@@ -4,10 +4,10 @@ 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
)
}
noteable
{
create
(
:issue
,
project:
project
)
}
project
{
noteable
.
project
}
factory
:note_on_issue
,
aliases:
[
:votable_note
]
factory
:note_on_issue
,
aliases:
[
:votable_note
]
factory
:note_on_commit
,
traits:
[
:on_commit
]
factory
:note_on_commit
,
traits:
[
:on_commit
]
...
@@ -20,7 +20,6 @@ FactoryGirl.define do
...
@@ -20,7 +20,6 @@ FactoryGirl.define do
factory
:upvote_note
,
traits:
[
:award
,
:upvote
]
factory
:upvote_note
,
traits:
[
:award
,
:upvote
]
trait
:on_commit
do
trait
:on_commit
do
project
noteable
nil
noteable
nil
commit_id
RepoHelpers
.
sample_commit
.
id
commit_id
RepoHelpers
.
sample_commit
.
id
noteable_type
"Commit"
noteable_type
"Commit"
...
@@ -31,11 +30,11 @@ FactoryGirl.define do
...
@@ -31,11 +30,11 @@ FactoryGirl.define do
end
end
trait
:on_merge_request
do
trait
:on_merge_request
do
noteable
{
create
(
:merge_request
)
}
noteable
{
create
(
:merge_request
,
project:
project
)
}
end
end
trait
:on_project_snippet
do
trait
:on_project_snippet
do
noteable
{
create
(
:snippet
)
}
noteable
{
create
(
:snippet
,
project:
project
)
}
end
end
trait
:system
do
trait
:system
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