lportal 1.0.18 → 1.0.19

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. data/ChangeLog +5 -9
  2. data/Rakefile +12 -1
  3. data/db_connection.rb +9 -0
  4. data/lib/country.rb +5 -0
  5. data/lib/group.rb +2 -1
  6. data/lib/web/layout.rb +2 -3
  7. data/lportal.rb +8 -17
  8. data/rails_gem_chooser.rb +87 -0
  9. data/test/unit/account_test.rb +7 -4
  10. data/test/unit/address_test.rb +22 -1
  11. data/test/unit/announcement/delivery_test.rb +24 -0
  12. data/test/unit/announcement/entry_test.rb +4 -2
  13. data/test/unit/blog_post_test.rb +16 -4
  14. data/test/unit/bookmark/entry_test.rb +11 -2
  15. data/test/unit/bookmark/folder_test.rb +20 -2
  16. data/test/unit/calevent_test.rb +9 -2
  17. data/test/unit/company_test.rb +93 -29
  18. data/test/unit/contact_test.rb +12 -5
  19. data/test/unit/country_test.rb +25 -0
  20. data/test/unit/dl_file_test.rb +12 -6
  21. data/test/unit/dl_folder_test.rb +33 -4
  22. data/test/unit/emailaddress_test.rb +28 -0
  23. data/test/unit/group_test.rb +54 -27
  24. data/test/unit/ig/folder_test.rb +4 -2
  25. data/test/unit/ig/image_test.rb +10 -2
  26. data/test/unit/image_test.rb +12 -4
  27. data/test/unit/journal/article_image_test.rb +8 -6
  28. data/test/unit/journal/article_resource_test.rb +9 -5
  29. data/test/unit/journal/article_test.rb +24 -17
  30. data/test/unit/journal/feed_test.rb +31 -4
  31. data/test/unit/journal/structure_test.rb +31 -4
  32. data/test/unit/journal/template_test.rb +31 -4
  33. data/test/unit/mb/category_test.rb +44 -8
  34. data/test/unit/mb/discussion_test.rb +10 -5
  35. data/test/unit/mb/message_flag_test.rb +28 -0
  36. data/test/unit/mb/message_test.rb +22 -13
  37. data/test/unit/mb/stats_user_test.rb +28 -0
  38. data/test/unit/mb/thread_test.rb +10 -5
  39. data/test/unit/organization_test.rb +32 -8
  40. data/test/unit/permission_test.rb +45 -6
  41. data/test/unit/phone_test.rb +13 -7
  42. data/test/unit/poll/question_test.rb +30 -4
  43. data/test/unit/ratings_stats_test.rb +16 -0
  44. data/test/unit/release_test.rb +5 -3
  45. data/test/unit/resource_code_test.rb +5 -2
  46. data/test/unit/resource_test.rb +40 -19
  47. data/test/unit/role_test.rb +17 -9
  48. data/test/unit/social_activity_test.rb +35 -0
  49. data/test/unit/social_relation_test.rb +29 -0
  50. data/test/unit/tag/asset_test.rb +29 -15
  51. data/test/unit/tag/entry_test.rb +14 -4
  52. data/test/unit/tag/property_test.rb +14 -6
  53. data/test/unit/user_test.rb +86 -57
  54. data/test/unit/usergroup_test.rb +8 -5
  55. data/test/unit/web/layout_set_test.rb +21 -6
  56. data/test/unit/web/layout_test.rb +51 -20
  57. data/test/unit/web/portlet_preferences_test.rb +10 -2
  58. data/test/unit/web/portlet_properties_test.rb +10 -2
  59. data/test/unit/web/portlet_test.rb +12 -3
  60. data/test/unit/web/typesettings_test.rb +7 -3
  61. data/test/unit/wiki/node_test.rb +3 -2
  62. data/test/unit/wiki/page_test.rb +48 -2
  63. data/version.rb +1 -1
  64. metadata +186 -105
@@ -1,18 +1,24 @@
1
- require 'test_helper'
1
+ # encoding: utf-8
2
+
3
+ require 'test/test_helper'
2
4
 
