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.
Files changed (81) hide show
  1. data/README +16 -0
  2. data/install.rb +1 -0
  3. data/lib/account.rb +16 -0
  4. data/lib/address.rb +25 -0
  5. data/lib/announcement.rb +5 -0
  6. data/lib/blog_post.rb +32 -0
  7. data/lib/bookmark.rb +10 -0
  8. data/lib/company.rb +43 -0
  9. data/lib/contact.rb +52 -0
  10. data/lib/counter.rb +4 -0
  11. data/lib/dl_file.rb +24 -0
  12. data/lib/dl_folder.rb +25 -0
  13. data/lib/emailaddress.rb +18 -0
  14. data/lib/group.rb +100 -0
  15. data/lib/ig/folder.rb +12 -0
  16. data/lib/ig/image.rb +35 -0
  17. data/lib/image.rb +11 -0
  18. data/lib/journal/article.rb +43 -0
  19. data/lib/journal/article_image.rb +4 -0
  20. data/lib/journal/article_resource.rb +23 -0
  21. data/lib/mb/category.rb +47 -0
  22. data/lib/mb/discussion.rb +16 -0
  23. data/lib/mb/message.rb +45 -0
  24. data/lib/mb/thread.rb +20 -0
  25. data/lib/organization.rb +26 -0
  26. data/lib/permission.rb +32 -0
  27. data/lib/phone.rb +33 -0
  28. data/lib/resource.rb +58 -0
  29. data/lib/resource_code.rb +13 -0
  30. data/lib/role.rb +19 -0
  31. data/lib/tag/asset.rb +34 -0
  32. data/lib/tag/entry.rb +46 -0
  33. data/lib/tag/property.rb +28 -0
  34. data/lib/user.rb +248 -0
  35. data/lib/usergroup.rb +23 -0
  36. data/lib/web/layout.rb +67 -0
  37. data/lib/web/layout_set.rb +37 -0
  38. data/lib/web/portlet.rb +43 -0
  39. data/lib/web/portlet_name.rb +6 -0
  40. data/lib/web/portlet_preferences.rb +42 -0
  41. data/lib/wiki/node.rb +21 -0
  42. data/lib/wiki/page.rb +29 -0
  43. data/lib/wiki/pageresource.rb +20 -0
  44. data/lportal.rb +9 -0
  45. data/test/unit/account_test.rb +20 -0
  46. data/test/unit/address_test.rb +8 -0
  47. data/test/unit/announcement_test.rb +8 -0
  48. data/test/unit/asset_test.rb +29 -0
  49. data/test/unit/bookmark_test.rb +8 -0
  50. data/test/unit/company_test.rb +60 -0
  51. data/test/unit/contact_test.rb +23 -0
  52. data/test/unit/dl_file_test.rb +8 -0
  53. data/test/unit/dl_folder_test.rb +8 -0
  54. data/test/unit/group_test.rb +76 -0
  55. data/test/unit/ig/folder_test.rb +8 -0
  56. data/test/unit/ig/image_test.rb +20 -0
  57. data/test/unit/image_test.rb +34 -0
  58. data/test/unit/journal/article_image_test.rb +8 -0
  59. data/test/unit/journal/article_resource_test.rb +20 -0
  60. data/test/unit/journal/article_test.rb +39 -0
  61. data/test/unit/mb/category_test.rb +35 -0
  62. data/test/unit/mb/discussion_test.rb +14 -0
  63. data/test/unit/mb/message_test.rb +46 -0
  64. data/test/unit/mb/thread_test.rb +21 -0
  65. data/test/unit/organization_test.rb +57 -0
  66. data/test/unit/permission_test.rb +33 -0
  67. data/test/unit/resource_code_test.rb +29 -0
  68. data/test/unit/resource_test.rb +49 -0
  69. data/test/unit/role_test.rb +22 -0
  70. data/test/unit/tag/entry_test.rb +35 -0
  71. data/test/unit/tag/property_test.rb +27 -0
  72. data/test/unit/user_group_test.rb +8 -0
  73. data/test/unit/user_test.rb +103 -0
  74. data/test/unit/usergroup_test.rb +33 -0
  75. data/test/unit/web/layout_set_test.rb +88 -0
  76. data/test/unit/web/layout_test.rb +91 -0
  77. data/test/unit/web/portlet_preferences_test.rb +47 -0
  78. data/test/unit/web/portlet_test.rb +33 -0
  79. data/test/unit/wiki/node_test.rb +8 -0
  80. data/test/unit/wiki/page_test.rb +8 -0
  81. metadata +146 -0
