lportal 1.0.7 → 1.0.8
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/README +81 -10
- data/lib/blog_post.rb +7 -7
- data/lib/bookmark/entry.rb +4 -0
- data/lib/contact.rb +1 -1
- data/lib/dl_file.rb +1 -0
- data/lib/dl_folder.rb +4 -0
- data/lib/group.rb +183 -4
- data/lib/ig/image.rb +1 -0
- data/lib/journal/article_resource.rb +1 -0
- data/lib/mb/category.rb +168 -1
- data/lib/mb/message.rb +4 -0
- data/lib/resource_code.rb +12 -0
- data/lib/role.rb +169 -0
- data/lib/tag/asset.rb +16 -3
- data/lib/tag/entry.rb +1 -0
- data/lib/user.rb +136 -31
- data/lib/web/layout.rb +148 -0
- data/lib/web/portlet_preferences.rb +1 -1
- data/lib/web/typesettings.rb +113 -0
- data/lib/wiki/pageresource.rb +1 -0
- data/test/unit/blog_post_test.rb +6 -0
- data/test/unit/group_test.rb +111 -5
- data/test/unit/mb/category_test.rb +63 -1
- data/test/unit/phone_test.rb +33 -0
- data/test/unit/role_test.rb +127 -8
- data/test/unit/tag/asset_test.rb +24 -12
- data/test/unit/user_test.rb +189 -1
- data/test/unit/web/layout_test.rb +62 -6
- data/test/unit/web/typesettings_test.rb +54 -0
- data/version.rb +1 -1
- metadata +5 -2
@@ -0,0 +1,113 @@
|
|
1
|
+
module Web
|
2
|
+
# Typesettings for portlets. Used in Web::Layout.
|
3
|
+
class Typesettings
|
4
|
+
|
5
|
+
attr_accessor :template_id
|
6
|
+
attr_accessor :portlets
|
7
|
+
|
8
|
+
# Takes either existing raw typesettings string (to be parsed) or a Hash, when clean Typesettings is created.
|
9
|
+
def initialize(params={})
|
10
|
+
@portlets = {}
|
11
|
+
if params.is_a?(String)
|
12
|
+
self.read(params)
|
13
|
+
else
|
14
|
+
self.columns = (params[:columns] || 2)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
# Parses raw typesettings String into internal format.
|
19
|
+
def read(raw)
|
20
|
+
_x = raw.split(/\n/)
|
21
|
+
#puts _x.inspect
|
22
|
+
|
23
|
+
template_id = _x.find{|z| z[/layout-template-id.*/]}
|
24
|
+
if template_id
|
25
|
+
_x.delete_at(_x.index(template_id))
|
26
|
+
@template_id = template_id[/=(.*)/,1]
|
27
|
+
end
|
28
|
+
|
29
|
+
_x.each do |col|
|
30
|
+
@portlets[col[/-(.)=/,1].to_i] = col[/=(.*)/,1].split(/,/)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# Choose the number of columns in the Layout
|
35
|
+
def columns=(nr)
|
36
|
+
@template_id = (
|
37
|
+
case nr
|
38
|
+
when 1
|
39
|
+
'1_column'
|
40
|
+
when 2
|
41
|
+
'2_columns_ii'
|
42
|
+
else
|
43
|
+
raise 'Invalid column number'
|
44
|
+
end
|
45
|
+
)
|
46
|
+
end
|
47
|
+
|
48
|
+
# Output String
|
49
|
+
def to_s
|
50
|
+
s = ''
|
51
|
+
s << "layout-template-id=%s\n" % @template_id if @template_id
|
52
|
+
s << self.parse
|
53
|
+
return s
|
54
|
+
end
|
55
|
+
|
56
|
+
# Accepts a PortletName as the first parameter,
|
57
|
+
# the second parameter acceps a Hash {:column => nr} where nr is the column to place the portlet.
|
58
|
+
def method_missing(method, *args, &block)
|
59
|
+
begin
|
60
|
+
portlet = Web::PortletName.find_by_name(method.to_s)
|
61
|
+
return nil unless portlet
|
62
|
+
|
63
|
+
column = 1
|
64
|
+
if args.any?
|
65
|
+
if args.first[:column]
|
66
|
+
column = args.first[:column]
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
@portlets.update(column => [portlet.portletid])
|
71
|
+
|
72
|
+
rescue
|
73
|
+
STDERR.puts $!.message
|
74
|
+
STDERR.puts 'Have you installed Caterpillar?'
|
75
|
+
return nil
|
76
|
+
end
|
77
|
+
self
|
78
|
+
end
|
79
|
+
|
80
|
+
# Formulates the typesettings columns string for portlets
|
81
|
+
def parse
|
82
|
+
columns = []
|
83
|
+
@portlets.each_pair do |column,portlets|
|
84
|
+
columns << "column-%i=%s," % [column, portlets.join(",")]
|
85
|
+
end
|
86
|
+
columns.join("\n")
|
87
|
+
end
|
88
|
+
|
89
|
+
# Does this Typesettings include this portlet?
|
90
|
+
# Params:
|
91
|
+
# - portlet (either name as String, or Web::PortletName)
|
92
|
+
def include?(args)
|
93
|
+
if args.is_a?(String)
|
94
|
+
p = Web::PortletName.find_by_name args
|
95
|
+
elsif args.is_a?(Web::PortletName)
|
96
|
+
p = args
|
97
|
+
else
|
98
|
+
raise 'Invalid input class: %s' % args.class
|
99
|
+
end
|
100
|
+
|
101
|
+
#!@portlets_s[/[=,]#{p.portletid},/].nil?
|
102
|
+
|
103
|
+
# this may be handy if columns are needed
|
104
|
+
#_x = @portlets.find{|k,v| v.include?(p.portletid)}
|
105
|
+
#return false if _x.nil?
|
106
|
+
#column = _x.first[0]
|
107
|
+
#return true
|
108
|
+
|
109
|
+
@portlets.any?{|k,v| v.include?(p.portletid)}
|
110
|
+
end
|
111
|
+
|
112
|
+
end
|
113
|
+
end
|
data/lib/wiki/pageresource.rb
CHANGED
data/test/unit/blog_post_test.rb
CHANGED
data/test/unit/group_test.rb
CHANGED
@@ -1,11 +1,92 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
class GroupTest < ActiveSupport::TestCase
|
4
|
-
fixtures
|
4
|
+
fixtures [
|
5
|
+
:organization_,
|
6
|
+
:users_orgs,
|
7
|
+
:usergroup,
|
8
|
+
:role_,
|
9
|
+
:classname_
|
10
|
+
]
|
5
11
|
|
6
12
|
def setup
|
7
13
|
@groups = Group.find :all
|
8
14
|
assert !@groups.empty?, "No groups"
|
15
|
+
|
16
|
+
@company = Company.first
|
17
|
+
flunk 'No company!' unless @company
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_create_group
|
21
|
+
user = @company.administrators.first
|
22
|
+
flunk 'No user!' unless user
|
23
|
+
|
24
|
+
# Type Group
|
25
|
+
group = Group.create(
|
26
|
+
:name => 'Test',
|
27
|
+
:company => @company,
|
28
|
+
:creatoruserid => user.id
|
29
|
+
)
|
30
|
+
assert_not_nil group
|
31
|
+
|
32
|
+
assert_equal @company, group.company
|
33
|
+
assert_equal user.id, group.creatoruserid
|
34
|
+
assert_equal 0, group.classnameid
|
35
|
+
assert_equal 0, group.classpk
|
36
|
+
assert_equal 1, group.type_ # open
|
37
|
+
|
38
|
+
rc = group.resource_code(4)
|
39
|
+
assert_not_nil rc
|
40
|
+
r = Resource.find(:first, :conditions => "codeid=#{rc.id} AND primkey='#{group.id}'")
|
41
|
+
assert_not_nil r
|
42
|
+
|
43
|
+
group.class.actions.each do |actionid|
|
44
|
+
p = Permission.find(:first,
|
45
|
+
:conditions => "companyid=#{group.companyid} AND actionid='#{actionid}' AND resourceid=#{r.id}")
|
46
|
+
assert_not_nil p
|
47
|
+
|
48
|
+
# Permissions to administrators
|
49
|
+
group.company.administrators.each do |user|
|
50
|
+
assert user.user_permissions.include?(p)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_create_user_group
|
56
|
+
user = User.first
|
57
|
+
flunk 'No user!' unless user
|
58
|
+
|
59
|
+
# Type User
|
60
|
+
group = Group.create(
|
61
|
+
:company => user.company,
|
62
|
+
:creatoruserid => user.id,
|
63
|
+
:classnameid => Classname.find_by_value(User.liferay_class).id,
|
64
|
+
:classpk => user.id,
|
65
|
+
:friendlyurl => '/'+user.screenname
|
66
|
+
)
|
67
|
+
|
68
|
+
assert_not_nil group
|
69
|
+
|
70
|
+
assert_equal user.companyid, group.companyid
|
71
|
+
assert_equal user.id, group.creatoruserid
|
72
|
+
assert_equal Classname.find_by_value(User.liferay_class).id, group.classnameid
|
73
|
+
assert_equal user.id, group.classpk
|
74
|
+
assert_equal 0, group.parentgroupid
|
75
|
+
assert_equal 0, group.livegroupid
|
76
|
+
assert_equal 0, group.type_
|
77
|
+
assert_equal '/'+user.screenname, group.friendlyurl
|
78
|
+
assert group.is_active?
|
79
|
+
|
80
|
+
assert_not_nil group.public_layoutset
|
81
|
+
assert_not_nil group.private_layoutset
|
82
|
+
|
83
|
+
group.layoutsets.each do |ls|
|
84
|
+
assert_equal user.companyid, ls.companyid
|
85
|
+
assert_equal false, ls.logo
|
86
|
+
assert_equal 0, ls.logoid
|
87
|
+
assert_equal 0, ls.pagecount
|
88
|
+
end
|
89
|
+
|
9
90
|
end
|
10
91
|
|
11
92
|
# each group must belong to a company
|
@@ -64,15 +145,40 @@ class GroupTest < ActiveSupport::TestCase
|
|
64
145
|
# each group must have one or more layouts
|
65
146
|
def test_layoutsets
|
66
147
|
@groups.each do |x|
|
67
|
-
assert !x.layoutsets.empty?, "#{x.id} has no layoutsets"
|
68
|
-
assert !(x.layoutsets.size > 2), "#{x.id} has more than 2 layoutsets"
|
148
|
+
assert !x.layoutsets.empty?, "#{x.id} (#{x.name}) has no layoutsets"
|
149
|
+
assert !(x.layoutsets.size > 2), "#{x.id} (#{x.name}) has more than 2 layoutsets"
|
150
|
+
assert_not_nil x.public_layoutset
|
151
|
+
assert_not_nil x.private_layoutset
|
69
152
|
end
|
70
153
|
end
|
71
154
|
|
72
|
-
def
|
155
|
+
def test_members
|
73
156
|
@groups.each do |x|
|
74
|
-
|
157
|
+
if x.owner.kind_of?(Organization)
|
158
|
+
assert_equal x.owner.members, x.members
|
159
|
+
end
|
75
160
|
end
|
76
161
|
end
|
77
162
|
|
163
|
+
def test_path
|
164
|
+
@groups.each do |x|
|
165
|
+
if x.private_layouts.any?
|
166
|
+
assert_not_nil x.path(:private)
|
167
|
+
else
|
168
|
+
assert_nil x.path(:private)
|
169
|
+
end
|
170
|
+
if x.public_layouts.any?
|
171
|
+
assert_not_nil x.path(:public)
|
172
|
+
else
|
173
|
+
assert_nil x.path(:public)
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
# def test_resource
|
179
|
+
# @groups.each do |x|
|
180
|
+
# # assert !x.resource.nil?, "#{x.id} has no resource"
|
181
|
+
# end
|
182
|
+
# end
|
183
|
+
|
78
184
|
end
|
@@ -5,7 +5,10 @@ class MB::CategoryTest < ActiveSupport::TestCase
|
|
5
5
|
:mbcategory,
|
6
6
|
:mbdiscussion,
|
7
7
|
:mbmessage,
|
8
|
-
:mbthread
|
8
|
+
:mbthread,
|
9
|
+
:group_,
|
10
|
+
:layout,
|
11
|
+
:portlet_names
|
9
12
|
]
|
10
13
|
|
11
14
|
def setup
|
@@ -14,6 +17,55 @@ class MB::CategoryTest < ActiveSupport::TestCase
|
|
14
17
|
@categories.delete @rootcategory
|
15
18
|
end
|
16
19
|
|
20
|
+
def test_create
|
21
|
+
# find first user that has a personal group
|
22
|
+
user = nil
|
23
|
+
User.all.each do |user|
|
24
|
+
break if user.hive
|
25
|
+
end
|
26
|
+
group = user.hive
|
27
|
+
assert_not_nil group
|
28
|
+
|
29
|
+
category = MB::Category.create(
|
30
|
+
:name => 'Test',
|
31
|
+
:group => group,
|
32
|
+
:user => user
|
33
|
+
)
|
34
|
+
assert_not_nil category
|
35
|
+
|
36
|
+
assert_equal group, category.group
|
37
|
+
assert_equal user, category.user
|
38
|
+
assert_equal user.fullname, category.username
|
39
|
+
assert_equal 0, category.parentcategoryid
|
40
|
+
|
41
|
+
# ResourceCode with scope 1 => Resource for Company
|
42
|
+
# ResourceCode with scope 2 => Resource for this Group and Guest's Group
|
43
|
+
# ResourceCode with scope 4 => Resource for self
|
44
|
+
|
45
|
+
rc = category.resource_code(1)
|
46
|
+
assert_not_nil rc
|
47
|
+
assert_not_nil Resource.find(:first,
|
48
|
+
:conditions => "codeid=#{rc.id} AND primkey='#{group.companyid}'")
|
49
|
+
|
50
|
+
rc = category.resource_code(2)
|
51
|
+
assert_not_nil rc
|
52
|
+
assert_not_nil Resource.find(:first,
|
53
|
+
:conditions => "codeid=#{rc.id} AND primkey='#{group.id}'")
|
54
|
+
|
55
|
+
rc = category.resource_code(4)
|
56
|
+
assert_not_nil rc
|
57
|
+
resource = Resource.find(:first,
|
58
|
+
:conditions => "codeid=#{rc.id} AND primkey='#{category.id}'")
|
59
|
+
assert_not_nil resource
|
60
|
+
|
61
|
+
category.class.actions.each do |actionid|
|
62
|
+
p = Permission.find(:first,
|
63
|
+
:conditions => "companyid=#{category.companyid} AND actionid='#{actionid}' AND resourceid=#{resource.id}")
|
64
|
+
assert_not_nil p
|
65
|
+
assert user.user_permissions.include?(p)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
17
69
|
# each article must belong to a company
|
18
70
|
def test_company
|
19
71
|
@categories.each do |x|
|
@@ -48,4 +100,14 @@ class MB::CategoryTest < ActiveSupport::TestCase
|
|
48
100
|
assert_equal 0, @rootcategory.parentcategoryid
|
49
101
|
end
|
50
102
|
|
103
|
+
def test_path
|
104
|
+
@categories.each do |x|
|
105
|
+
if x.group.layouts_include?('message_boards')
|
106
|
+
assert_not_nil x.path
|
107
|
+
else
|
108
|
+
assert_nil x.path
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
51
113
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class PhoneTest < ActiveSupport::TestCase
|
4
|
+
fixtures [
|
5
|
+
:company,
|
6
|
+
:user_,
|
7
|
+
:phone,
|
8
|
+
:contact_,
|
9
|
+
:classname_,
|
10
|
+
:listtype
|
11
|
+
]
|
12
|
+
|
13
|
+
def setup
|
14
|
+
@phones = Phone.all
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_phones
|
18
|
+
@phones.each do |phone|
|
19
|
+
assert_not_nil phone.company
|
20
|
+
assert_not_nil phone.user
|
21
|
+
assert_equal phone.company, phone.user.company
|
22
|
+
|
23
|
+
classnameid = Classname.find_by_value('com.liferay.portal.model.Contact').id
|
24
|
+
assert_equal classnameid, phone.classnameid
|
25
|
+
|
26
|
+
assert_equal phone.user.contact.id, phone.classpk
|
27
|
+
|
28
|
+
# mobile = ListType.find_by_name('Mobile').id
|
29
|
+
# assert_equal mobile, phone.typeid
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
data/test/unit/role_test.rb
CHANGED
@@ -1,24 +1,143 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
class RoleTest < ActiveSupport::TestCase
|
4
|
-
fixtures
|
4
|
+
fixtures [
|
5
|
+
:role_,
|
6
|
+
:users_roles,
|
7
|
+
:groups_roles,
|
8
|
+
:permission_,
|
9
|
+
:users_permissions,
|
10
|
+
:groups_permissions,
|
11
|
+
:resource_,
|
12
|
+
:resourcecode
|
13
|
+
]
|
5
14
|
|
6
15
|
def setup
|
7
16
|
@roles = Role.all
|
17
|
+
@company = Company.first
|
18
|
+
flunk 'No company!' unless @company
|
8
19
|
end
|
9
20
|
|
21
|
+
def test_create
|
22
|
+
name = 'Regular role'
|
23
|
+
description = 'test'
|
24
|
+
|
25
|
+
role = Role.create(
|
26
|
+
:company => @company,
|
27
|
+
:name => name,
|
28
|
+
:description => description
|
29
|
+
)
|
30
|
+
role.reload
|
31
|
+
|
32
|
+
assert_equal @company, role.company
|
33
|
+
assert_equal name, role.name
|
34
|
+
assert_equal description, role.description
|
35
|
+
assert_equal 0, role.classnameid
|
36
|
+
assert_equal 0, role.classpk
|
37
|
+
assert_equal 1, role.type_
|
38
|
+
|
39
|
+
# ResourceCode & Resource
|
40
|
+
rc = role.resource_code(1)
|
41
|
+
assert_not_nil rc
|
42
|
+
r = Resource.find(:first, :conditions => "codeid=#{rc.id} AND primkey='#{role.companyid}'")
|
43
|
+
assert_not_nil r
|
44
|
+
|
45
|
+
rc = role.resource_code(4)
|
46
|
+
assert_not_nil rc
|
47
|
+
r = Resource.find(:first, :conditions => "codeid=#{rc.id} AND primkey='#{role.id}'")
|
48
|
+
assert_not_nil r
|
49
|
+
|
50
|
+
role.class.actions.each do |actionid|
|
51
|
+
p = Permission.find(:first,
|
52
|
+
:conditions => "companyid=#{role.companyid} AND actionid='#{actionid}' AND resourceid=#{r.id}")
|
53
|
+
assert_not_nil p
|
54
|
+
|
55
|
+
# Permissions to administrators
|
56
|
+
role.company.administrators.each do |user|
|
57
|
+
assert user.user_permissions.include?(p)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_destroy
|
63
|
+
Role.all.each do |role|
|
64
|
+
rc = role.resource_code(4)
|
65
|
+
|
66
|
+
company = role.company
|
67
|
+
users = role.users
|
68
|
+
groups = role.groups
|
69
|
+
|
70
|
+
role.destroy
|
71
|
+
|
72
|
+
users.each do |user|
|
73
|
+
assert !user.roles.include?(role)
|
74
|
+
end
|
75
|
+
|
76
|
+
groups.each do |group|
|
77
|
+
assert !group.roles.include?(role)
|
78
|
+
end
|
79
|
+
|
80
|
+
assert_raise(ActiveRecord::RecordNotFound) { role.reload }
|
81
|
+
|
82
|
+
|
83
|
+
next unless rc
|
84
|
+
r = Resource.find(:first, :conditions => "codeid=#{rc.id} AND primkey='#{role.id}'")
|
85
|
+
next unless r
|
86
|
+
|
87
|
+
%w{
|
88
|
+
ASSIGN_MEMBERS
|
89
|
+
DEFINE_PERMISSIONS
|
90
|
+
DELETE
|
91
|
+
MANAGE_ANNOUNCEMENTS
|
92
|
+
PERMISSIONS
|
93
|
+
UPDATE
|
94
|
+
VIEW }.each do |actionid|
|
95
|
+
p = Permission.find(:first,
|
96
|
+
:conditions => "companyid=#{company.id} AND actionid='#{actionid}' AND resourceid=#{r.id}")
|
97
|
+
assert_nil p
|
98
|
+
|
99
|
+
# User + group permissions
|
100
|
+
users.each do |user|
|
101
|
+
assert !user.user_permissions.include?(p)
|
102
|
+
end
|
103
|
+
groups.each do |group|
|
104
|
+
assert !group.permissions.include?(p)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
assert_raise(ActiveRecord::RecordNotFound) { r.reload }
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
|
10
112
|
# each role must belong to a company
|
11
113
|
def test_company
|
12
|
-
@roles.each do |
|
13
|
-
assert_not_nil
|
114
|
+
@roles.each do |r|
|
115
|
+
assert_not_nil r.company, "#{r.id} belongs to no companies"
|
14
116
|
end
|
15
117
|
end
|
16
118
|
|
17
|
-
def
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
119
|
+
def test_users
|
120
|
+
@roles.each do |r|
|
121
|
+
r.users.each do |user|
|
122
|
+
assert_not_nil user
|
123
|
+
end
|
22
124
|
end
|
23
125
|
end
|
126
|
+
|
127
|
+
def test_groups
|
128
|
+
@roles.each do |r|
|
129
|
+
r.groups.each do |group|
|
130
|
+
assert_not_nil group
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
def test_permissions
|
136
|
+
@roles.each do |r|
|
137
|
+
r.permissions.each do |permission|
|
138
|
+
assert_not_nil permission
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
24
143
|
end
|
data/test/unit/tag/asset_test.rb
CHANGED
@@ -18,40 +18,52 @@ class Tag::AssetTest < ActiveSupport::TestCase
|
|
18
18
|
@assets = Tag::Asset.all
|
19
19
|
end
|
20
20
|
|
21
|
-
|
22
|
-
def test_company
|
21
|
+
def test_resource
|
23
22
|
@assets.each do |asset|
|
24
23
|
assert_not_nil asset.company
|
25
|
-
end
|
26
|
-
end
|
27
24
|
|
28
|
-
# each asset's resource _must_ belong to a company
|
29
|
-
def test_resource
|
30
|
-
@assets.each do |asset|
|
31
25
|
classname = Classname.find(asset.classnameid).value
|
26
|
+
assert_not_nil classname
|
27
|
+
|
32
28
|
resource = asset.resource
|
29
|
+
assert_not_nil resource
|
30
|
+
|
31
|
+
assert_equal asset.company, resource.company
|
33
32
|
|
34
33
|
assert_not_nil resource.liferay_class, '%s has not defined its Java class' % resource.class
|
35
34
|
assert_equal classname,resource.liferay_class, 'Asset %i' % asset.id
|
36
35
|
|
37
|
-
assert_not_nil resource.
|
36
|
+
#assert_not_nil resource.content
|
37
|
+
end
|
38
|
+
end
|
38
39
|
|
39
|
-
|
40
|
+
def test_label
|
41
|
+
@assets.each do |asset|
|
42
|
+
assert_not_nil asset.label
|
43
|
+
assert_not_equal '', asset.label
|
44
|
+
assert_equal asset.title, asset.label unless asset.title.empty?
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_owner
|
49
|
+
@assets.each do |asset|
|
50
|
+
assert_not_nil asset.owner
|
51
|
+
assert_equal User, asset.owner.class
|
40
52
|
end
|
41
53
|
end
|
42
54
|
|
43
55
|
def test_asset_types
|
44
|
-
Asset.resource_types.each do |type|
|
56
|
+
Tag::Asset.resource_types.each do |type|
|
45
57
|
type.find(:all).each do |obj|
|
46
58
|
if defined? obj.asset
|
47
|
-
assert_not_nil obj.asset
|
59
|
+
assert_not_nil obj.asset, '%s (%i) has no Tag::Asset' % [obj.class, obj.id]
|
48
60
|
|
49
61
|
# problems with versioned wiki and journal pages..
|
50
62
|
unless obj.class==Wiki::Page or obj.class==Journal::Article
|
51
63
|
assert_equal obj,obj.asset.resource
|
52
64
|
end
|
53
65
|
else
|
54
|
-
|
66
|
+
STDERR.puts '%s has no asset relation' % obj.class
|
55
67
|
end
|
56
68
|
|
57
69
|
assert_not_nil obj.liferay_class, '%s has not defined its Java class' % obj.class
|