3
5
  class PhoneTest < ActiveSupport::TestCase
4
6
  fixtures [
5
- :company,
6
- :user_,
7
- :phone,
8
- :contact_,
9
- :classname_,
10
- :listtype
7
+ :Company,
8
+ :User_,
9
+ :Phone,
10
+ :Contact_,
11
+ :ClassName_,
12
+ :ListType
11
13
  ]
12
14
 
13
15
  def setup
14
16
  @phones = Phone.all
15
17
  end
18
+
19
+ def test_create
20
+ flunk 'todo'
21
+ end
16
22
 
17
23
  def test_phones
18
24
  @phones.each do |phone|
@@ -1,8 +1,34 @@
1
- require 'test_helper'
1
+ # encoding: utf-8
2
+
3
+ require 'test/test_helper'
2
4
 
3
5
  class Poll::QuestionTest < ActiveSupport::TestCase
4
- # Replace this with your real tests.
5
- def test_truth
6
- assert true
6
+ fixtures [
7
+ :Company,
8
+ :User_,
9
+ :Group_,
10
+ :PollsQuestion
11
+ ]
12
+
13
+ def setup
14
+ @qs = Journal::Feed.all
15
+ end
16
+
17
+ def test_company
18
+ @qs.each do |x|
19
+ assert_not_nil x.company
20
+ end
21
+ end
22
+
23
+ def test_group
24
+ @qs.each do |x|
25
+ assert_not_nil x.group
26
+ end
27
+ end
28
+
29
+ def test_user
30
+ @qs.each do |x|
31
+ assert_not_nil x.user
32
+ end
7
33
  end
8
34
  end
@@ -0,0 +1,16 @@
1
+ # encoding: utf-8
2
+
3
+ require 'test/test_helper'
4
+
5
+ class RatingsStatsTest < ActiveSupport::TestCase
6
+ # fixtures [
7
+ # :Company,
8
+ # :User_,
9
+ # :Group_,
10
+ # :RatingsStats
11
+ # ]
12
+ #
13
+ # def setup
14
+ # @stats = RatingsStats.all
15
+ # end
16
+ end
@@ -1,7 +1,9 @@
1
- require 'test_helper'
1
+ # encoding: utf-8
2
+
3
+ require 'test/test_helper'
2
4
 
3
5
  class ReleaseTest < ActiveSupport::TestCase
4
- fixtures :release_
6
+ fixtures :Release_
5
7
 
6
8
  def test_releases
7
9
  releases = Release.all
@@ -19,7 +21,7 @@ class ReleaseTest < ActiveSupport::TestCase
19
21
 
20
22
  Lportal::Schema.buildnumber = 5100
21
23
  assert_equal 5100, Lportal::Schema.buildnumber
22
- assert_equal '5.1', Lportal::Schema.version
24
+ assert_equal '5.1.0', Lportal::Schema.version
23
25
  end
24
26
 
25
27
  end
@@ -1,8 +1,11 @@
1
- require 'test_helper'
1
+ # encoding: utf-8
2
+
3
+ require 'test/test_helper'
2
4
 
3
5
  class ResourceCodeTest < ActiveSupport::TestCase
4
6
  fixtures [
5
- :resource_, :resourcecode,
7
+ :Company,
8
+ :Resource_, :ResourceCode
6
9
  ]
7
10
 
8
11
  def setup
@@ -1,31 +1,52 @@
1
- require 'test_helper'
1
+ # encoding: utf-8
2
+
3
+ require 'test/test_helper'
2
4
 
3
5
  class ResourceTest < ActiveSupport::TestCase