@@ -0,0 +1,42 @@
1
+ module Web
2
+ class PortletPreferences < ActiveRecord::Base
3
+ set_table_name :portletpreferences
4
+ set_primary_key :portletpreferencesid
5
+
6
+ public
7
+
8
+ belongs_to :layout,
9
+ :class_name => 'Web::Layout',
10
+ :foreign_key => 'plid'
11
+
12
+ belongs_to :owner,
13
+ :class_name => 'User',
14
+ :foreign_key => 'ownerid'
15
+
16
+ # primkey in resource_ table
17
+ def primkey
18
+ "#{self.plid}_LAYOUT_#{self.portletid}"
19
+ end
20
+
21
+ # argument plid is to comply API with Web::Portlet.resource
22
+ def resource(plid)
23
+ Resource.find_by_primkey(self.primkey)
24
+ # Resource.find(:all, :conditions => "primkey='#{self.primkey}'")
25
+ end
26
+
27
+ # loads the preferences XML structure to Ruby Hash
28
+ def preferences_
29
+ xml = REXML::Document.new(self.preferences)
30
+ preferences = []
31
+ xml.elements.each("portlet-preferences/preference") do |pref|
32
+ phash = {
33
+ :name => pref.elements["name"].text,
34
+ :value => (pref.elements["value"] ? pref.elements["value"].text : "")
35
+ }
36
+ preferences << phash
37
+ end
38
+ return preferences
39
+ end
40
+
41
+ end
42
+ end
data/lib/wiki/node.rb ADDED
@@ -0,0 +1,21 @@
1
+ module Wiki
2
+ class Node < ActiveRecord::Base
3
+ set_table_name :wikinode
4
+ set_primary_key :nodeid
5
+
6
+ # com.liferay.portlet.wiki.model.WikiNode
7
+ def liferay_class
8
+ 'com.liferay.portlet.wiki.model.WikiNode'
9
+ end
10
+
11
+ has_many :pages,
12
+ :class_name => "Wiki::Page",
13
+ :foreign_key => "nodeid"
14
+ alias :articles :pages
15
+
16
+ has_many :resources,
17
+ :class_name => "Wiki::PageResource",
18
+ :foreign_key => "nodeid"
19
+
20
+ end
21
+ end
data/lib/wiki/page.rb ADDED
@@ -0,0 +1,29 @@
1
+ module Wiki
2
+ class Page < ActiveRecord::Base
3
+ set_table_name :wikipage
4
+ set_primary_key :pageid
5
+
6
+ # com.liferay.portlet.wiki.model.WikiPage
7
+ def liferay_class
8
+ 'com.liferay.portlet.wiki.model.WikiPage'
9
+ end
10
+
11
+ # association to WikiNode
12
+ belongs_to :node,
13
+ :class_name => 'Wiki::Node',
14
+ :foreign_key => 'nodeid'
15
+
16
+ belongs_to :user,
17
+ :foreign_key => 'userid'
18
+ alias :writer :user
19
+
20
+ belongs_to :resource,
21
+ :class_name => 'Wiki::PageResource',
22
+ :foreign_key => 'resourceprimkey'
23
+
24
+ def asset
25
+ self.resource.asset
26
+ end
27
+
28
+ end
29
+ end
@@ -0,0 +1,20 @@
1
+ module Wiki
2
+ class PageResource < ActiveRecord::Base
3
+ set_table_name :wikipageresource
4
+ set_primary_key :resourceprimkey
5
+
6
+ # com.liferay.portlet.wiki.model.WikiPageResource
7
+ def liferay_class
8
+ 'com.liferay.portlet.wiki.model.WikiPageResource'
9
+ end
10
+
11
+ # association to WikiNode
12
+ belongs_to :node,
13
+ :class_name => "Wiki::Node",
14
+ :foreign_key => "nodeid"
15
+
16
+ has_one :asset,
17
+ :foreign_key => 'classpk'
18
+
19
+ end
20
+ end
data/lportal.rb ADDED
@@ -0,0 +1,9 @@
1
+ require 'find'
2
+ require 'active_record'
3
+
4
+ file = File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__
5
+ this_dir = File.dirname(File.expand_path(file))
6
+
7
+ Find.find(this_dir+'/lib') do |file|
8
+ require file unless FileTest.directory?(file)
9
+ end
@@ -0,0 +1,20 @@
1
+ require 'test_helper'
2
+
3
+ class AccountTest < ActiveSupport::TestCase
4
+ def setup
5
+ @accounts = Account.find :all
6
+ assert !@accounts.empty?, "No accounts found"
7
+ end
8
+
9
+ def test_company
10
+ @accounts.each do |x|
11
+ assert !x.company.nil?, "#{x.id} has no company"
12
+ end
13
+ end
14
+
15
+ def test_user
16
+ @accounts.each do |x|
17
+ assert !x.user.nil?, "#{x.id} has no user"
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,8 @@
1
+ require 'test_helper'
2
+
3
+ class AddressTest < ActiveSupport::TestCase
4
+ # Replace this with your real tests.
5
+ def test_truth
6
+ assert true
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ require 'test_helper'
2
+
3
+ class AnnouncementTest < ActiveSupport::TestCase
4
+ # Replace this with your real tests.
5
+ def test_truth
6
+ assert true
7
+ end
8
+ end
@@ -0,0 +1,29 @@
1
+ require 'test_helper'
2
+
3
+ class AssetTest < ActiveSupport::TestCase
4
+ def setup
5
+ @assets = Asset.find :all
6
+ end
7
+
8
+ # each asset's resource _must_ belong to a company
9
+ def test_company
10
+ @assets.each do |asset|
11
+ asset_company = asset.company
12
+ resource_company = asset.resource.company
13
+ assert !asset_company.nil?, "Asset #{asset.id} does not belong to any company"
14
+ assert !resource_company.nil?, "Asset's #{asset.id} resource #{asset.resource.id} does not belong to any company"
15
+ assert asset_company==resource_company, "Asset #{asset.id} and resource #{asset.resource.id} belong to a different company"
16
+ end
17
+ end
18
+
19
+ # def test_asset_types
20
+ # Asset.resource_types.each do |type|
21
+ # type.find(:all).each do |asset|
22
+ # assert !asset.resource.nil?
23
+ # assert asset.resource.asset == asset
24
+ # assert !asset.resource.liferay_class.nil?
25
+ # end
26
+ # end
27
+ # end
28
+
29
+ end
@@ -0,0 +1,8 @@
1
+ require 'test_helper'
2
+
3
+ class BookmarkTest < ActiveSupport::TestCase
4
+ # Replace this with your real tests.
5
+ def test_truth
6
+ assert true
7
+ end
8
+ end
@@ -0,0 +1,60 @@
1
+ require 'test_helper'
2
+
3
+ class CompanyTest < ActiveSupport::TestCase
4
+ def setup
5
+ @companies = Company.find :all
6
+ assert !@companies.empty?, "No companies found"
7
+ end
8
+
9
+ # each company must have an account
10
+ def test_account
11
+ @companies.each do |c|
12
+ assert !c.account.nil?, "#{c.id} has no account"
13
+ end
14
+ end
15
+
16
+ # each company must have contacts
17
+ def test_contacts
18
+ @companies.each do |c|
19
+ assert !c.contacts.empty?, "#{c.id} has no contacts"
20
+ end
21
+ end
22
+
23
+ # hmm?
24
+ def test_defaultuser
25
+ @companies.each do |c|
26
+ assert c.account.user.is_default?, "No default user for #{c.id}"
27
+ assert c.account.user.is_active?, "Default user account for #{c.id} is not active"
28
+ assert c.account.user.company == c, "Default user for #{c.id} has wrong company"
29
+ assert !c.account.user.account.nil?, "Default user for #{c.id} has no account"
30
+ end
31
+ end
32
+
33
+ # each company must have a webid
34
+ def test_webid
35
+ @companies.each do |c|
36
+ assert !c.webid.nil?, "#{c.id} has no webid"
37
+ end
38
+ end
39
+
40
+ # each company must have a virtualhost
41
+ def test_virtualhost
42
+ @companies.each do |c|
43
+ assert !c.virtualhost.nil?, "#{c.id} has no virtualhost"
44
+ end
45
+ end
46
+
47
+ # each company must have organization(s)
48
+ def test_virtualhost
49
+ @companies.each do |c|
50
+ assert !c.organizations.empty?, "#{c.id} has no organizations"
51
+ end
52
+ end
53
+
54
+ def test_resource
55
+ @companies.each do |x|
56
+ assert !x.resource.nil?, "#{x.id} has no resource"
57
+ end
58
+ end
59
+
60
+ end
@@ -0,0 +1,23 @@
1
+ require 'test_helper'
2
+
3
+ class ContactTest < ActiveSupport::TestCase
4
+ # Replace this with your real tests.
5
+ def setup
6
+ @contacts = Contact.find :all
7
+ assert !@contacts.empty?, "No contacts found"
8
+ end
9
+
10
+ # each company must have an account
11
+ def test_account
12
+ @contacts.each do |c|
13
+ assert !c.account.nil?, "#{c} has no account"
14
+ end
15
+ end
16
+
17
+ def test_user
18
+ @contacts.each do |x|
19
+ assert !x.user.nil?, "#{x} has no user"
20
+ end
21
+ end
22
+
23
+ end
@@ -0,0 +1,8 @@
1
+ require 'test_helper'
2
+
3
+ class DlFileTest < ActiveSupport::TestCase
4
+ # Replace this with your real tests.
5
+ def test_truth
6
+ assert true
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ require 'test_helper'
2
+
3
+ class DlFolderTest < ActiveSupport::TestCase
4
+ # Replace this with your real tests.
5
+ def test_truth
6
+ assert true
7
+ end
8
+ end
@@ -0,0 +1,76 @@
1
+ require 'test_helper'
2
+
3
+ class GroupTest < ActiveSupport::TestCase
4
+ def setup
5
+ @groups = Group.find :all
6
+ assert !@groups.empty?, "No groups"
7
+ end
8
+
9
+ # each group must belong to a company
10
+ def test_company
11
+ @groups.each do |x|
12
+ assert !x.company.nil?, "#{x.id} belongs to no company"
13
+ end
14
+ end
15
+
16
+ def test_organizations
17
+ @groups.each do |x|
18
+ x.organizations.each do |org|
19
+ assert organization.nil?, "#{x.id} has_and_belongs_to to unknown organization #{org.inspect}"
20
+ end
21
+ end
22
+ end
23
+
24
+ def test_roles
25
+ @groups.each do |x|
26
+ x.roles.each do |role|
27
+ assert role.nil?, "#{x.id} has_and_belongs_to an unknown role #{role.inspect}"
28
+ end
29
+ end
30
+ end
31
+
32
+ def test_permissions
33
+ @groups.each do |x|
34
+ x.permissions.each do |permission|
35
+ assert permission.nil?, "#{x.id} has_and_belongs_to an unknown permission #{permission.inspect}"
36
+ end
37
+ end
38
+ end
39
+
40
+ def test_usergroups
41
+ @groups.each do |x|
42
+ x.usergroups.each do |usergroup|
43
+ assert usergroup.nil?, "#{x.id} has_and_belongs_to an unknown usergroup #{usergroup.inspect}"
44
+ end
45
+ end
46
+ end
47
+
48
+ # each group must belong to a creator
49
+ def test_creator
50
+ @groups.each do |x|
51
+ assert !x.creator.nil?, "#{x.id} has no creator"
52
+ end
53
+ end
54
+
55
+ # each group must have a friendlyurl
56
+ def test_friendlyurl
57
+ @groups.each do |x|
58
+ assert !x.friendlyurl.nil?, "#{x.id} has no friendlyurl"
59
+ end
60
+ end
61
+
62
+ # each group must have one or more layouts
63
+ def test_layoutsets
64
+ @groups.each do |x|
65
+ assert !x.layoutsets.empty?, "#{x.id} has no layoutsets"
66
+ assert !(x.layoutsets.size > 2), "#{x.id} has more than 2 layoutsets"
67
+ end
68
+ end
69
+
70
+ def test_resource
71
+ @groups.each do |x|
72
+ assert !x.resource.nil?, "#{x.id} has no resource"
73
+ end
74
+ end
75
+
76
+ end
@@ -0,0 +1,8 @@
1
+ require 'test_helper'
2
+
3
+ class IG::FolderTest < ActiveSupport::TestCase
4
+ # Replace this with your real tests.
5
+ def test_truth
6
+ assert true
7
+ end
8
+ end
@@ -0,0 +1,20 @@
1
+ require 'test_helper'
2
+
3
+ class IG::ImageTest < ActiveSupport::TestCase
4
+ def setup
5
+ @igimages = IG::Image.find :all
6
+ end
7
+
8
+ def test_company
9
+ @igimages.each do |x|
10
+ assert !x.company.nil?, "#{x.id} belongs to no company"
11
+ end
12
+ end
13
+
14
+ def test_user
15
+ @igimages.each do |x|
16
+ assert !x.user.nil?, "#{x.id} belongs to no user!"
17
+ end
18
+ end
19
+
20
+ end
@@ -0,0 +1,34 @@
1
+ require 'test_helper'
2
+
3
+ class ImageTest < ActiveSupport::TestCase
4
+ def setup
5
+ @images = Image.find :all
6
+ end
7
+
8
+ def test_type
9
+ @images.each do |x|
10
+ assert !x.type_.nil?, "#{x.id} type is null"
11
+ end
12
+ end
13
+
14
+ def test_dimensions
15
+ @images.each do |x|
16
+ assert !x.width.nil? && !x.height.nil?, "#{x.id} has no width && height"
17
+ end
18
+ end
19
+
20
+ def test_size
21
+ @images.each do |x|
22
+ assert !x.size_.nil?, "#{x.id} size is null"
23
+ assert x.size_ > 0, "#{x.id} size is not positive"
24
+ end
25
+ end
26
+
27
+ def test_gallery
28
+ @images.each do |x|
29
+ igs = IG::Image.find(:first, :conditions => "smallimageid=#{x.id} OR largeimageid=#{x.id} OR custom1imageid=#{x.id} OR custom2imageid=#{x.id}")
30
+ assert !igs.nil?, "#{x.id} is not referenced in any igimage"
31
+ end
32
+ end
33
+
34
+ end
@@ -0,0 +1,8 @@
1
+ require 'test_helper'
2
+
3
+ class Journal::ArticleImageTest < ActiveSupport::TestCase
4
+ # Replace this with your real tests.
5
+ def test_truth
6
+ assert true
7
+ end
8
+ end
@@ -0,0 +1,20 @@
1
+ require 'test_helper'
2
+
3
+ class Journal::ArticleResourceTest < ActiveSupport::TestCase
4
+ def setup
5
+ @resources = Journal::ArticleResource.find :all
6
+ end
7
+
8
+ def test_group
9
+ @resources.each do |x|
10
+ assert !x.group.nil?, "#{x.id} belongs to no group!"
11
+ end
12
+ end
13
+
14
+ def test_article
15
+ @resources.each do |x|
16
+ assert !x.article.nil?, "#{x.id} has no article!"
17
+ end
18
+ end
19
+
20
+ end
@@ -0,0 +1,39 @@
1
+ require 'test_helper'
2
+
3
+ class Journal::ArticleTest < ActiveSupport::TestCase
4
+ def setup
5
+ @articles = Journal::Article.find :all
6
+ end
7
+
8
+ # each article must belong to a company
9
+ def test_company
10
+ @articles.each do |x|
11
+ assert !x.company.nil?, "#{x.id} belongs to no company"
12
+ end
13
+ end
14
+
15
+ def test_group
16
+ @articles.each do |x|
17
+ assert !x.group.nil?, "#{x.id} belongs to no group!"
18
+ end
19
+ end
20
+
21
+ def test_owner
22
+ @articles.each do |x|
23
+ assert !x.owner.nil?, "#{x.id} belongs to no user!"
24
+ end
25
+ end
26
+
27
+ def test_articleid
28
+ @articles.each do |x|
29
+ assert !x.articleid.nil?, "#{x.id} has no articleid!"
30
+ end
31
+ end
32
+
33
+ def test_resource
34
+ @articles.each do |x|
35
+ assert !x.resource.nil?, "#{x.id} belongs to no resource"
36
+ end
37
+ end
38
+
39
+ end
@@ -0,0 +1,35 @@
1
+ require 'test_helper'
2
+
3
+ class MB::CategoryTest < ActiveSupport::TestCase
4
+ def setup
5
+ @categories = MB::Category.find :all
6
+ end
7
+
8
+ # each article must belong to a company
9
+ def test_company
10
+ @categories.each do |x|
11
+ assert !x.company.nil?, "#{x.id} belongs to no company"
12
+ end
13
+ end
14
+
15
+ def test_group
16
+ @categories.each do |x|
17
+ assert !x.group.nil?, "#{x.id} belongs to no group!"
18
+ end
19
+ end
20
+
21
+ def test_user
22
+ @categories.each do |x|
23
+ assert !x.user.nil?, "#{x.id} belongs to no user!"
24
+ end
25
+ end
26
+
27
+ def test_parent
28
+ @categories.each do |x|
29
+ unless x.parentcategoryid == 0 then
30
+ assert !x.parent.nil?, "#{x.id} refers to parent category #{x.parentcategoryid} which does not exist"
31
+ end
32
+ end
33
+ end
34
+
35
+ end
@@ -0,0 +1,14 @@
1
+ require 'test_helper'
2
+
3
+ class MB::DiscussionTest < ActiveSupport::TestCase
4
+ def setup
5
+ @discussions = MB::Discussion.find :all
6
+ end
7
+
8
+ def test_thread
9
+ @discussions.each do |x|
10
+ assert !x.thread.nil?, "#{x.id} belongs to no thread"
11
+ end
12
+ end
13
+
14
+ end
@@ -0,0 +1,46 @@
1
+ require 'test_helper'
2
+
3
+ class MB::MessageTest < ActiveSupport::TestCase
4
+ def setup
5
+ @messages = MB::Message.find :all
6
+ end
7
+
8
+ def test_company
9
+ @messages.each do |x|
10
+ assert !x.company.nil?, "#{x.id} belongs to no company"
11
+ end
12
+ end
13
+
14
+ def test_user
15
+ @messages.each do |x|
16
+ assert !x.user.nil?, "#{x.id} belongs to no user!"
17
+ end
18
+ end
19
+
20
+ def test_category
21
+ @messages.each do |x|
22
+ assert !x.category.nil?, "#{x.id} belongs to no category!"
23
+ end
24
+ end
25
+
26
+ def test_thread
27
+ @messages.each do |x|
28
+ assert !x.thread.nil?, "#{x.id} belongs to no thread"
29
+ if x.parentmessageid == 0 then
30
+ assert x.thread.rootmessageid == x.id, "Discrepancy between thread #{x.thread.id} rootmessageid #{x.thread.rootmessageid} and message #{x.id}"
31
+ end
32
+ end
33
+ end
34
+
35
+ def test_parent
36
+ @messages.each do |x|
37
+ unless x.parentmessageid == 0 then
38
+ assert !x.parent.nil?, "#{x.id} refers to parent message #{x.parentmessageid} which does not exist"
39
+ else
40
+ # there must be a thread with this message as root!
41
+ assert MB::Thread.find(:all).map{|t| t.rootmessageid }.include?(x.id), " Message #{x.id} appears not to belong to any thread"
42
+ end
43
+ end
44
+ end
45
+
46
+ end
@@ -0,0 +1,21 @@
1
+ require 'test_helper'
2
+
3
+ class MB::ThreadTest < ActiveSupport::TestCase
4
+ def setup
5
+ @threads = MB::Thread.find :all
6
+ end
7
+
8
+ def test_category
9
+ @threads.each do |x|
10
+ assert !x.category.nil?, "#{x.id} belongs to no category"
11
+ end
12
+ end
13
+
14
+ def test_root
15
+ @threads.each do |x|
16
+ assert !x.root.nil?, "#{x.id} has no root message"
17
+ end
18
+ end
19
+
20
+
21
+ end