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
Boxiang Sun
gitlab-ce
Commits
dbba6002
Commit
dbba6002
authored
May 18, 2016
by
Grzegorz Bizon
Committed by
Robert Speicher
May 29, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve note factory
parent
cc2efcf1
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
19 additions
and
21 deletions
+19
-21
features/steps/project/merge_requests.rb
features/steps/project/merge_requests.rb
+1
-1
spec/factories/notes.rb
spec/factories/notes.rb
+2
-5
spec/features/issues/note_polling_spec.rb
spec/features/issues/note_polling_spec.rb
+2
-3
spec/lib/gitlab/note_data_builder_spec.rb
spec/lib/gitlab/note_data_builder_spec.rb
+8
-8
spec/models/legacy_diff_note_spec.rb
spec/models/legacy_diff_note_spec.rb
+3
-1
spec/models/project_services/hipchat_service_spec.rb
spec/models/project_services/hipchat_service_spec.rb
+3
-3
No files found.
features/steps/project/merge_requests.rb
View file @
dbba6002
...
@@ -273,7 +273,7 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps
...
@@ -273,7 +273,7 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps
step
'user "John Doe" leaves a comment like "Line is wrong" on diff'
do
step
'user "John Doe" leaves a comment like "Line is wrong" on diff'
do
mr
=
MergeRequest
.
find_by
(
title:
"Bug NS-05"
)
mr
=
MergeRequest
.
find_by
(
title:
"Bug NS-05"
)
create
(
:note_on_merge_request_diff
,
project:
project
,
create
(
:note_on_merge_request_diff
,
project:
project
,
noteable
_id:
mr
.
id
,
noteable
:
mr
,
author:
user_exists
(
"John Doe"
),
author:
user_exists
(
"John Doe"
),
line_code:
sample_commit
.
line_code
,
line_code:
sample_commit
.
line_code
,
note:
'Line is wrong'
)
note:
'Line is wrong'
)
...
...
spec/factories/notes.rb
View file @
dbba6002
...
@@ -7,7 +7,7 @@ FactoryGirl.define do
...
@@ -7,7 +7,7 @@ FactoryGirl.define do
project
project
note
"Note"
note
"Note"
author
author
noteable
{
create
(
:issue
,
project:
project
)
}
on_issue
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
...
@@ -21,8 +21,8 @@ FactoryGirl.define do
...
@@ -21,8 +21,8 @@ FactoryGirl.define do
trait
:on_commit
do
trait
:on_commit
do
noteable
nil
noteable
nil
noteable_type
'Commit'
noteable_id
nil
noteable_id
nil
noteable_type
'Commit'
commit_id
RepoHelpers
.
sample_commit
.
id
commit_id
RepoHelpers
.
sample_commit
.
id
end
end
...
@@ -31,17 +31,14 @@ FactoryGirl.define do
...
@@ -31,17 +31,14 @@ FactoryGirl.define do
end
end
trait
:on_issue
do
trait
:on_issue
do
noteable_type
'Issue'
noteable
{
create
(
:issue
,
project:
project
)
}
noteable
{
create
(
:issue
,
project:
project
)
}
end
end
trait
:on_merge_request
do
trait
:on_merge_request
do
noteable_type
'MergeRequest'
noteable
{
create
(
:merge_request
,
source_project:
project
)
}
noteable
{
create
(
:merge_request
,
source_project:
project
)
}
end
end
trait
:on_project_snippet
do
trait
:on_project_snippet
do
noteable_type
'Snippet'
noteable
{
create
(
:snippet
,
project:
project
)
}
noteable
{
create
(
:snippet
,
project:
project
)
}
end
end
...
...
spec/features/issues/note_polling_spec.rb
View file @
dbba6002
...
@@ -9,9 +9,8 @@ feature 'Issue notes polling' do
...
@@ -9,9 +9,8 @@ feature 'Issue notes polling' do
end
end
scenario
'Another user adds a comment to an issue'
,
js:
true
do
scenario
'Another user adds a comment to an issue'
,
js:
true
do
note
=
create
(
:note_on_issue
,
noteable:
issue
,
note
=
create
(
:note
,
noteable:
issue
,
project:
project
,
project:
project
,
note:
'Looks good!'
)
note:
'Looks good!'
)
page
.
execute_script
(
'notes.refresh();'
)
page
.
execute_script
(
'notes.refresh();'
)
...
...
spec/lib/gitlab/note_data_builder_spec.rb
View file @
dbba6002
...
@@ -44,13 +44,13 @@ describe 'Gitlab::NoteDataBuilder', lib: true do
...
@@ -44,13 +44,13 @@ describe 'Gitlab::NoteDataBuilder', lib: true do
end
end
let
(
:note
)
do
let
(
:note
)
do
create
(
:note_on_issue
,
noteable
_id:
issue
.
id
,
project:
project
)
create
(
:note_on_issue
,
noteable
:
issue
,
project:
project
)
end
end
it
'returns the note and issue-specific data'
do
it
'returns the note and issue-specific data'
do
expect
(
data
).
to
have_key
(
:issue
)
expect
(
data
).
to
have_key
(
:issue
)
expect
(
data
[
:issue
].
except
(
'updated_at'
))
expect
(
data
[
:issue
].
except
(
'updated_at'
))
.
to
eq
(
issue
.
hook_attrs
.
except
(
'updated_at'
))
.
to
eq
(
issue
.
reload
.
hook_attrs
.
except
(
'updated_at'
))
expect
(
data
[
:issue
][
'updated_at'
])
expect
(
data
[
:issue
][
'updated_at'
])
.
to
be
>
issue
.
hook_attrs
[
'updated_at'
]
.
to
be
>
issue
.
hook_attrs
[
'updated_at'
]
end
end
...
@@ -67,14 +67,14 @@ describe 'Gitlab::NoteDataBuilder', lib: true do
...
@@ -67,14 +67,14 @@ describe 'Gitlab::NoteDataBuilder', lib: true do
end
end
let
(
:note
)
do
let
(
:note
)
do
create
(
:note_on_merge_request
,
noteable
_id:
merge_request
.
id
,
create
(
:note_on_merge_request
,
noteable
:
merge_request
,
project:
project
)
project:
project
)
end
end
it
'returns the note and merge request data'
do
it
'returns the note and merge request data'
do
expect
(
data
).
to
have_key
(
:merge_request
)
expect
(
data
).
to
have_key
(
:merge_request
)
expect
(
data
[
:merge_request
].
except
(
'updated_at'
))
expect
(
data
[
:merge_request
].
except
(
'updated_at'
))
.
to
eq
(
merge_request
.
hook_attrs
.
except
(
'updated_at'
))
.
to
eq
(
merge_request
.
reload
.
hook_attrs
.
except
(
'updated_at'
))
expect
(
data
[
:merge_request
][
'updated_at'
])
expect
(
data
[
:merge_request
][
'updated_at'
])
.
to
be
>
merge_request
.
hook_attrs
[
'updated_at'
]
.
to
be
>
merge_request
.
hook_attrs
[
'updated_at'
]
end
end
...
@@ -90,14 +90,14 @@ describe 'Gitlab::NoteDataBuilder', lib: true do
...
@@ -90,14 +90,14 @@ describe 'Gitlab::NoteDataBuilder', lib: true do
end
end
let
(
:note
)
do
let
(
:note
)
do
create
(
:note_on_merge_request_diff
,
noteable
_id:
merge_request
.
id
,
create
(
:note_on_merge_request_diff
,
noteable
:
merge_request
,
project:
project
)
project:
project
)
end
end
it
'returns the note and merge request diff data'
do
it
'returns the note and merge request diff data'
do
expect
(
data
).
to
have_key
(
:merge_request
)
expect
(
data
).
to
have_key
(
:merge_request
)
expect
(
data
[
:merge_request
].
except
(
'updated_at'
))
expect
(
data
[
:merge_request
].
except
(
'updated_at'
))
.
to
eq
(
merge_request
.
hook_attrs
.
except
(
'updated_at'
))
.
to
eq
(
merge_request
.
reload
.
hook_attrs
.
except
(
'updated_at'
))
expect
(
data
[
:merge_request
][
'updated_at'
])
expect
(
data
[
:merge_request
][
'updated_at'
])
.
to
be
>
merge_request
.
hook_attrs
[
'updated_at'
]
.
to
be
>
merge_request
.
hook_attrs
[
'updated_at'
]
end
end
...
@@ -113,14 +113,14 @@ describe 'Gitlab::NoteDataBuilder', lib: true do
...
@@ -113,14 +113,14 @@ describe 'Gitlab::NoteDataBuilder', lib: true do
end
end
let!
(
:note
)
do
let!
(
:note
)
do
create
(
:note_on_project_snippet
,
noteable
_id:
snippet
.
id
,
create
(
:note_on_project_snippet
,
noteable
:
snippet
,
project:
project
)
project:
project
)
end
end
it
'returns the note and project snippet data'
do
it
'returns the note and project snippet data'
do
expect
(
data
).
to
have_key
(
:snippet
)
expect
(
data
).
to
have_key
(
:snippet
)
expect
(
data
[
:snippet
].
except
(
'updated_at'
))
expect
(
data
[
:snippet
].
except
(
'updated_at'
))
.
to
eq
(
snippet
.
hook_attrs
.
except
(
'updated_at'
))
.
to
eq
(
snippet
.
reload
.
hook_attrs
.
except
(
'updated_at'
))
expect
(
data
[
:snippet
][
'updated_at'
])
expect
(
data
[
:snippet
][
'updated_at'
])
.
to
be
>
snippet
.
hook_attrs
[
'updated_at'
]
.
to
be
>
snippet
.
hook_attrs
[
'updated_at'
]
end
end
...
...
spec/models/legacy_diff_note_spec.rb
View file @
dbba6002
...
@@ -63,7 +63,9 @@ describe LegacyDiffNote, models: true do
...
@@ -63,7 +63,9 @@ describe LegacyDiffNote, models: true do
code
=
Gitlab
::
Diff
::
LineCode
.
generate
(
diff
.
new_path
,
line
.
new_pos
,
line
.
old_pos
)
code
=
Gitlab
::
Diff
::
LineCode
.
generate
(
diff
.
new_path
,
line
.
new_pos
,
line
.
old_pos
)
# We're persisting in order to trigger the set_diff callback
# We're persisting in order to trigger the set_diff callback
note
=
create
(
:note_on_merge_request_diff
,
noteable:
merge
,
line_code:
code
)
note
=
create
(
:note_on_merge_request_diff
,
noteable:
merge
,
line_code:
code
,
project:
merge
.
source_project
)
# Make sure we don't get a false positive from a guard clause
# Make sure we don't get a false positive from a guard clause
expect
(
note
).
to
receive
(
:find_noteable_diff
).
and_call_original
expect
(
note
).
to
receive
(
:find_noteable_diff
).
and_call_original
...
...
spec/models/project_services/hipchat_service_spec.rb
View file @
dbba6002
...
@@ -211,7 +211,7 @@ describe HipchatService, models: true do
...
@@ -211,7 +211,7 @@ describe HipchatService, models: true do
end
end
let
(
:merge_request_note
)
do
let
(
:merge_request_note
)
do
create
(
:note_on_merge_request
,
noteable
_id:
merge_request
.
id
,
create
(
:note_on_merge_request
,
noteable
:
merge_request
,
project:
project
,
project:
project
,
note:
"merge request note"
)
note:
"merge request note"
)
end
end
...
@@ -239,7 +239,7 @@ describe HipchatService, models: true do
...
@@ -239,7 +239,7 @@ describe HipchatService, models: true do
context
'when issue comment event triggered'
do
context
'when issue comment event triggered'
do
let
(
:issue
)
{
create
(
:issue
,
project:
project
)
}
let
(
:issue
)
{
create
(
:issue
,
project:
project
)
}
let
(
:issue_note
)
do
let
(
:issue_note
)
do
create
(
:note_on_issue
,
noteable
_id:
issue
.
id
,
project:
project
,
create
(
:note_on_issue
,
noteable
:
issue
,
project:
project
,
note:
"issue note"
)
note:
"issue note"
)
end
end
...
@@ -264,7 +264,7 @@ describe HipchatService, models: true do
...
@@ -264,7 +264,7 @@ describe HipchatService, models: true do
context
'when snippet comment event triggered'
do
context
'when snippet comment event triggered'
do
let
(
:snippet
)
{
create
(
:project_snippet
,
project:
project
)
}
let
(
:snippet
)
{
create
(
:project_snippet
,
project:
project
)
}
let
(
:snippet_note
)
do
let
(
:snippet_note
)
do
create
(
:note_on_project_snippet
,
noteable
_id:
snippet
.
id
,
create
(
:note_on_project_snippet
,
noteable
:
snippet
,
project:
project
,
project:
project
,
note:
"snippet note"
)
note:
"snippet note"
)
end
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