4
6
  fixtures [
5
- :resource_, :resourcecode,
6
- :igimage,
7
- :portletpreferences,
8
- :mbmessage,
9
- :layout,
10
- :journalarticle,
11
- :bookmarksfolder,
12
- :wikinode, :wikipage, :wikipageresource,
13
- :announcementsentry,
14
- :calevent,
15
- :dlfolder, :dlfileentry
7
+ :Company,
8
+ :Resource_, :ResourceCode,
9
+ :Permission_,
10
+ :IGImage,
11
+ :PortletPreferences,
12
+ :MBMessage,
13
+ :Layout,
14
+ :JournalArticle,
15
+ :BookmarksFolder,
16
+ :WikiNode, :WikiPage, :WikiPageResource,
17
+ :AnnouncementsEntry,
18
+ :CalEvent,
19
+ :DLFolder, :DLFileEntry
16
20
  ]
17
21
 
18
22
  def setup
19
23
  @resources = Resource.all
20
24
  end
21
25
 
22
- # # each resource must have a resourcecode
23
- # def test_codes
24
- # @resources.each do |x|
25
- # assert_not_nil x.code, "#{x.id} has no resourcecode"
26
- # end
27
- # end
28
- #
26
+ # each resource must have a resourcecode
27
+ def test_codes
28
+ @resources.each do |x|
29
+ assert_not_nil x.resourcecode, "#{x.id} has no resourcecode"
30
+ end
31
+ end
32
+
33
+ def test_permissions
34
+ @resources.each do |x|
35
+ x.permissions.each do |p|
36
+ assert_equal Permission, p.class
37
+ assert_equal x, p.resource
38
+ end
39
+ end
40
+ end
41
+
42
+ def test_layout
43
+ @resources.each do |x|
44
+ if x.layout
45
+ assert_equal Web::Layout, x.layout.class
46
+ end
47
+ end
48
+ end
49
+
29
50
  # def test_permissions
30
51
  # @resources.each do |x|
31
52
  # permissions = x.permissions
@@ -1,15 +1,20 @@
1
- require 'test_helper'
1
+ # encoding: utf-8
2
+
3
+ require 'test/test_helper'
2
4
 
3
5
  class RoleTest < ActiveSupport::TestCase
4
6
  fixtures [
5
- :role_,
6
- :users_roles,
7
- :groups_roles,
8
- # :permission_,
9
- # :users_permissions,
10
- # :groups_permissions,
11
- # :resource_,
12
- # :resourcecode
7
+ :Company,
8
+ :Role_,
9
+ :Users_Roles,
10
+ :Group_,
11
+ :Groups_Roles,
12
+
13
+ # :Permission_,
14
+ # :Roles_Permissions,
15
+ # :Users_Permissions,
16
+ # :Groups_Permissions,
17
+ # :Resource_, :ResourceCode
13
18
  ]
14
19
 
15
20
  def setup
@@ -19,6 +24,9 @@ class RoleTest < ActiveSupport::TestCase
19
24
  end
20
25
 
21
26
  def test_create
27
+ flunk mysql_bug if defined?(mysql_bug)
28
+ # ^ bug goes down to Acts as Resourceful
29
+
22
30
  name = 'Regular role'
23
31
  description = 'test'
24
32
 
@@ -0,0 +1,35 @@
1
+ # encoding: utf-8
2
+
3
+ require 'test/test_helper'
4
+
5
+ class SocialActivityTest < ActiveSupport::TestCase
6
+ fixtures [
7
+ :Company,
8
+ :User_,
9
+ :Group_,
10
+ :SocialActivity
11
+ ]
12
+
13
+ def setup
14
+ @activities = SocialActivity.all
15
+ end
16
+
17
+ def test_company
18
+ @activities.each do |x|
19
+ assert_not_nil x.company
20
+ end
21
+ end
22
+
23
+ def test_group
24
+ @activities.each do |x|
25
+ assert_not_nil x.group
26
+ end
27
+ end
28
+
29
+ def test_user
30
+ @activities.each do |x|
31
+ assert_not_nil x.user
32
+ end
33
+ end
34
+
35
+ end
@@ -0,0 +1,29 @@
1
+ # encoding: utf-8
2
+
3
+ require 'test/test_helper'
4
+
5
+ class SocialRelationTest < ActiveSupport::TestCase
6
+ fixtures [
7
+ :Company,
8
+ :User_,
9
+ :SocialRelation
10
+ ]
11
+
12
+ def setup
13
+ @relations = SocialRelation.all
14
+ end
15
+
16
+ def test_company
17
+ @relations.each do |x|
18
+ assert_not_nil x.company
19
+ end
20
+ end
21
+
22
+ def test_users
23
+ @relations.each do |x|
24
+ assert_not_nil x.user1
25
+ assert_not_nil x.user2
26
+ end
27
+ end
28
+
29
+ end
@@ -1,21 +1,28 @@
1
- require 'test_helper'
1
+ # encoding: utf-8
2
+
3
+ require 'test/test_helper'
2
4
 
