Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
b1461de9
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
b1461de9
编写于
10月 13, 2012
作者:
R
Riyad Preukschas
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make Note methods saner
上级
db3d90cb
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
39 addition
and
18 deletion
+39
-18
app/helpers/notes_helper.rb
app/helpers/notes_helper.rb
+1
-3
app/mailers/notify.rb
app/mailers/notify.rb
+1
-1
app/models/note.rb
app/models/note.rb
+9
-8
app/roles/static_model.rb
app/roles/static_model.rb
+8
-0
app/views/notes/_note.html.haml
app/views/notes/_note.html.haml
+3
-3
spec/mailers/notify_spec.rb
spec/mailers/notify_spec.rb
+1
-1
spec/models/note_spec.rb
spec/models/note_spec.rb
+16
-2
未找到文件。
app/helpers/notes_helper.rb
浏览文件 @
b1461de9
...
...
@@ -13,9 +13,7 @@ module NotesHelper
end
def
link_to_commit_diff_line_note
(
note
)
return
unless
note
.
line_note?
commit
=
note
.
target
commit
=
note
.
noteable
diff_index
,
diff_old_line
,
diff_new_line
=
note
.
line_code
.
split
(
'_'
)
link_file
=
commit
.
diffs
[
diff_index
.
to_i
].
new_path
...
...
app/mailers/notify.rb
浏览文件 @
b1461de9
...
...
@@ -29,7 +29,7 @@ class Notify < ActionMailer::Base
def
note_commit_email
(
recipient_id
,
note_id
)
@note
=
Note
.
find
(
note_id
)
@commit
=
@note
.
target
@commit
=
@note
.
noteable
@commit
=
CommitDecorator
.
decorate
(
@commit
)
@project
=
@note
.
project
mail
(
to:
recipient
(
recipient_id
),
subject:
subject
(
"note for commit
#{
@commit
.
short_id
}
"
,
@commit
.
title
))
...
...
app/models/note.rb
浏览文件 @
b1461de9
...
...
@@ -48,11 +48,12 @@ class Note < ActiveRecord::Base
@notify_author
||=
false
end
def
target
if
commit?
# override to return commits, which are not active record
def
noteable
if
for_commit?
project
.
commit
(
noteable_id
)
else
noteable
super
end
# Temp fix to prevent app crash
# if note commit id doesnt exist
...
...
@@ -74,22 +75,22 @@ class Note < ActiveRecord::Base
# Boolean
#
def
notify_only_author?
(
user
)
commit?
&&
commit_author
&&
for_
commit?
&&
commit_author
&&
commit_author
.
email
!=
user
.
email
end
def
commit?
def
for_
commit?
noteable_type
==
"Commit"
end
def
line_not
e?
def
for_diff_lin
e?
line_code
.
present?
end
def
commit_author
@commit_author
||=
project
.
users
.
find_by_email
(
target
.
author_email
)
||
project
.
users
.
find_by_name
(
target
.
author_name
)
project
.
users
.
find_by_email
(
noteable
.
author_email
)
||
project
.
users
.
find_by_name
(
noteable
.
author_name
)
rescue
nil
end
...
...
app/roles/static_model.rb
浏览文件 @
b1461de9
...
...
@@ -36,4 +36,12 @@ module StaticModel
def
destroyed?
false
end
def
==
(
other
)
if
other
.
is_a?
StaticModel
id
==
other
.
id
else
super
end
end
end
app/views/notes/_note.html.haml
浏览文件 @
b1461de9
...
...
@@ -8,10 +8,10 @@
ago
-
unless
note_for_main_target?
(
note
)
-
if
note
.
commit?
-
if
note
.
for_
commit?
%span
.cgray
on
#{
link_to
note
.
target
.
short_id
,
project_commit_path
(
@project
,
note
.
target
)
}
=
link_to_commit_diff_line_note
(
note
)
if
note
.
line_not
e?
on
#{
link_to
note
.
noteable
.
short_id
,
project_commit_path
(
@project
,
note
.
noteable
)
}
=
link_to_commit_diff_line_note
(
note
)
if
note
.
for_diff_lin
e?
-# only show vote if it's a note for the main target
-
if
note_for_main_target?
(
note
)
...
...
spec/mailers/notify_spec.rb
浏览文件 @
b1461de9
...
...
@@ -235,7 +235,7 @@ describe Notify do
commit
.
stub
(
:safe_message
).
and_return
(
'some message'
)
end
end
before
(
:each
)
{
note
.
stub
(
:
target
).
and_return
(
commit
)
}
before
(
:each
)
{
note
.
stub
(
:
noteable
).
and_return
(
commit
)
}
subject
{
Notify
.
note_commit_email
(
recipient
.
id
,
note
.
id
)
}
...
...
spec/models/note_spec.rb
浏览文件 @
b1461de9
...
...
@@ -85,9 +85,19 @@ describe Note do
noteable_type:
"Commit"
end
it
"should be accessible through #noteable"
do
@note
.
noteable_id
.
should
==
commit
.
id
@note
.
noteable
.
should
be_a
(
Commit
)
@note
.
noteable
.
should
==
commit
end
it
"should save a valid note"
do
@note
.
noteable_id
.
should
==
commit
.
id
@note
.
target
.
id
.
should
==
commit
.
id
@note
.
noteable
==
commit
end
it
"should be recognized by #for_commit?"
do
@note
.
should
be_for_commit
end
end
...
...
@@ -101,7 +111,11 @@ describe Note do
it
"should save a valid note"
do
@note
.
noteable_id
.
should
==
commit
.
id
@note
.
target
.
id
.
should
==
commit
.
id
@note
.
noteable
.
id
.
should
==
commit
.
id
end
it
"should be recognized by #for_diff_line?"
do
@note
.
should
be_for_diff_line
end
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录