lportal 1.0.0
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 +16 -0
- data/install.rb +1 -0
- data/lib/account.rb +16 -0
- data/lib/address.rb +25 -0
- data/lib/announcement.rb +5 -0
- data/lib/blog_post.rb +32 -0
- data/lib/bookmark.rb +10 -0
- data/lib/company.rb +43 -0
- data/lib/contact.rb +52 -0
- data/lib/counter.rb +4 -0
- data/lib/dl_file.rb +24 -0
- data/lib/dl_folder.rb +25 -0
- data/lib/emailaddress.rb +18 -0
- data/lib/group.rb +100 -0
- data/lib/ig/folder.rb +12 -0
- data/lib/ig/image.rb +35 -0
- data/lib/image.rb +11 -0
- data/lib/journal/article.rb +43 -0
- data/lib/journal/article_image.rb +4 -0
- data/lib/journal/article_resource.rb +23 -0
- data/lib/mb/category.rb +47 -0
- data/lib/mb/discussion.rb +16 -0
- data/lib/mb/message.rb +45 -0
- data/lib/mb/thread.rb +20 -0
- data/lib/organization.rb +26 -0
- data/lib/permission.rb +32 -0
- data/lib/phone.rb +33 -0
- data/lib/resource.rb +58 -0
- data/lib/resource_code.rb +13 -0
- data/lib/role.rb +19 -0
- data/lib/tag/asset.rb +34 -0
- data/lib/tag/entry.rb +46 -0
- data/lib/tag/property.rb +28 -0
- data/lib/user.rb +248 -0
- data/lib/usergroup.rb +23 -0
- data/lib/web/layout.rb +67 -0
- data/lib/web/layout_set.rb +37 -0
- data/lib/web/portlet.rb +43 -0
- data/lib/web/portlet_name.rb +6 -0
- data/lib/web/portlet_preferences.rb +42 -0
- data/lib/wiki/node.rb +21 -0
- data/lib/wiki/page.rb +29 -0
- data/lib/wiki/pageresource.rb +20 -0
- data/lportal.rb +9 -0
- data/test/unit/account_test.rb +20 -0
- data/test/unit/address_test.rb +8 -0
- data/test/unit/announcement_test.rb +8 -0
- data/test/unit/asset_test.rb +29 -0
- data/test/unit/bookmark_test.rb +8 -0
- data/test/unit/company_test.rb +60 -0
- data/test/unit/contact_test.rb +23 -0
- data/test/unit/dl_file_test.rb +8 -0
- data/test/unit/dl_folder_test.rb +8 -0
- data/test/unit/group_test.rb +76 -0
- data/test/unit/ig/folder_test.rb +8 -0
- data/test/unit/ig/image_test.rb +20 -0
- data/test/unit/image_test.rb +34 -0
- data/test/unit/journal/article_image_test.rb +8 -0
- data/test/unit/journal/article_resource_test.rb +20 -0
- data/test/unit/journal/article_test.rb +39 -0
- data/test/unit/mb/category_test.rb +35 -0
- data/test/unit/mb/discussion_test.rb +14 -0
- data/test/unit/mb/message_test.rb +46 -0
- data/test/unit/mb/thread_test.rb +21 -0
- data/test/unit/organization_test.rb +57 -0
- data/test/unit/permission_test.rb +33 -0
- data/test/unit/resource_code_test.rb +29 -0
- data/test/unit/resource_test.rb +49 -0
- data/test/unit/role_test.rb +22 -0
- data/test/unit/tag/entry_test.rb +35 -0
- data/test/unit/tag/property_test.rb +27 -0
- data/test/unit/user_group_test.rb +8 -0
- data/test/unit/user_test.rb +103 -0
- data/test/unit/usergroup_test.rb +33 -0
- data/test/unit/web/layout_set_test.rb +88 -0
- data/test/unit/web/layout_test.rb +91 -0
- data/test/unit/web/portlet_preferences_test.rb +47 -0
- data/test/unit/web/portlet_test.rb +33 -0
- data/test/unit/wiki/node_test.rb +8 -0
- data/test/unit/wiki/page_test.rb +8 -0
- metadata +146 -0
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class OrganizationTest < ActiveSupport::TestCase
|
4
|
+
def setup
|
5
|
+
@orgs = Organization.find :all
|
6
|
+
assert !@orgs.empty?
|
7
|
+
end
|
8
|
+
|
9
|
+
# each organization must belong to a company
|
10
|
+
def test_company
|
11
|
+
@orgs.each do |x|
|
12
|
+
assert !x.company.nil?
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
# # each group must belong to a creator
|
17
|
+
# def test_creator
|
18
|
+
# @orgs.each do |c|
|
19
|
+
# assert !c.creator.nil?
|
20
|
+
# end
|
21
|
+
# end
|
22
|
+
|
23
|
+
|
24
|
+
# organization's group (hive)
|
25
|
+
def test_hive
|
26
|
+
@orgs.each do |x|
|
27
|
+
group = x.hive
|
28
|
+
assert !group.nil?, "#{x.id} does not have a personal group"
|
29
|
+
|
30
|
+
# the group must have classnameid 10017 (com.liferay.portal.model.Organization)
|
31
|
+
assert group.classnameid == 10017, "#{x.id}'s personal group is not assigned to com.liferay.portal.model.Organization"
|
32
|
+
|
33
|
+
assert group.is_active?, "#{x.id}'s personal group is not active"
|
34
|
+
|
35
|
+
# there has to be layoutsets
|
36
|
+
assert !group.layoutsets.empty?, "#{x.id}'s personal group does not have layoutsets"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
def test_group
|
42
|
+
@orgs.each do |x|
|
43
|
+
|
44
|
+
assert !Group.find(:all, :conditions => "classnameid=10017 AND classpk=#{x.id}").empty?, "No group found with classnameid 10017 and classpk #{x.id}"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# each member have to belong to the same company than the organization
|
49
|
+
def test_members_companies
|
50
|
+
@orgs.each do |org|
|
51
|
+
org.members.each do |user|
|
52
|
+
assert user.company == org.company, "Member #{user.id} of organization #{org.id} does not belong to company #{org.company.id}"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class PermissionTest < ActiveSupport::TestCase
|
4
|
+
def setup
|
5
|
+
@permissions = Permission.find :all
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_company
|
9
|
+
@permissions.each do |x|
|
10
|
+
assert !x.company.nil?, "#{x.id} belongs to no companies"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_resource
|
15
|
+
@permissions.each do |p|
|
16
|
+
assert !p.resource.nil?, "#{p.id} belongs to no resource!"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_rigidity
|
21
|
+
# each role must exist!
|
22
|
+
roles = @permissions.map{|x| x.roles}.uniq
|
23
|
+
roles.each do |role|
|
24
|
+
assert !role.nil?, "Reference to non-existing user #{role.inspect}"
|
25
|
+
end
|
26
|
+
|
27
|
+
# each user must exist!
|
28
|
+
users = @permissions.map{|x| x.users}.uniq
|
29
|
+
users.each do |user|
|
30
|
+
assert !user.nil?, "Reference to non-existing user #{user.inspect}"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ResourceCodeTest < ActiveSupport::TestCase
|
4
|
+
def setup
|
5
|
+
@resourcecodes = ResourceCode.find :all
|
6
|
+
end
|
7
|
+
|
8
|
+
# each resourcecode must belong to a company
|
9
|
+
def test_company
|
10
|
+
@resourcecodes.each do |x|
|
11
|
+
assert !x.company.nil?, "#{x.id} belongs to no companies"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
# each resourcecode must have a scope
|
16
|
+
def test_scope
|
17
|
+
@resourcecodes.each do |x|
|
18
|
+
assert !x.scope.nil?, "#{x.id} has no scope"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_rigidity
|
23
|
+
# each resource must exist!
|
24
|
+
resources = @resourcecodes.map{|x| x.resources}.uniq
|
25
|
+
resources.each do |r|
|
26
|
+
assert !r.nil?, "Reference to non-existing resource #{r.inspect}"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ResourceTest < ActiveSupport::TestCase
|
4
|
+
def setup
|
5
|
+
@resources = Resource.find :all
|
6
|
+
end
|
7
|
+
|
8
|
+
# each resource must have a resourcecode
|
9
|
+
def test_codes
|
10
|
+
@resources.each do |x|
|
11
|
+
assert !x.code.nil?, "#{x.id} has no resourcecode"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_permissions
|
16
|
+
@resources.each do |x|
|
17
|
+
permissions = x.permissions
|
18
|
+
assert !permissions.empty?, "#{x.id} has no permissions"
|
19
|
+
permissions.each do |perm|
|
20
|
+
assert !perm.nil?, "#{x.id} refers to an undefined permission #{perm.inspect}"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_primkey
|
26
|
+
companies_ids = Company.find(:all).map{|x| x.id.to_s}
|
27
|
+
groups_ids = Group.find(:all).map{|x| x.id.to_s}
|
28
|
+
|
29
|
+
@resources.each do |x|
|
30
|
+
key = x.primkey
|
31
|
+
|
32
|
+
unless (companies_ids.include?(key) or groups_ids.include?(key))
|
33
|
+
content = x.content
|
34
|
+
assert !content.nil?, "Resource #{x.id}, primkey #{key} is not any known content type #{x.code.name}"
|
35
|
+
|
36
|
+
if key[/LAYOUT/]
|
37
|
+
assert !x.plid.nil?, "Improper LAYOUT resourcecode #{key} for #{x.id}"
|
38
|
+
assert !x.portletid.nil?, "Improper LAYOUT resourcecode #{key} for #{x.id}"
|
39
|
+
|
40
|
+
codename = key[/LAYOUT_([^_]*)/,1]
|
41
|
+
assert !codename.nil?, "Improper LAYOUT resourcecode #{key} for #{x.id}"
|
42
|
+
assert x.code.name == codename, "Codenames #{x.code.name} and #{codename} do not match for #{x.id}"
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class RoleTest < ActiveSupport::TestCase
|
4
|
+
def setup
|
5
|
+
@roles = Role.find :all
|
6
|
+
end
|
7
|
+
|
8
|
+
# each role must belong to a company
|
9
|
+
def test_company
|
10
|
+
@roles.each do |x|
|
11
|
+
assert !x.company.nil?, "#{x.id} belongs to no companies"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_rigidity
|
16
|
+
# each user must exist!
|
17
|
+
users = @roles.map{|x| x.users}.uniq
|
18
|
+
users.each do |user|
|
19
|
+
assert !user.nil?, "Reference to non-existing user #{user.inspect}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class TagTest < ActiveSupport::TestCase
|
4
|
+
def setup
|
5
|
+
@tags = Tag.find :all
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_name
|
9
|
+
@tags.each do |x|
|
10
|
+
assert !x.name.nil?, "#{x.id} has no name"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
# each tag must belong to a company
|
15
|
+
def test_company
|
16
|
+
@tags.each do |x|
|
17
|
+
assert !x.company.nil?, "#{x.id} (#{x.name}) belongs to no company"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_owner
|
22
|
+
@tags.each do |x|
|
23
|
+
assert !x.owner.nil?, "#{x.id} (#{x.name}) belongs to no user"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
# each asset must exist!
|
28
|
+
def test_asset
|
29
|
+
assets = @tags.map{|x| x.assets}.uniq
|
30
|
+
assets.each do |asset|
|
31
|
+
assert !asset.nil?, "Reference to non-existing asset #{asset.inspect}"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class Tag::PropertyTest < ActiveSupport::TestCase
|
4
|
+
def setup
|
5
|
+
@properties = Tag::Property.find :all
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_company
|
9
|
+
@properties.each do |x|
|
10
|
+
assert !x.company.nil?, "#{x.id} belongs to no companies"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_owner
|
15
|
+
@properties.each do |x|
|
16
|
+
assert !x.owner.nil?, "#{x.id} belongs to no user!"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_rigidity
|
21
|
+
# each asset must exist!
|
22
|
+
tags = @properties.map{|x| x.tag}.uniq
|
23
|
+
tags.each do |tag|
|
24
|
+
assert !tag.nil?, "Reference to non-existing tag #{tag.inspect}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class UserTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@users = User.find :all
|
7
|
+
end
|
8
|
+
|
9
|
+
# each user must have an account
|
10
|
+
def test_account
|
11
|
+
@users.each do |x|
|
12
|
+
# in the default liferay 5.0.1 DB, lax95 has no account
|
13
|
+
#assert !x.account.nil?, "#{x.screenname} has no account"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# each user must belong to a company
|
18
|
+
def test_company
|
19
|
+
@users.each do |x|
|
20
|
+
assert !x.company.nil?, "#{x.screenname} belongs to no companies"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# each user can belong to many organizations
|
25
|
+
def test_organization
|
26
|
+
@users.each do |x|
|
27
|
+
unless x.is_default?
|
28
|
+
assert !x.organizations.empty?, "#{x.screenname} belongs to no organizations"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# each user must have a contact
|
34
|
+
def test_contact
|
35
|
+
@users.each do |x|
|
36
|
+
assert !x.contact.nil?, "User #{x.screenname} does not have a contact"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_fullname
|
41
|
+
@users.each do |x|
|
42
|
+
assert !x.fullname.nil?
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# each user must have a personal group (hive)
|
47
|
+
def test_hive
|
48
|
+
@users.each do |x|
|
49
|
+
group = x.hive
|
50
|
+
assert !group.nil?, "#{x.id} does not have a personal group"
|
51
|
+
|
52
|
+
# the group must have classnameid 10034 (com.liferay.portal.model.User)
|
53
|
+
assert group.classnameid == 10034, "User's personal group is not assigned to com.liferay.portal.model.User"
|
54
|
+
|
55
|
+
# if user is active, hive is active, and vice versa
|
56
|
+
if x.is_active?
|
57
|
+
assert group.is_active?, "#{x.id}'s personal group is not active"
|
58
|
+
# there has to be layoutsets
|
59
|
+
assert !group.layoutsets.empty?, "#{x.id}'s personal group does not have layoutsets"
|
60
|
+
|
61
|
+
else
|
62
|
+
assert !group.is_active?, "#{x.id}'s personal group is active, while the user is not"
|
63
|
+
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_rigidity
|
69
|
+
# each group must exist!
|
70
|
+
groups = @users.map{|x| x.groups}.uniq
|
71
|
+
groups.each do |group|
|
72
|
+
assert !group.nil?, "Reference to non-existing group #{group.inspect}"
|
73
|
+
end
|
74
|
+
|
75
|
+
# each role must exist!
|
76
|
+
roles = @users.map{|x| x.roles}.uniq
|
77
|
+
roles.each do |role|
|
78
|
+
assert !role.nil?, "Reference to non-existing role #{role.inspect}"
|
79
|
+
end
|
80
|
+
|
81
|
+
# each permission must exist!
|
82
|
+
perms = @users.map{|x| x.permissions}.uniq
|
83
|
+
perms.each do |p|
|
84
|
+
assert !p.nil?, "Reference to non-existing permission #{p.inspect}"
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
# # each user must have a friendlyurl
|
89
|
+
# def test_friendlyurl
|
90
|
+
# @users.each do |x|
|
91
|
+
# assert !x.friendlyurl.nil?
|
92
|
+
# end
|
93
|
+
# end
|
94
|
+
|
95
|
+
|
96
|
+
# # test that user has subscribed tags
|
97
|
+
# def test_subscriptions
|
98
|
+
# tags = @mikael.subscriptions
|
99
|
+
# assert tags.include?(@vitamins)
|
100
|
+
# assert tags.include?(@dieting)
|
101
|
+
# end
|
102
|
+
|
103
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class UserusergroupTest < ActiveSupport::TestCase
|
4
|
+
def setup
|
5
|
+
@usergroups = usergroup.find :all
|
6
|
+
assert !@usergroups.empty?, "No usergroups"
|
7
|
+
end
|
8
|
+
|
9
|
+
# each usergroup must belong to a company
|
10
|
+
def test_company
|
11
|
+
@usergroups.each do |x|
|
12
|
+
assert !x.company.nil?, "#{x.id} belongs to no company"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
# each usergroup must belong to a company
|
17
|
+
def test_parent
|
18
|
+
@usergroups.each do |x|
|
19
|
+
unless x.parent == 0
|
20
|
+
assert !x.parent.nil?, "#{x.id} has no parent"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_usergroups
|
26
|
+
@usergroups.each do |x|
|
27
|
+
x.usergroups.each do |group|
|
28
|
+
assert group.nil?, "#{x.id} has_and_belongs_to an unknown group #{group.inspect}"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class Web::LayoutSetTest < ActiveSupport::TestCase
|
4
|
+
def setup
|
5
|
+
@sets = Web::LayoutSet.find :all
|
6
|
+
assert !@sets.empty?
|
7
|
+
end
|
8
|
+
|
9
|
+
# each layoutset must belong to a company
|
10
|
+
def test_company
|
11
|
+
@sets.each do |x|
|
12
|
+
assert !x.company.nil?, "#{x.id} belongs to no company"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
# def test_resource
|
17
|
+
# @sets.each do |x|
|
18
|
+
# assert !x.resource.nil?, "#{x.id} #{x.group.friendlyurl} belongs to no resource"
|
19
|
+
# end
|
20
|
+
# end
|
21
|
+
|
22
|
+
# each layoutset must belong to a group
|
23
|
+
def test_group
|
24
|
+
@sets.each do |x|
|
25
|
+
group = x.group
|
26
|
+
assert !group.nil?, "#{x.id} belongs to no group"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_public_layoutsets
|
31
|
+
@sets.each do |x|
|
32
|
+
group = x.group
|
33
|
+
assert !group.public_layoutset.nil?, "Group #{group.id} does not have a public layoutset"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_private_layoutsets
|
38
|
+
@sets.each do |x|
|
39
|
+
group = x.group
|
40
|
+
assert !group.private_layoutset.nil?, "Group #{group.id} does not have a private layoutset"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_rigidity
|
45
|
+
@sets.each do |x|
|
46
|
+
assert !x.is_public?.nil?
|
47
|
+
end
|
48
|
+
|
49
|
+
# each group must exist!
|
50
|
+
groups = @sets.map{|x| x.group}.uniq
|
51
|
+
groups.each do |group|
|
52
|
+
assert !group.nil?, "Reference to non-existing group #{group.inspect}"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_pagecount
|
57
|
+
@sets.each do |x|
|
58
|
+
gid=x.group.id
|
59
|
+
layouts = Web::Layout.find(:all, :conditions => "groupid=#{gid} AND privatelayout=#{x.privatelayout}" )
|
60
|
+
assert layouts.size == x.pagecount, "Pagecount does not match layouts on #{x.id} (#{(x.is_public? ? "public" : "private")}), should be #{layouts.size}, is #{x.pagecount}"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
# test /web/guest/home equivalent
|
65
|
+
def test_guest_layoutset
|
66
|
+
# identified by default user
|
67
|
+
group = User.find_by_defaultuser(true).hive # /guest
|
68
|
+
assert !group.nil?, "Default user does not have a home group"
|
69
|
+
|
70
|
+
# find all layoutsets
|
71
|
+
layoutsets = Web::LayoutSet.find(:all).collect {|x| x if( x.groupid==group.id ) }.compact
|
72
|
+
|
73
|
+
assert layoutsets.size > 0, "No defaultuser layoutsets found"
|
74
|
+
assert layoutsets.map{|x| x.is_public? }.include?(true), "No default public layoutset found"
|
75
|
+
|
76
|
+
# pick one public
|
77
|
+
web = layoutsets.map{|x| x if x.is_public? }.compact.first # /web
|
78
|
+
|
79
|
+
# layout
|
80
|
+
layout = Web::Layout.find( :first, :conditions => "groupid=#{web.group.id} AND layoutid=1 AND privatelayout=false" )
|
81
|
+
assert !layout.nil?, "Public layout with id 1 was not found for layoutset #{web.id} in group #{web.group.id}"
|
82
|
+
assert !layout.is_hidden?, "Public layout for layoutset #{web.id} is hidden"
|
83
|
+
end
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
# [com.liferay.portal.verify.VerifyImageGallery:67] WARN Unable to update tags asset for image 13993: No User exists with the primary key 13201
|
4
|
+
# [com.liferay.portal.verify.VerifyJournal:134] WARN Unable to update tags asset for article 11934: No User exists with the primary key 11373
|
5
|
+
|
6
|
+
|
7
|
+
class Web::LayoutTest < ActiveSupport::TestCase
|
8
|
+
def setup
|
9
|
+
@layouts = Web::Layout.find :all
|
10
|
+
assert !@layouts.empty?
|
11
|
+
end
|
12
|
+
|
13
|
+
# each layout must belong to a company
|
14
|
+
def test_company
|
15
|
+
@layouts.each do |x|
|
16
|
+
assert !x.company.nil?, "#{x} has no company"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
# each layout must belong to a group
|
21
|
+
def test_group
|
22
|
+
@layouts.each do |x|
|
23
|
+
assert !x.group.nil?, "#{x} has no group"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_rigidity
|
28
|
+
@layouts.each do |x|
|
29
|
+
assert !x.is_public?.nil?
|
30
|
+
end
|
31
|
+
|
32
|
+
# each group must exist!
|
33
|
+
groups = @layouts.map{|x| x.group}.uniq
|
34
|
+
groups.each do |group|
|
35
|
+
assert !group.nil?, "Reference to non-existing group #{group.inspect}"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# each layout must have layoutid within the group,
|
40
|
+
# there must be no duplicate layoutids
|
41
|
+
def test_layoutid
|
42
|
+
@layouts.each do |x|
|
43
|
+
assert !x.layoutid.nil?, "#{x} has no local layout number"
|
44
|
+
end
|
45
|
+
|
46
|
+
groupids = @layouts.map{|x| x.groupid}.uniq
|
47
|
+
groupids.each do |gid|
|
48
|
+
# find all group's layoutids
|
49
|
+
pub = Web::Layout.find(:all, :conditions => "groupid=#{gid} AND privatelayout=false").map{|x| x.layoutid}
|
50
|
+
priv = Web::Layout.find(:all, :conditions => "groupid=#{gid} AND privatelayout=true").map{|x| x.layoutid}
|
51
|
+
|
52
|
+
# they must have no overlapping ids
|
53
|
+
assert pub.uniq == pub, "Group #{gid} has duplicate public layoutids"
|
54
|
+
assert priv.uniq == priv, "Group #{gid} has duplicate private layoutids"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
# each layout must have a friendlyurl
|
59
|
+
def test_friendlyurl
|
60
|
+
@layouts.each do |x|
|
61
|
+
assert !x.friendlyurl.nil?, "#{x} has no friendlyurl"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
# each layout must have a name
|
66
|
+
def test_name
|
67
|
+
@layouts.each do |x|
|
68
|
+
assert !x.name.nil?, "#{x} has no name"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
# each layout must have a typesettings, and the defined portlets exist
|
73
|
+
def test_portlets
|
74
|
+
@layouts.each do |x|
|
75
|
+
assert !x.typesettings.nil?, "#{x} has no typesettings"
|
76
|
+
|
77
|
+
# check portlets
|
78
|
+
x.portletids.each do |id|
|
79
|
+
unless id[/INSTANCE/]
|
80
|
+
assert Web::Portlet.find_by_portletid(id), "#{x.id} defines portlet #{id} but it is not found in portlet"
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
# check instances
|
85
|
+
x.instanceids.each do |id|
|
86
|
+
assert Web::PortletPreferences.find_by_portletid(id), "#{x.id} defines portlet instance #{id} but it is not found in portletpreferences"
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class Web::PortletPreferencesTest < ActiveSupport::TestCase
|
4
|
+
def setup
|
5
|
+
@prefs = Web::PortletPreferences.find :all
|
6
|
+
end
|
7
|
+
|
8
|
+
# # each preference must belong to an owner
|
9
|
+
# def test_owner
|
10
|
+
# @prefs.each do |x|
|
11
|
+
# unless x.ownerid == 0
|
12
|
+
# assert !x.owner.nil?, "#{x.id} belongs to no owner"
|
13
|
+
# end
|
14
|
+
# end
|
15
|
+
# end
|
16
|
+
|
17
|
+
# each preference must define ownertype
|
18
|
+
def test_ownertype
|
19
|
+
@prefs.each do |x|
|
20
|
+
assert !x.ownertype.nil?, "#{x.id} defines no ownertype"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# each preference must belong to a layout
|
25
|
+
def test_layout
|
26
|
+
@prefs.each do |x|
|
27
|
+
unless x.plid == 0
|
28
|
+
assert !x.layout.nil?, "#{x.id} refers to non-existing layout #{x.plid}"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# each preference must have a portletid
|
34
|
+
def test_portletid
|
35
|
+
@prefs.each do |x|
|
36
|
+
assert !x.portletid.nil?, "#{x.id} has no portletid"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# there has to be a resource for each portletpreference
|
41
|
+
def test_resource
|
42
|
+
@prefs.each do |x|
|
43
|
+
assert !x.resource.nil?, "No resource with primkey #{x.primkey}"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class Web::PortletTest < ActiveSupport::TestCase
|
4
|
+
def setup
|
5
|
+
@portlets = Web::Portlet.find :all
|
6
|
+
end
|
7
|
+
|
8
|
+
# each portlet must belong to a company
|
9
|
+
def test_company
|
10
|
+
@portlets.each do |x|
|
11
|
+
assert !x.company.nil?, "#{x.id} belongs to no companies"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
# each role must exist
|
16
|
+
def test_roles
|
17
|
+
@portlets.each do |x|
|
18
|
+
roles = x.roles.split(",")
|
19
|
+
roles.each do |role|
|
20
|
+
role.gsub!(/^\ *|\ *$/,"") # clean leading and trailing spaces
|
21
|
+
assert Role.find_by_name(role), "Role \"#{role}\" does not exist"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# each portlet must have a resource
|
27
|
+
def test_resource
|
28
|
+
@portlets.each do |x|
|
29
|
+
assert !x.resource.nil?, "No resource with primkey #{x.primkey}"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|