3
5
  class Tag::AssetTest < ActiveSupport::TestCase
4
6
  fixtures [
5
- :tagsasset, :tagsassets_tagsentries,
6
- # :resource_, :resourcecode,
7
- :classname_,
8
- :igimage,
9
- :mbmessage,
10
- :blogsentry,
11
- :wikipage,
12
- :bookmarksentry,
13
- :journalarticle,
14
- :dlfileentry,
15
- :layout
7
+ :Company,
8
+ :User_,
9
+ :Group_,
10
+ :TagsAsset, :TagsAssets_TagsEntries,
11
+ # :Resource_, :ResourceCode,
12
+ :ClassName_,
13
+ :IGImage,
14
+ :MBMessage,
15
+ :BlogsEntry,
16
+ :WikiPage,
17
+ :BookmarksEntry,
18
+ :JournalArticle,
19
+ :DLFileEntry,
20
+ :Layout
16
21
  ]
17
22
 
18
23
  def setup
24
+ flunk mysql_bug if defined?(mysql_bug)
25
+
19
26
  @assets = Tag::Asset.all
20
27
  # TODO: DRY up, the same creation code is in portlet test.
21
28
  unless Web::Portlet.find_by_name('asset_publisher')
@@ -55,6 +62,7 @@ class Tag::AssetTest < ActiveSupport::TestCase
55
62
 
56
63
  path = asset.path
57
64
  assert_not_nil path
65
+ assert !path.empty?
58
66
  if build==5100
