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
iv
gitlab-ce
Commits
ea40c08d
Commit
ea40c08d
authored
Jul 11, 2016
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow SentNotification#position to be set as string or hash
parent
92772f85
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
0 deletions
+37
-0
app/models/sent_notification.rb
app/models/sent_notification.rb
+13
-0
spec/services/notification_service_spec.rb
spec/services/notification_service_spec.rb
+24
-0
No files found.
app/models/sent_notification.rb
View file @
ea40c08d
...
...
@@ -72,6 +72,19 @@ class SentNotification < ActiveRecord::Base
end
end
def
position
=
(
new_position
)
if
new_position
.
is_a?
(
String
)
new_position
=
JSON
.
parse
(
new_position
)
rescue
nil
end
if
new_position
.
is_a?
(
Hash
)
new_position
=
new_position
.
with_indifferent_access
new_position
=
Gitlab
::
Diff
::
Position
.
new
(
new_position
)
end
super
(
new_position
)
end
def
to_param
self
.
reply_key
end
...
...
spec/services/notification_service_spec.rb
View file @
ea40c08d
...
...
@@ -293,6 +293,30 @@ describe NotificationService, services: true do
end
end
end
context
"merge request diff note"
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
,
assignee:
user
)
}
let
(
:note
)
{
create
(
:diff_note_on_merge_request
,
project:
project
,
noteable:
merge_request
)
}
before
do
build_team
(
note
.
project
)
project
.
team
<<
[
merge_request
.
author
,
:master
]
project
.
team
<<
[
merge_request
.
assignee
,
:master
]
end
describe
:new_note
do
it
"records sent notifications"
do
# Ensure create SentNotification by noteable = merge_request 6 times, not noteable = note
expect
(
SentNotification
).
to
receive
(
:record_note
).
with
(
note
,
any_args
).
exactly
(
4
).
times
.
and_call_original
notification
.
new_note
(
note
)
expect
(
SentNotification
.
last
.
position
).
to
eq
(
note
.
position
)
end
end
end
end
describe
'Issues'
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