Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
OHR Support
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Projects
OHR Support
Commits
dedf6966
Commit
dedf6966
authored
13 years ago
by
Eric Davis
Committed by
Holger Just
13 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[#604] Add missing test for Liquid
parent
464dafc1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/unit/lib/chili_project/liquid_test.rb
+211
-0
211 additions, 0 deletions
test/unit/lib/chili_project/liquid_test.rb
with
211 additions
and
0 deletions
test/unit/lib/chili_project/liquid_test.rb
0 → 100644
+
211
−
0
View file @
dedf6966
#-- encoding: UTF-8
#-- copyright
# ChiliProject is a project management system.
#
# Copyright (C) 2010-2011 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# See doc/COPYRIGHT.rdoc for more details.
#++
require
File
.
expand_path
(
'../../../../test_helper'
,
__FILE__
)
class
ChiliProject::LiquidTest
<
ActionView
::
TestCase
include
ApplicationHelper
context
"hello_world tag"
do
should
"render 'Hello world!'"
do
text
=
"{% hello_world %}"
assert_match
/Hello world!/
,
textilizable
(
text
)
end
end
context
"variable_list tag"
do
should
"render a list of the current variables"
do
text
=
"{% variable_list %}"
formatted
=
textilizable
(
text
)
assert
formatted
.
include?
(
'<ul>'
),
"Not in a list format"
assert
formatted
.
include?
(
'current_user'
)
end
end
context
"child_pages tag"
do
context
"with no arg"
do
context
"and @project set"
do
should
"should list all wiki pages for the current project"
do
@project
=
Project
.
generate!
.
reload
wiki
=
@project
.
wiki
top
=
WikiPage
.
generate!
(
:wiki
=>
wiki
,
:title
=>
'Top'
,
:content
=>
WikiContent
.
new
(
:text
=>
'top page'
))
child1
=
WikiPage
.
generate!
(
:wiki
=>
wiki
,
:title
=>
'Child1'
,
:content
=>
WikiContent
.
new
(
:text
=>
'child'
),
:parent
=>
top
)
text
=
"{% child_pages %}"
formatted
=
textilizable
(
text
)
assert
formatted
.
include?
(
'pages-hierarchy'
)
assert
formatted
.
include?
(
'Child1'
)
assert
formatted
.
include?
(
'Top'
)
end
end
context
"and no @project set"
do
should
"render a warning"
do
text
=
"{% child_pages %}"
formatted
=
textilizable
(
text
)
assert_match
/flash error/
,
formatted
assert
formatted
.
include?
(
'With no argument, this tag can be called from projects only'
)
end
end
end
context
"with a valid WikiPage arg"
do
should
"list all child pages for the wiki page"
do
@project
=
Project
.
generate!
.
reload
wiki
=
@project
.
wiki
top
=
WikiPage
.
generate!
(
:wiki
=>
wiki
,
:title
=>
'Top'
,
:content
=>
WikiContent
.
new
(
:text
=>
'top page'
))
child1
=
WikiPage
.
generate!
(
:wiki
=>
wiki
,
:title
=>
'Child1'
,
:content
=>
WikiContent
.
new
(
:text
=>
'child'
),
:parent
=>
top
)
text
=
"{% child_pages 'Top' %}"
formatted
=
textilizable
(
text
)
assert
formatted
.
include?
(
'pages-hierarchy'
)
assert
formatted
.
include?
(
'Child1'
)
assert
!
formatted
.
include?
(
'Top'
)
end
should
"allow cross project listings even when outside of a project"
do
project
=
Project
.
generate!
.
reload
# project not an ivar
wiki
=
project
.
wiki
top
=
WikiPage
.
generate!
(
:wiki
=>
wiki
,
:title
=>
'Top'
,
:content
=>
WikiContent
.
new
(
:text
=>
'top page'
))
child1
=
WikiPage
.
generate!
(
:wiki
=>
wiki
,
:title
=>
'Child1'
,
:content
=>
WikiContent
.
new
(
:text
=>
'child'
),
:parent
=>
top
)
text
=
"{% child_pages
#{
project
.
identifier
}
:'Top' %}"
formatted
=
textilizable
(
text
)
assert
formatted
.
include?
(
'pages-hierarchy'
)
assert
formatted
.
include?
(
'Child1'
)
assert
!
formatted
.
include?
(
'Top'
)
end
should
"show the WikiPage when parent=1 is set"
do
@project
=
Project
.
generate!
.
reload
wiki
=
@project
.
wiki
top
=
WikiPage
.
generate!
(
:wiki
=>
wiki
,
:title
=>
'Top'
,
:content
=>
WikiContent
.
new
(
:text
=>
'top page'
))
child1
=
WikiPage
.
generate!
(
:wiki
=>
wiki
,
:title
=>
'Child1'
,
:content
=>
WikiContent
.
new
(
:text
=>
'child'
),
:parent
=>
top
)
text
=
"{% child_pages 'Top', 'parent=1' %}"
formatted
=
textilizable
(
text
)
assert
formatted
.
include?
(
'pages-hierarchy'
)
assert
formatted
.
include?
(
'Child1'
)
assert
formatted
.
include?
(
'Top'
)
end
end
context
"with an invalid arg"
do
should
"render a warning"
do
@project
=
Project
.
generate!
.
reload
wiki
=
@project
.
wiki
top
=
WikiPage
.
generate!
(
:wiki
=>
wiki
,
:title
=>
'Top'
,
:content
=>
WikiContent
.
new
(
:text
=>
'top page'
))
child1
=
WikiPage
.
generate!
(
:wiki
=>
wiki
,
:title
=>
'Child1'
,
:content
=>
WikiContent
.
new
(
:text
=>
'child'
),
:parent
=>
top
)
text
=
"{% child_pages 1 %}"
formatted
=
textilizable
(
text
)
assert_match
/flash error/
,
formatted
assert
formatted
.
include?
(
'No such page'
)
end
end
end
context
"include tag"
do
setup
do
@project
=
Project
.
generate!
.
reload
@wiki
=
@project
.
wiki
@included_page
=
WikiPage
.
generate!
(
:wiki
=>
@wiki
,
:title
=>
'Included_Page'
,
:content
=>
WikiContent
.
new
(
:text
=>
'included page [[Second_Page]]'
))
@project2
=
Project
.
generate!
.
reload
@cross_project_page
=
WikiPage
.
generate!
(
:wiki
=>
@project2
.
wiki
,
:title
=>
'Second_Page'
,
:content
=>
WikiContent
.
new
(
:text
=>
'second page'
))
end
context
"with a direct page"
do
should
"show the included page's content"
do
text
=
"{% include 'Included Page' %}"
formatted
=
textilizable
(
text
)
assert
formatted
.
include?
(
'included page'
)
end
end
context
"with a cross-project page"
do
should
"show the included page's content"
do
text
=
"{% include '
#{
@project2
.
identifier
}
:Second Page' %}"
formatted
=
textilizable
(
text
)
assert
formatted
.
include?
(
'second page'
)
end
end
context
"with recursive includes"
do
should
"render all child pages"
do
parent
=
WikiPage
.
generate!
(
:wiki
=>
@wiki
,
:title
=>
'Recursive_Parent'
,
:content
=>
WikiContent
.
new
(
:text
=>
"h1. Parent
\r\n
{% include 'Recursive_Child1' %}"
))
child1
=
WikiPage
.
generate!
(
:wiki
=>
@wiki
,
:title
=>
'Recursive_Child1'
,
:content
=>
WikiContent
.
new
(
:text
=>
"h1. Child1
\r\n
{% include 'Recursive_Child2' %}"
))
child2
=
WikiPage
.
generate!
(
:wiki
=>
@wiki
,
:title
=>
'Recursive_Child2'
,
:content
=>
WikiContent
.
new
(
:text
=>
'h1. Child2'
))
formatted
=
textilizable
(
parent
.
reload
.
text
)
assert_match
/<h1.*?>\s*Parent.*?<\/h1>/
,
formatted
assert_match
/<h1.*?>\s*Child1.*?<\/h1>/
,
formatted
assert_match
/<h1.*?>\s*Child2.*?<\/h1>/
,
formatted
# make sure there are no dangling html result variables
assert_no_match
/!!html_results.*?!!/
,
formatted
end
end
context
"with a circular inclusion"
do
should
"render a warning"
do
circle_page
=
WikiPage
.
generate!
(
:wiki
=>
@wiki
,
:title
=>
'Circle'
,
:content
=>
WikiContent
.
new
(
:text
=>
'{% include "Circle2" %}'
))
circle_page2
=
WikiPage
.
generate!
(
:wiki
=>
@wiki
,
:title
=>
'Circle2'
,
:content
=>
WikiContent
.
new
(
:text
=>
'{% include "Circle" %}'
))
formatted
=
textilizable
(
circle_page
.
reload
.
text
)
assert_match
/flash error/
,
formatted
assert_match
'Circular inclusion detected'
,
formatted
end
end
context
"with an invalid arg"
do
should
"render a warning"
do
text
=
"{% include '404' %}"
formatted
=
textilizable
(
text
)
assert_match
/flash error/
,
formatted
assert
formatted
.
include?
(
'No such page'
)
end
should
"HTML escape the error"
do
text
=
"{% include '<script>alert(
\"
foo
\"
):</script>' %}"
formatted
=
textilizable
(
text
)
assert
formatted
.
include?
(
"No such page '<script>alert("foo"):</script>'"
)
end
end
context
"legacy"
do
should
"map to native include"
do
text
=
"{{include(
#{
@project2
.
identifier
}
:Second_Page)}}"
formatted
=
textilizable
(
text
)
assert
formatted
.
include?
(
'second page'
)
end
end
end
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment