caterpillar 1.4.3 → 1.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ChangeLog +4 -0
- data/lib/caterpillar.rb +1 -1
- data/lib/caterpillar/liferay.rb +22 -21
- data/lib/caterpillar/portlet.rb +7 -4
- data/lib/caterpillar/security.rb +6 -2
- data/lib/caterpillar/task.rb +1 -1
- data/lib/caterpillar/util.rb +13 -0
- data/lib/rails_gem_chooser.rb +1 -1
- data/portlet_test_bench/controllers/caterpillar/xhr_controller.rb +20 -0
- data/portlet_test_bench/routing.rb +11 -2
- data/portlet_test_bench/views/caterpillar/application/index.html.erb +3 -141
- data/portlet_test_bench/views/caterpillar/application/portlet_test_bench.html.erb +155 -0
- data/portlet_test_bench/views/caterpillar/xhr/time.html.erb +29 -0
- data/test/portlets_test.rb +7 -0
- data/test/xml_test.rb +5 -4
- metadata +7 -4
data/ChangeLog
CHANGED
data/lib/caterpillar.rb
CHANGED
data/lib/caterpillar/liferay.rb
CHANGED
|
@@ -165,9 +165,6 @@ module Caterpillar # :nodoc:
|
|
|
165
165
|
else
|
|
166
166
|
_p.update(:category => categories.first)
|
|
167
167
|
end
|
|
168
|
-
# debug
|
|
169
|
-
#puts _p.inspect
|
|
170
|
-
|
|
171
168
|
end
|
|
172
169
|
end
|
|
173
170
|
|
|
@@ -190,33 +187,41 @@ module Caterpillar # :nodoc:
|
|
|
190
187
|
portlets.each do |portlet|
|
|
191
188
|
# <portlet>
|
|
192
189
|
app.elements << self.portlet_element(portlet)
|
|
193
|
-
# <role-mapper>s
|
|
194
|
-
roles.each {|role| app.elements << role}
|
|
195
190
|
end
|
|
196
191
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
return
|
|
192
|
+
# define role-mappers only once, at the end
|
|
193
|
+
roles.each {|role| app.elements << role}
|
|
194
|
+
|
|
195
|
+
return Util.xml_to_s(doc)
|
|
201
196
|
end
|
|
202
197
|
|
|
203
198
|
# liferay-display XML
|
|
204
199
|
def display_xml(portlets)
|
|
205
200
|
liferay_display_file = File.join(self.WEB_INF,'liferay-display.xml')
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
201
|
+
|
|
202
|
+
# read existing configuration
|
|
203
|
+
_doc = REXML::Document.new File.new(liferay_display_file)
|
|
204
|
+
display = _doc.root
|
|
205
|
+
|
|
206
|
+
doc = REXML::Document.new
|
|
207
|
+
doc << REXML::XMLDecl.new('1.0', 'utf-8')
|
|
208
|
+
doc << REXML::DocType.new('display',
|
|
209
|
+
'PUBLIC '+\
|
|
210
|
+
'"-//Liferay//DTD Display %s//EN" ' % (self.dtd_version) +\
|
|
211
|
+
'"http://www.liferay.com/dtd/liferay-display_%s.dtd"' % self.dtd_version.gsub('.','_')
|
|
212
|
+
)
|
|
213
|
+
doc << display
|
|
214
|
+
|
|
210
215
|
# include portlets
|
|
211
216
|
Util.categorize(portlets).each_pair do |category_name, portlets|
|
|
212
217
|
category = nil
|
|
213
218
|
display.each_element {|e| if e.attributes['name'] == category_name.to_s then category = e; break end}
|
|
214
|
-
|
|
219
|
+
|
|
215
220
|
unless category
|
|
216
221
|
category = REXML::Element.new('category', display)
|
|
217
222
|
category.attributes['name'] = category_name.to_s
|
|
218
223
|
end
|
|
219
|
-
|
|
224
|
+
|
|
220
225
|
portlets.each do |portlet|
|
|
221
226
|
if category.has_elements?
|
|
222
227
|
# unless he holds does not add again
|
|
@@ -229,14 +234,10 @@ module Caterpillar # :nodoc:
|
|
|
229
234
|
else
|
|
230
235
|
category.add_element 'portlet', {'id' => portlet[:name]}
|
|
231
236
|
end
|
|
232
|
-
end
|
|
233
|
-
|
|
237
|
+
end
|
|
234
238
|
end
|
|
235
239
|
|
|
236
|
-
|
|
237
|
-
doc.write(xml, -1) # no indentation, tag and text should be on same line
|
|
238
|
-
#doc.write(xml, 4) # without identation is very dificult to reconfigure those files in production
|
|
239
|
-
return xml.gsub('\'', '"') # fix rexml attribute single quotes to double quotes
|
|
240
|
+
return Util.xml_to_s(doc)
|
|
240
241
|
end
|
|
241
242
|
|
|
242
243
|
protected
|
data/lib/caterpillar/portlet.rb
CHANGED
|
@@ -14,6 +14,7 @@ else
|
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
module Caterpillar
|
|
17
|
+
|
|
17
18
|
# Formulates generic JSR286 portlet XML
|
|
18
19
|
class Portlet
|
|
19
20
|
class << self
|
|
@@ -54,18 +55,20 @@ module Caterpillar
|
|
|
54
55
|
end
|
|
55
56
|
|
|
56
57
|
# create XML element tree
|
|
58
|
+
# (in proper order so the validation passes)
|
|
57
59
|
portlets.each do |portlet|
|
|
58
60
|
# <portlet>
|
|
59
61
|
app.elements << self.portlet_element(portlet, session, app)
|
|
62
|
+
end
|
|
63
|
+
portlets.each do |portlet|
|
|
60
64
|
# <filter>
|
|
61
65
|
app.elements << self.filter_element(portlet)
|
|
66
|
+
end
|
|
67
|
+
portlets.each do |portlet|
|
|
62
68
|
# filter mapping
|
|
63
69
|
app.elements << self.filter_mapping(portlet)
|
|
64
70
|
end
|
|
65
|
-
|
|
66
|
-
doc.write(xml, -1) # no indentation, tag and text should be on same line
|
|
67
|
-
#doc.write(xml, 4) # without identation is very dificult to reconfigure those files in production
|
|
68
|
-
return xml.gsub('\'', '"') # fix rexml attribute single quotes to double quotes
|
|
71
|
+
return Util.xml_to_s(doc)
|
|
69
72
|
end
|
|
70
73
|
|
|
71
74
|
# <portlet> element.
|
data/lib/caterpillar/security.rb
CHANGED
|
@@ -106,14 +106,18 @@ module Caterpillar # :nodoc:
|
|
|
106
106
|
# Return Rails' session key
|
|
107
107
|
def self.get_session_key
|
|
108
108
|
# Rails before 2.3 had a different way
|
|
109
|
-
if RAILS_GEM_VERSION.gsub('.','').to_i < 230
|
|
109
|
+
if defined?(RAILS_GEM_VERSION) and RAILS_GEM_VERSION.gsub('.','').to_i < 230
|
|
110
110
|
ActionController::Base.session_options_for(nil,nil)[:session_key]
|
|
111
111
|
# On Rails 2.3:
|
|
112
112
|
else
|
|
113
113
|
key = ActionController::Base.session_options[:key]
|
|
114
114
|
return key unless key.nil?
|
|
115
115
|
# try session_key
|
|
116
|
-
ActionController::Base.session_options[:session_key]
|
|
116
|
+
key = ActionController::Base.session_options[:session_key]
|
|
117
|
+
return key unless key.nil?
|
|
118
|
+
# XXX: Rails changed sometime during 2.3.8 ..
|
|
119
|
+
STDERR.puts 'Failed to read session key - consider this a bug'
|
|
120
|
+
return nil
|
|
117
121
|
end
|
|
118
122
|
end
|
|
119
123
|
|
data/lib/caterpillar/task.rb
CHANGED
data/lib/caterpillar/util.rb
CHANGED
|
@@ -124,6 +124,19 @@ module Caterpillar
|
|
|
124
124
|
return ret
|
|
125
125
|
end
|
|
126
126
|
|
|
127
|
+
def xml_to_s(doc)
|
|
128
|
+
# Serializes the REXML::Document to String.
|
|
129
|
+
# It has to pass Ruby unit test validation and Liferay runtime validation.
|
|
130
|
+
# The XML requires strict ordering of the child nodes,
|
|
131
|
+
# and also tags and values have to be on a single line.
|
|
132
|
+
require 'rexml/formatters/pretty'
|
|
133
|
+
str = String.new
|
|
134
|
+
fmt = REXML::Formatters::Pretty.new(4)
|
|
135
|
+
fmt.compact = true
|
|
136
|
+
fmt.write(doc,str)
|
|
137
|
+
return str.gsub('\'', '"') # fix rexml attribute single quotes to double quotes
|
|
138
|
+
end
|
|
139
|
+
|
|
127
140
|
end # static
|
|
128
141
|
end
|
|
129
142
|
end
|
data/lib/rails_gem_chooser.rb
CHANGED
|
@@ -41,7 +41,7 @@ class RailsGemChooser
|
|
|
41
41
|
config = f.read
|
|
42
42
|
f.close
|
|
43
43
|
rails_gem_version = config[/^RAILS_GEM_VERSION.*(\d\.\d\.\d)/,1]
|
|
44
|
-
STDOUT.puts 'Detected Rails version %s from the config file %s' % [rails_gem_version,config_file]
|
|
44
|
+
#STDOUT.puts 'Detected Rails version %s from the config file %s' % [rails_gem_version,config_file]
|
|
45
45
|
return rails_gem_version
|
|
46
46
|
end
|
|
47
47
|
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
class Caterpillar::XhrController < Caterpillar::ApplicationController
|
|
3
|
+
|
|
4
|
+
def prototype
|
|
5
|
+
# the page with the XHR triggers
|
|
6
|
+
@javascripts = %w{prototype}
|
|
7
|
+
render :action => 'time'
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def jquery
|
|
11
|
+
# the page with the XHR triggers
|
|
12
|
+
@javascripts = %w{jquery-1.4.2.min}
|
|
13
|
+
render :action => 'time'
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def get_time
|
|
17
|
+
send_data Time.now.to_s, :type => 'text/html'
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
end
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
module Caterpillar #:nodoc:
|
|
5
4
|
# Routes for Portlet Test Bench.
|
|
6
5
|
module Routing
|
|
@@ -10,7 +9,7 @@ module Caterpillar #:nodoc:
|
|
|
10
9
|
@set.add_named_route(
|
|
11
10
|
'portlet_test_bench',
|
|
12
11
|
'caterpillar/test_bench',
|
|
13
|
-
{:controller => 'Caterpillar::Application'})
|
|
12
|
+
{:controller => 'Caterpillar::Application', :action => 'portlet_test_bench'})
|
|
14
13
|
|
|
15
14
|
@set.add_route(
|
|
16
15
|
'caterpillar/test_bench/http_methods/:action',
|
|
@@ -44,6 +43,10 @@ module Caterpillar #:nodoc:
|
|
|
44
43
|
'caterpillar/test_bench/liferay/:action',
|
|
45
44
|
{:controller => 'Caterpillar::Liferay'})
|
|
46
45
|
|
|
46
|
+
@set.add_route(
|
|
47
|
+
'caterpillar/test_bench/xhr/:action',
|
|
48
|
+
{:controller => 'Caterpillar::Xhr'})
|
|
49
|
+
|
|
47
50
|
# Liferay GID
|
|
48
51
|
@set.add_route(
|
|
49
52
|
'caterpillar/test_bench/liferay/:action/gid/:gid',
|
|
@@ -54,6 +57,12 @@ module Caterpillar #:nodoc:
|
|
|
54
57
|
'caterpillar/test_bench/junit/:action',
|
|
55
58
|
{:controller => 'Caterpillar::Junit'})
|
|
56
59
|
|
|
60
|
+
# index
|
|
61
|
+
@set.add_named_route(
|
|
62
|
+
'caterpillar',
|
|
63
|
+
'caterpillar/',
|
|
64
|
+
{:controller => 'Caterpillar::Application'})
|
|
65
|
+
|
|
57
66
|
end
|
|
58
67
|
end
|
|
59
68
|
end
|
|
@@ -1,143 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
<style type="text/css">
|
|
3
|
-
body {
|
|
4
|
-
background: white;
|
|
5
|
-
}
|
|
6
|
-
#testBenchContainer {
|
|
7
|
-
background: #FFFFCC;
|
|
8
|
-
border: 1px solid #B9B9B9;
|
|
9
|
-
padding: 8px;
|
|
10
|
-
font-size: 11px;
|
|
11
|
-
line-height: 15px;
|
|
12
|
-
}
|
|
13
|
-
#testBenchContainer h1 {
|
|
14
|
-
border-bottom: 1px solid #B9B9B9;
|
|
15
|
-
color: #990000;
|
|
16
|
-
font-size: 18px;
|
|
17
|
-
font-weight: bold;
|
|
18
|
-
margin-bottom: 20px;
|
|
19
|
-
padding: 0 0 0 15px;
|
|
20
|
-
}
|
|
21
|
-
#testBenchContainer h2 {
|
|
22
|
-
border: 1px solid #B9B9B9;
|
|
23
|
-
color: #990000;
|
|
24
|
-
font-size: 14px;
|
|
25
|
-
font-weight: bold;
|
|
26
|
-
padding: 4px 0 3px 25px;
|
|
27
|
-
background: white;
|
|
28
|
-
}
|
|
29
|
-
.testContainer {
|
|
30
|
-
padding: 12px;
|
|
31
|
-
}
|
|
32
|
-
</style>
|
|
1
|
+
Caterpillar <%= Caterpillar::VERSION %>
|
|
33
2
|
|
|
34
|
-
<
|
|
3
|
+
<hr />
|
|
35
4
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
<p style="font-size: 14px;">
|
|
39
|
-
These are isolated test cases of the Rails-portlet, for manual testing in the browser. The <%= link_to_exit_portlet 'source code', 'http://rails-portlet.rubyforge.org/svn/trunk/caterpillar/portlet_test_bench/' -%> can be used as a reference for using the same features in other Rails apps.
|
|
40
|
-
</p>
|
|
41
|
-
|
|
42
|
-
<h2>HTTP</h2>
|
|
43
|
-
<div class="testContainer">
|
|
44
|
-
|
|
45
|
-
<%= link_to 'URL parameter passing',
|
|
46
|
-
:controller => 'Caterpillar::HttpMethods', :action => :parameter -%><br />
|
|
47
|
-
|
|
48
|
-
<%= link_to 'HTTP POST form',
|
|
49
|
-
:controller => 'Caterpillar::HttpMethods', :action => :post -%><br />
|
|
50
|
-
|
|
51
|
-
<%= link_to 'HTTP POST and GET redirect',
|
|
52
|
-
:controller => 'Caterpillar::HttpMethods', :action => :post_and_redirect -%><br />
|
|
53
|
-
|
|
54
|
-
<%= link_to 'HTTP referer (back)',
|
|
55
|
-
:controller => 'Caterpillar::HttpMethods', :action => :back -%><br />
|
|
56
|
-
|
|
57
|
-
<%= link_to 'HTTP redirect',
|
|
58
|
-
:controller => 'Caterpillar::HttpMethods', :action => :redirect -%><br />
|
|
59
|
-
|
|
60
|
-
</div>
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
<h2>JavaScripts</h2>
|
|
64
|
-
<div class="testContainer">
|
|
65
|
-
|
|
66
|
-
<%= link_to 'Simple JavaScript',
|
|
67
|
-
:controller => 'Caterpillar::Js', :action => :simple -%><br />
|
|
68
|
-
|
|
69
|
-
<%= link_to 'Prototype JavaScript',
|
|
70
|
-
:controller => 'Caterpillar::Js', :action => :prototype -%><br />
|
|
71
|
-
|
|
72
|
-
<%= link_to 'Script.aculo.us JavaScript',
|
|
73
|
-
:controller => 'Caterpillar::Js', :action => :scriptaculous -%><br />
|
|
74
|
-
|
|
75
|
-
<%= link_to 'jQuery JavaScript',
|
|
76
|
-
:controller => 'Caterpillar::Js', :action => :jquery -%><br />
|
|
77
|
-
|
|
78
|
-
<%= link_to 'Drag and drop',
|
|
79
|
-
:controller => 'Caterpillar::Js', :action => :dragndrop -%><br />
|
|
80
|
-
|
|
81
|
-
<%= link_to 'link_to :method => :post',
|
|
82
|
-
:controller => 'Caterpillar::Js', :action => :link_to_post -%><br />
|
|
83
|
-
|
|
84
|
-
</div>
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
<h2>CSS</h2>
|
|
88
|
-
<div class="testContainer">
|
|
89
|
-
|
|
90
|
-
<%= link_to 'Simple CSS',
|
|
91
|
-
:controller => 'Caterpillar::Css', :action => :simple -%><br />
|
|
92
|
-
|
|
93
|
-
<%= link_to 'CSS background image',
|
|
94
|
-
:controller => 'Caterpillar::Css', :action => :background -%><br />
|
|
95
|
-
|
|
96
|
-
</div>
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
<h2>Misc</h2>
|
|
100
|
-
<div class="testContainer">
|
|
101
|
-
|
|
102
|
-
<%= link_to 'Image resources',
|
|
103
|
-
:controller => 'Caterpillar::Resource', :action => :images -%><br />
|
|
104
|
-
|
|
105
|
-
<%= link_to 'Inline text',
|
|
106
|
-
:controller => 'Caterpillar::Resource', :action => :inline -%><br />
|
|
107
|
-
|
|
108
|
-
<%= link_to 'Link outside the portlet',
|
|
109
|
-
:controller => 'Caterpillar::Resource', :action => :exit_portlet -%><br />
|
|
110
|
-
|
|
111
|
-
<%= link_to 'Liferay session variables',
|
|
112
|
-
url_for(
|
|
113
|
-
:controller => 'Caterpillar::Liferay',
|
|
114
|
-
:action => :session_variables
|
|
115
|
-
)+'/uid/%UID%/gid/%GID%'
|
|
116
|
-
-%><br />
|
|
117
|
-
|
|
118
|
-
<%= link_to 'Flash message',
|
|
119
|
-
:controller => 'Caterpillar::Session', :action => :flash_msg -%><br />
|
|
120
|
-
|
|
121
|
-
</div>
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
<h2>JUnit</h2>
|
|
125
|
-
|
|
126
|
-
The JUnit tests are used for automatic testing and they output XML.
|
|
127
|
-
|
|
128
|
-
<div class="testContainer">
|
|
129
|
-
|
|
130
|
-
<%= link_to 'Session cookie',
|
|
131
|
-
:controller => 'Caterpillar::Junit', :action => :session_cookie -%><br />
|
|
132
|
-
|
|
133
|
-
<%= link_to 'Redirect',
|
|
134
|
-
:controller => 'Caterpillar::Junit', :action => :redirect -%><br />
|
|
135
|
-
|
|
136
|
-
<%= link_to 'Session cookies & redirect',
|
|
137
|
-
:controller => 'Caterpillar::Junit', :action => :cookies_with_redirect -%><br />
|
|
138
|
-
|
|
139
|
-
</div>
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
</div>
|
|
143
|
-
</body>
|
|
5
|
+
Includes <%= link_to 'portlet test bench', portlet_test_bench_url %>.
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
<body>
|
|
2
|
+
<style type="text/css">
|
|
3
|
+
body {
|
|
4
|
+
background: white;
|
|
5
|
+
}
|
|
6
|
+
.testBenchContainer {
|
|
7
|
+
background: #FFFFCC;
|
|
8
|
+
border: 1px solid #B9B9B9;
|
|
9
|
+
padding: 8px;
|
|
10
|
+
font-size: 11px;
|
|
11
|
+
line-height: 15px;
|
|
12
|
+
}
|
|
13
|
+
.testBenchHeader {
|
|
14
|
+
border-bottom: 1px solid #B9B9B9;
|
|
15
|
+
color: #990000;
|
|
16
|
+
font-size: 18px;
|
|
17
|
+
font-weight: bold;
|
|
18
|
+
margin-bottom: 20px;
|
|
19
|
+
padding: 0 0 0 15px;
|
|
20
|
+
}
|
|
21
|
+
.testBenchSuite {
|
|
22
|
+
border: 1px solid #B9B9B9;
|
|
23
|
+
color: #990000;
|
|
24
|
+
font-size: 14px;
|
|
25
|
+
font-weight: bold;
|
|
26
|
+
padding: 4px 0 3px 25px;
|
|
27
|
+
background: white;
|
|
28
|
+
}
|
|
29
|
+
.testContainer {
|
|
30
|
+
padding: 12px;
|
|
31
|
+
}
|
|
32
|
+
</style>
|
|
33
|
+
|
|
34
|
+
<div class="testBenchContainer">
|
|
35
|
+
|
|
36
|
+
<div class="testBenchHeader">Rails-portlet test bench</div>
|
|
37
|
+
|
|
38
|
+
<p style="font-size: 14px;">
|
|
39
|
+
These are isolated test cases of the Rails-portlet, for manual testing in the browser. The <%= link_to_exit_portlet 'source code', 'http://rails-portlet.rubyforge.org/svn/trunk/caterpillar/portlet_test_bench/' -%> can be used as a reference for using the same features in other Rails apps.
|
|
40
|
+
</p>
|
|
41
|
+
|
|
42
|
+
<div class="testBenchSuite">HTTP</div>
|
|
43
|
+
<div class="testContainer">
|
|
44
|
+
|
|
45
|
+
<%= link_to 'URL parameter passing',
|
|
46
|
+
:controller => 'Caterpillar::HttpMethods', :action => :parameter -%><br />
|
|
47
|
+
|
|
48
|
+
<%= link_to 'HTTP POST form',
|
|
49
|
+
:controller => 'Caterpillar::HttpMethods', :action => :post -%><br />
|
|
50
|
+
|
|
51
|
+
<%= link_to 'HTTP POST and GET redirect',
|
|
52
|
+
:controller => 'Caterpillar::HttpMethods', :action => :post_and_redirect -%><br />
|
|
53
|
+
|
|
54
|
+
<%= link_to 'HTTP referer (back)',
|
|
55
|
+
:controller => 'Caterpillar::HttpMethods', :action => :back -%><br />
|
|
56
|
+
|
|
57
|
+
<%= link_to 'HTTP redirect',
|
|
58
|
+
:controller => 'Caterpillar::HttpMethods', :action => :redirect -%><br />
|
|
59
|
+
|
|
60
|
+
</div>
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
<div class="testBenchSuite">JavaScripts</div>
|
|
64
|
+
<div class="testContainer">
|
|
65
|
+
|
|
66
|
+
<%= link_to 'Simple JavaScript',
|
|
67
|
+
:controller => 'Caterpillar::Js', :action => :simple -%><br />
|
|
68
|
+
|
|
69
|
+
<%= link_to 'Prototype JavaScript',
|
|
70
|
+
:controller => 'Caterpillar::Js', :action => :prototype -%><br />
|
|
71
|
+
|
|
72
|
+
<%= link_to 'Script.aculo.us JavaScript',
|
|
73
|
+
:controller => 'Caterpillar::Js', :action => :scriptaculous -%><br />
|
|
74
|
+
|
|
75
|
+
<%= link_to 'jQuery JavaScript',
|
|
76
|
+
:controller => 'Caterpillar::Js', :action => :jquery -%><br />
|
|
77
|
+
|
|
78
|
+
<%= link_to 'Drag and drop',
|
|
79
|
+
:controller => 'Caterpillar::Js', :action => :dragndrop -%><br />
|
|
80
|
+
|
|
81
|
+
<%= link_to 'link_to :method => :post',
|
|
82
|
+
:controller => 'Caterpillar::Js', :action => :link_to_post -%><br />
|
|
83
|
+
|
|
84
|
+
</div>
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
<div class="testBenchSuite">CSS</div>
|
|
88
|
+
<div class="testContainer">
|
|
89
|
+
|
|
90
|
+
<%= link_to 'Simple CSS',
|
|
91
|
+
:controller => 'Caterpillar::Css', :action => :simple -%><br />
|
|
92
|
+
|
|
93
|
+
<%= link_to 'CSS background image',
|
|
94
|
+
:controller => 'Caterpillar::Css', :action => :background -%><br />
|
|
95
|
+
|
|
96
|
+
</div>
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
<div class="testBenchSuite">XHR</div>
|
|
100
|
+
<div class="testContainer">
|
|
101
|
+
|
|
102
|
+
<%= link_to 'Get time (Prototype)',
|
|
103
|
+
:controller => 'Caterpillar::Xhr', :action => :prototype -%><br />
|
|
104
|
+
|
|
105
|
+
<%= link_to 'Get time (jQuery)',
|
|
106
|
+
:controller => 'Caterpillar::Xhr', :action => :jquery -%><br />
|
|
107
|
+
|
|
108
|
+
</div>
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
<div class="testBenchSuite">Misc</div>
|
|
112
|
+
<div class="testContainer">
|
|
113
|
+
|
|
114
|
+
<%= link_to 'Image resources',
|
|
115
|
+
:controller => 'Caterpillar::Resource', :action => :images -%><br />
|
|
116
|
+
|
|
117
|
+
<%= link_to 'Inline text',
|
|
118
|
+
:controller => 'Caterpillar::Resource', :action => :inline -%><br />
|
|
119
|
+
|
|
120
|
+
<%= link_to 'Link outside the portlet',
|
|
121
|
+
:controller => 'Caterpillar::Resource', :action => :exit_portlet -%><br />
|
|
122
|
+
|
|
123
|
+
<%= link_to 'Liferay session variables',
|
|
124
|
+
url_for(
|
|
125
|
+
:controller => 'Caterpillar::Liferay',
|
|
126
|
+
:action => :session_variables
|
|
127
|
+
)+'/uid/%UID%/gid/%GID%'
|
|
128
|
+
-%><br />
|
|
129
|
+
|
|
130
|
+
<%= link_to 'Flash message',
|
|
131
|
+
:controller => 'Caterpillar::Session', :action => :flash_msg -%><br />
|
|
132
|
+
|
|
133
|
+
</div>
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
<div class="testBenchSuite">JUnit</div>
|
|
137
|
+
|
|
138
|
+
The JUnit tests are used for automatic testing and they output XML.
|
|
139
|
+
|
|
140
|
+
<div class="testContainer">
|
|
141
|
+
|
|
142
|
+
<%= link_to 'Session cookie',
|
|
143
|
+
:controller => 'Caterpillar::Junit', :action => :session_cookie -%><br />
|
|
144
|
+
|
|
145
|
+
<%= link_to 'Redirect',
|
|
146
|
+
:controller => 'Caterpillar::Junit', :action => :redirect -%><br />
|
|
147
|
+
|
|
148
|
+
<%= link_to 'Session cookies & redirect',
|
|
149
|
+
:controller => 'Caterpillar::Junit', :action => :cookies_with_redirect -%><br />
|
|
150
|
+
|
|
151
|
+
</div>
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
</div>
|
|
155
|
+
</body>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<% if @javascripts.include? 'prototype' %>
|
|
2
|
+
<h2>Prototype</h2>
|
|
3
|
+
<p>
|
|
4
|
+
<%= link_to_remote 'What time it is?', :update => 'result1', :url => {:action => 'get_time'} %>
|
|
5
|
+
</p>
|
|
6
|
+
<div id="result1"></div>
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
<% else %>
|
|
10
|
+
<h2>jQuery</h2>
|
|
11
|
+
<p>
|
|
12
|
+
<a href="#" id="jq_link">What time it is?</a>
|
|
13
|
+
<script type="text/javascript">
|
|
14
|
+
$('#jq_link').click(function(){
|
|
15
|
+
$.ajax({
|
|
16
|
+
url: "<%= url_for :action => 'get_time' %>",
|
|
17
|
+
type: 'POST',
|
|
18
|
+
data: '',
|
|
19
|
+
success: function(data) {
|
|
20
|
+
$('#result2').html(data);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
</script>
|
|
25
|
+
</p>
|
|
26
|
+
<div id="result2"></div>
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
<% end %>
|
data/test/portlets_test.rb
CHANGED
|
@@ -15,6 +15,13 @@ class PortletsTest < Caterpillar::TestCase # :nodoc:
|
|
|
15
15
|
# end
|
|
16
16
|
# end
|
|
17
17
|
|
|
18
|
+
def test_session
|
|
19
|
+
key = Caterpillar::Security.get_session_key()
|
|
20
|
+
assert_not_nil key
|
|
21
|
+
secret = Caterpillar::Security.get_secret()
|
|
22
|
+
assert_not_nil secret
|
|
23
|
+
end
|
|
24
|
+
|
|
18
25
|
def test_name
|
|
19
26
|
@portlets.each do |portlet|
|
|
20
27
|
assert_not_nil portlet[:name], '%s has no name' % portlet
|
data/test/xml_test.rb
CHANGED
|
@@ -15,6 +15,7 @@ class XmlTest < Caterpillar::TestCase # :nodoc:
|
|
|
15
15
|
@liferay_tld_table = {
|
|
16
16
|
'5.1.1' => '5.1.0',
|
|
17
17
|
'5.2.0' => '5.2.0',
|
|
18
|
+
'5.2.3' => '5.2.0',
|
|
18
19
|
'6.0.1' => '6.0.0'
|
|
19
20
|
}
|
|
20
21
|
end
|
|
@@ -70,8 +71,8 @@ class XmlTest < Caterpillar::TestCase # :nodoc:
|
|
|
70
71
|
@config.container.version = version
|
|
71
72
|
xml = @config.container.display_xml(@portlets)
|
|
72
73
|
|
|
73
|
-
|
|
74
|
-
|
|
74
|
+
dtd_v = xml[/liferay-display_(._._.)/,1]
|
|
75
|
+
assert_equal(tld.gsub('.','_'), dtd_v, 'Failed to create DTD with proper version')
|
|
75
76
|
|
|
76
77
|
# parse DTD
|
|
77
78
|
dtd_file = File.join(@dtd_dir,'liferay-display_%s.dtd' % tld.gsub('.','_'))
|
|
@@ -89,8 +90,8 @@ class XmlTest < Caterpillar::TestCase # :nodoc:
|
|
|
89
90
|
@liferay_tld_table.each_pair do |version,tld|
|
|
90
91
|
@config.container.version = version
|
|
91
92
|
xml = @config.container.portletapp_xml(@portlets)
|
|
92
|
-
|
|
93
|
-
|
|
93
|
+
dtd_v = xml[/liferay-portlet-app_(._._.)/,1]
|
|
94
|
+
assert_equal(tld.gsub('.','_'), dtd_v, 'Failed to create DTD with proper version')
|
|
94
95
|
|
|
95
96
|
# parse DTD
|
|
96
97
|
dtd_file = File.join(@dtd_dir,'liferay-portlet-app_%s.dtd' % tld.gsub('.','_'))
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: caterpillar
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 15
|
|
5
5
|
prerelease: false
|
|
6
6
|
segments:
|
|
7
7
|
- 1
|
|
8
8
|
- 4
|
|
9
|
-
-
|
|
10
|
-
version: 1.4.
|
|
9
|
+
- 4
|
|
10
|
+
version: 1.4.4
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- Mikael Lammentausta
|
|
@@ -15,7 +15,7 @@ autorequire:
|
|
|
15
15
|
bindir: bin
|
|
16
16
|
cert_chain: []
|
|
17
17
|
|
|
18
|
-
date: 2010-07-
|
|
18
|
+
date: 2010-07-07 00:00:00 +03:00
|
|
19
19
|
default_executable: caterpillar
|
|
20
20
|
dependencies:
|
|
21
21
|
- !ruby/object:Gem::Dependency
|
|
@@ -118,6 +118,7 @@ files:
|
|
|
118
118
|
- portlet_test_bench/controllers/caterpillar/resource_controller.rb
|
|
119
119
|
- portlet_test_bench/controllers/caterpillar/session_controller.rb
|
|
120
120
|
- portlet_test_bench/controllers/caterpillar/user_controller.rb
|
|
121
|
+
- portlet_test_bench/controllers/caterpillar/xhr_controller.rb
|
|
121
122
|
- portlet_test_bench/helpers/caterpillar/application_helper.rb
|
|
122
123
|
- portlet_test_bench/helpers/caterpillar/junit_helper.rb
|
|
123
124
|
- portlet_test_bench/README.rdoc
|
|
@@ -125,6 +126,7 @@ files:
|
|
|
125
126
|
- portlet_test_bench/routing.rb
|
|
126
127
|
- portlet_test_bench/views/caterpillar/application/_back_to_menu.html.erb
|
|
127
128
|
- portlet_test_bench/views/caterpillar/application/index.html.erb
|
|
129
|
+
- portlet_test_bench/views/caterpillar/application/portlet_test_bench.html.erb
|
|
128
130
|
- portlet_test_bench/views/caterpillar/css/background.html.erb
|
|
129
131
|
- portlet_test_bench/views/caterpillar/css/simple.html.erb
|
|
130
132
|
- portlet_test_bench/views/caterpillar/http_methods/back.html.erb
|
|
@@ -162,6 +164,7 @@ files:
|
|
|
162
164
|
- portlet_test_bench/views/caterpillar/session/cookie.html.erb
|
|
163
165
|
- portlet_test_bench/views/caterpillar/session/flash_display.html.erb
|
|
164
166
|
- portlet_test_bench/views/caterpillar/user/home.html.erb
|
|
167
|
+
- portlet_test_bench/views/caterpillar/xhr/time.html.erb
|
|
165
168
|
- portlet_test_bench/views/layouts/bare.html.erb
|
|
166
169
|
- portlet_test_bench/views/layouts/basic.html.erb
|
|
167
170
|
- test/dtd/liferay-display_5_1_0.dtd
|