59
67
  assert path[/#{asset.id}/], 'Path ”%s” does not contain asset id (%i)' % [path, asset.id]
60
68
  assert path[/tagged_content/]
@@ -93,10 +101,16 @@ class Tag::AssetTest < ActiveSupport::TestCase
93
101
  end
94
102
  end
95
103
 
96
- def test_owner
104
+ def test_company
105
+ @assets.each do |asset|
106
+ assert_not_nil asset.company
107
+ end
108
+ end
109
+
110
+ def test_user
97
111
  @assets.each do |asset|
98
- assert_not_nil asset.owner
99
- assert_equal User, asset.owner.class
112
+ assert_not_nil asset.user, 'Asset %i has no user' % asset.id
113
+ assert_equal User, asset.user.class
100
114
  end
101
115
  end
102
116
 
@@ -1,7 +1,17 @@
1
- require 'test_helper'
1
+ # encoding: utf-8
2
+
3
+ require 'test/test_helper'
2
4
 
3
5
  class Tag::EntryTest < ActiveSupport::TestCase
4
- fixtures :tagsentry, :tagsproperty, :tagsasset, :tagsassets_tagsentries, :classname_
6
+ fixtures [
7
+ :Company,
8
+ :User_,
9
+ :TagsAsset,
10
+ :TagsEntry,
11
+ :TagsAssets_TagsEntries,
12
+ :TagsProperty,
13
+ :ClassName_
14
+ ]
5
15
 
6
16
  def setup
7
17
  @tags = Tag::Entry.find :all
@@ -20,9 +30,9 @@ class Tag::EntryTest < ActiveSupport::TestCase
20
30
  end
21
31
  end
22
32
 
23
- def test_owner
33
+ def test_user
24
34
  @tags.each do |x|
25
- assert_not_nil x.owner, "#{x.id} (#{x.name}) belongs to no user"
35
+ assert_not_nil x.user, "#{x.id} (#{x.name}) belongs to no user"
26
36
  end
27
37
  end
28
38
 
@@ -1,21 +1,29 @@
1
- require 'test_helper'
1
+ # encoding: utf-8
2
+
3
+ require 'test/test_helper'
2
4
 
3
5
  class Tag::PropertyTest < ActiveSupport::TestCase
4
- fixtures :tagsentry, :tagsproperty
6
+ fixtures [
7
+ :Company,
8
+ :User_,
9
+ :TagsEntry,
10
+ :TagsProperty
11
+ ]
5
12
 
6
13
  def setup
7
- @properties = Tag::Property.find :all
14
+ @properties = Tag::Property.all
15
+ flunk 'No properties to test' unless @properties.any?
8
16
  end
9
17
 
10
18
  def test_company
11
19
  @properties.each do |x|
12
- assert_not_nil x.company, "#{x.id} belongs to no companies"
20
+ assert_not_nil x.company
13
21
  end
14
22
  end
15
23
 
16
- def test_owner
24
+ def test_user
17
25
  @properties.each do |x|
18
- assert_not_nil x.owner, "#{x.id} belongs to no user"
26
+ assert_not_nil x.user, "#{x.id} belongs to no user"
19
27
  end
20
28
  end
21
29
 
@@ -1,16 +1,23 @@
1
- require 'test_helper'
1
+ # encoding: utf-8
2
+
3
+ require 'test/test_helper'
2
4
 
3
5
  class UserTest < ActiveSupport::TestCase
4
6
  fixtures [
5
- :organization_,
6
- :address,
7
- :phone,
8
- :contact_,
9
- :classname_,
10
- :listtype,
11
- :layoutset,
12
- :counter,
13
- :resourcecode
7
+ :Address,
8
+ :Company,
9
+ :Phone,
10
+ :Contact_,
11
+ :ClassName_,
12
+ :ListType,
13
+ :LayoutSet,
14
+ :Counter,
15
+ :Role_,
16
+ :ResourceCode,
17
+ :Organization_,
18
+ :Users_Orgs,
19
+ :Group_,
20
+ :Users_Groups
14
21
  ]
15
22
 
16
23
  def setup
@@ -20,6 +27,8 @@ class UserTest < ActiveSupport::TestCase
20
27
  end
21
28
 
22
29
  def test_create
30
+ flunk mysql_bug if defined?(mysql_bug)
31
+
23
32
  firstname = 'Test'
24
33
  lastname = 'User'
25
34
  email = 'test@localhost'
@@ -200,25 +209,17 @@ class UserTest < ActiveSupport::TestCase
200
209
 
201
210
  # each user must belong to a company
202
211
  def test_company
212
+ companies = Company.all
203
213
  @users.each do |x|
204
- assert_not_nil x.company
205
- end
206
- end
207
-
208
- # each user can belong to many organizations (they don't have to)
209
- def test_organization
210
- @users.each do |x|
211
- x.organizations.each do |o|
212
- assert_not_nil o
213
- end
214
- #assert !x.organizations.empty?, "#{x.screenname} belongs to no organizations"
214
+ assert_equal Company, x.company.class
215
+ assert companies.include?(x.company)
215
216
  end
216
217
  end
217
218
 
218
219
  # each user must have a contact
219
220
  def test_contact
220
221
  @users.each do |x|
221
- assert_not_nil x.contact
222
+ assert_not_nil x.contact, x.inspect unless x.is_default?
222
223
  end
223
224
  end
224
225
 
@@ -230,7 +231,7 @@ class UserTest < ActiveSupport::TestCase
230
231
 
231
232
  def test_sex
232
233
  @users.each do |x|
233
- assert_not_nil x.sex
234
+ assert_not_nil x.sex unless x.is_default?
234
235
  end
235
236
  end
236
237
 
@@ -238,11 +239,12 @@ class UserTest < ActiveSupport::TestCase
238
239
  def test_hive
239
240
  @users.each do |user|
240
241
  group = user.hive
241
- if user.is_guest?
242
- assert_nil group
243
- else
244
- assert_not_nil group
245
- end
242
+ # since Liferay 5.2.3 guest has group
243
+ #if user.is_guest?
244
+ # assert_nil group
245
+ #else
246
+ # assert_not_nil group, 'User %i has no "home" group' % user.id
247
+ #end
246
248
  next unless group
247
249
  # the group must have a proper classnameid
248
250
  _class = Classname.find_by_value user.liferay_class
@@ -257,7 +259,7 @@ class UserTest < ActiveSupport::TestCase
257
259
  # there has to be layoutsets
258
260
  assert !group.layoutsets.empty?, "#{user.id}'s personal group does not have layoutsets"
259
261
 
260
- # ..eusercept that Liferay-5.1.user doesn't seem to unactive the group
262
+ # ..except that Liferay-5.1 doesn't seem to unactivate the group
261
263
  else
262
264
  #assert !group.is_active?, "#{user.id}'s personal group is active, while the user is not"
263
265
 
@@ -265,33 +267,60 @@ class UserTest < ActiveSupport::TestCase
265
267
  end
266
268
  end
267
269
 
268
- # def test_rigidity
269
- # # each group must exist!
270
- # groups = @users.map{|x| x.groups}.uniq
271
- # groups.each do |group|
272
- # assert_not_nil group, "Reference to non-existing group #{group.inspect}"
273
- # end
274
- #
275
- # # each role must exist!
276
- # roles = @users.map{|x| x.roles}.uniq
277
- # roles.each do |role|
278
- # assert_not_nil role, "Reference to non-existing role #{role.inspect}"
279
- # end
280
- #
281
- # # each permission must exist!
282
- # perms = @users.map{|x| x.permissions}.uniq
283
- # perms.each do |p|
284
- # assert_not_nil p, "Reference to non-existing permission #{p.inspect}"
285
- # end
286
- # end
287
- #
288
- # def test_path
289
- # @users.each do |u|
290
- # unless u.hive.nil?
291
- # assert_not_nil u.path(:public), u.id if u.hive.public_layoutset
292
- # assert_not_nil u.path(:private), u.id if u.hive.private_layoutset
293
- # end
294
- # end
295
- # end
270
+ def test_organizations
271
+ orgs = @users.map{|x| x.orgs}.flatten.uniq
272
+ # Liferay 5.2.3
273
+ assert_equal 11, orgs.size
274
+ orgs.each do |org|
275
+ assert_equal Organization, org.class
276
+ end
277
+ end
278
+
279
+ def test_all_groups
280
+ # each group must exist!
281
+ groups = @users.map{|x| x.groups}.flatten.uniq
282
+ # Liferay 5.2.3
283
+ assert_equal 1, groups.size
284
+ groups.each do |group|
285
+ assert_equal Group, group.class
286
+ end
287
+ end
288
+
289
+ def test_all_roles
290
+ # each role must exist!
291
+ roles = @users.map{|x| x.roles}.flatten.uniq
292
+ # Liferay 5.2.3
293
+ assert_equal 3, roles.size
294
+ roles.each do |role|
295
+ assert_equal Role, role.class
296
+ end
297
+ end
298
+
299
+ def test_all_permissions
300
+ permissions = @users.map{|x| x.permissions}.flatten.uniq
301
+ # Liferay 5.2.3
302
+ assert_equal 0, permissions.size
303
+ permissions.each do |permission|
304
+ assert_equal Permission, permission.class
305
+ end
306
+ end
307
+
308
+ def test_all_usergroups
309
+ usergroups = @users.map{|x| x.usergroups}.flatten.uniq
310
+ # Liferay 5.2.3
311
+ assert_equal 0, usergroups.size
312
+ usergroups.each do |usergroup|
313
+ assert_equal Usergroup, permission.class
314
+ end
315
+ end
316
+
317
+ def test_path
318
+ @users.each do |u|
319
+ unless u.hive.nil?
320
+ assert_not_nil u.path(:public), u.id if u.hive.public_layoutset
321
+ assert_not_nil u.path(:private), u.id if u.hive.private_layoutset
322
+ end
323
+ end
324
+ end
296
325
 
297
326
  end