Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
05bbad58
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,发现更多精彩内容 >>
提交
05bbad58
编写于
5月 11, 2016
作者:
R
Robert Speicher
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Clean up EventsHelper spec
上级
459af7ff
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
48 addition
and
47 deletion
+48
-47
spec/helpers/events_helper_spec.rb
spec/helpers/events_helper_spec.rb
+48
-47
未找到文件。
spec/helpers/events_helper_spec.rb
浏览文件 @
05bbad58
require
'spec_helper'
describe
EventsHelper
do
include
ApplicationHelper
include
GitlabMarkdownHelper
describe
'#event_note'
do
before
do
allow
(
helper
).
to
receive
(
:current_user
).
and_return
(
double
)
end
let
(
:current_user
)
{
create
(
:user
,
email:
"current@email.com"
)
}
it
'should display one line of plain text without alteration'
do
input
=
'A short, plain note'
expect
(
helper
.
event_note
(
input
)).
to
match
(
input
)
expect
(
helper
.
event_note
(
input
)).
not_to
match
(
/\.\.\.\z/
)
end
it
'should display one line of plain text without alteration'
do
input
=
'A short, plain note'
expect
(
event_note
(
input
)).
to
match
(
input
)
expect
(
event_note
(
input
)).
not_to
match
(
/\.\.\.\z/
)
end
it
'should display inline code'
do
input
=
'A note with `inline code`'
expected
=
'A note with <code>inline code</code>'
it
'should display inline code'
do
input
=
'A note with `inline code`'
expected
=
'A note with <code>inline code</code>'
expect
(
helper
.
event_note
(
input
)).
to
match
(
expected
)
end
expect
(
event_note
(
input
)).
to
match
(
expected
)
end
it
'should truncate a note with multiple paragraphs'
do
input
=
"Paragraph 1
\n\n
Paragraph 2"
expected
=
'Paragraph 1...'
it
'should truncate a note with multiple paragraphs'
do
input
=
"Paragraph 1
\n\n
Paragraph 2"
expected
=
'Paragraph 1...'
expect
(
helper
.
event_note
(
input
)).
to
match
(
expected
)
end
expect
(
event_note
(
input
)).
to
match
(
expected
)
end
it
'should display the first line of a code block'
do
input
=
"```
\n
Code block
\n
with two lines
\n
```"
expected
=
%r{<pre.+><code>Code block
\.\.\.
</code></pre>}
it
'should display the first line of a code block'
do
input
=
"```
\n
Code block
\n
with two lines
\n
```"
expected
=
%r{<pre.+><code>Code block
\.\.\.
</code></pre>}
expect
(
helper
.
event_note
(
input
)).
to
match
(
expected
)
end
expect
(
event_note
(
input
)).
to
match
(
expected
)
end
it
'should truncate a single long line of text'
do
text
=
'The quick brown fox jumped over the lazy dog twice'
# 50 chars
input
=
text
*
4
expected
=
(
text
*
2
).
sub
(
/.{3}/
,
'...'
)
it
'should truncate a single long line of text'
do
text
=
'The quick brown fox jumped over the lazy dog twice'
# 50 chars
input
=
"
#{
text
}#{
text
}#{
text
}#{
text
}
"
# 200 chars
expected
=
"
#{
text
}#{
text
}
"
.
sub
(
/.{3}/
,
'...'
)
expect
(
helper
.
event_note
(
input
)).
to
match
(
expected
)
end
expect
(
event_note
(
input
)).
to
match
(
expected
)
end
it
'should preserve a link href when link text is truncated'
do
text
=
'The quick brown fox jumped over the lazy dog'
# 44 chars
input
=
"
#{
text
}#{
text
}#{
text
}
"
# 133 chars
link_url
=
'http://example.com/foo/bar/baz'
# 30 chars
input
<<
link_url
expected_link_text
=
'http://example...</a>'
it
'should preserve a link href when link text is truncated'
do
text
=
'The quick brown fox jumped over the lazy dog'
# 44 chars
input
=
"
#{
text
}#{
text
}#{
text
}
"
# 133 chars
link_url
=
'http://example.com/foo/bar/baz'
# 30 chars
input
<<
link_url
expected_link_text
=
'http://example...</a>'
expect
(
event_note
(
input
)).
to
match
(
link_url
)
expect
(
event_note
(
input
)).
to
match
(
expected_link_text
)
end
expect
(
helper
.
event_note
(
input
)).
to
match
(
link_url
)
expect
(
helper
.
event_note
(
input
)).
to
match
(
expected_link_text
)
end
it
'should preserve code color scheme'
do
input
=
"```ruby
\n
def test
\n
'hello world'
\n
end
\n
```"
expected
=
'<pre class="code highlight js-syntax-highlight ruby">'
\
"<code><span class=
\"
k
\"
>def</span> <span class=
\"
nf
\"
>test</span>
\n
"
\
" <span class=
\"
s1
\"
>
\'
hello world
\'
</span>
\n
"
\
"<span class=
\"
k
\"
>end</span>"
\
'</code></pre>'
expect
(
event_note
(
input
)).
to
eq
(
expected
)
it
'should preserve code color scheme'
do
input
=
"```ruby
\n
def test
\n
'hello world'
\n
end
\n
```"
expected
=
'<pre class="code highlight js-syntax-highlight ruby">'
\
"<code><span class=
\"
k
\"
>def</span> <span class=
\"
nf
\"
>test</span>
\n
"
\
" <span class=
\"
s1
\"
>
\'
hello world
\'
</span>
\n
"
\
"<span class=
\"
k
\"
>end</span>"
\
'</code></pre>'
expect
(
helper
.
event_note
(
input
)).
to
eq
(
expected
)
end
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录