KayakoClient 1.0.2 → 1.1.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 (84) hide show
  1. data/lib/kayako_client.rb +31 -0
  2. data/lib/kayako_client/base.rb +23 -0
  3. data/lib/kayako_client/custom_field.rb +14 -0
  4. data/lib/kayako_client/department.rb +18 -3
  5. data/lib/kayako_client/http/http.rb +14 -0
  6. data/lib/kayako_client/http/http_backend.rb +14 -0
  7. data/lib/kayako_client/http/http_client.rb +14 -0
  8. data/lib/kayako_client/http/http_response.rb +14 -0
  9. data/lib/kayako_client/http/net_http.rb +14 -0
  10. data/lib/kayako_client/knowledgebase_article.rb +131 -0
  11. data/lib/kayako_client/knowledgebase_attachment.rb +59 -0
  12. data/lib/kayako_client/knowledgebase_category.rb +71 -0
  13. data/lib/kayako_client/knowledgebase_comment.rb +32 -0
  14. data/lib/kayako_client/mixins/api.rb +14 -0
  15. data/lib/kayako_client/mixins/article_client.rb +76 -0
  16. data/lib/kayako_client/mixins/attachment.rb +16 -1
  17. data/lib/kayako_client/mixins/authentication.rb +14 -0
  18. data/lib/kayako_client/mixins/client.rb +300 -0
  19. data/lib/kayako_client/mixins/comment_object.rb +102 -0
  20. data/lib/kayako_client/mixins/convert_api.rb +39 -0
  21. data/lib/kayako_client/mixins/creator_api.rb +44 -0
  22. data/lib/kayako_client/mixins/knowledgebase_article_api.rb +69 -0
  23. data/lib/kayako_client/mixins/knowledgebase_category_client.rb +51 -0
  24. data/lib/kayako_client/mixins/logger.rb +14 -0
  25. data/lib/kayako_client/mixins/news_category_client.rb +51 -0
  26. data/lib/kayako_client/mixins/news_client.rb +51 -0
  27. data/lib/kayako_client/mixins/object.rb +24 -7
  28. data/lib/kayako_client/mixins/post_client.rb +14 -0
  29. data/lib/kayako_client/mixins/staff_visibility_api.rb +14 -0
  30. data/lib/kayako_client/mixins/ticket_api.rb +14 -0
  31. data/lib/kayako_client/mixins/ticket_client.rb +14 -0
  32. data/lib/kayako_client/mixins/troubleshooter_step_api.rb +69 -0
  33. data/lib/kayako_client/mixins/troubleshooter_step_client.rb +76 -0
  34. data/lib/kayako_client/mixins/user_visibility_api.rb +14 -0
  35. data/lib/kayako_client/news_category.rb +29 -0
  36. data/lib/kayako_client/news_comment.rb +32 -0
  37. data/lib/kayako_client/news_item.rb +81 -0
  38. data/lib/kayako_client/news_subscriber.rb +33 -0
  39. data/lib/kayako_client/staff.rb +14 -0
  40. data/lib/kayako_client/staff_group.rb +14 -0
  41. data/lib/kayako_client/ticket.rb +24 -1
  42. data/lib/kayako_client/ticket_attachment.rb +18 -0
  43. data/lib/kayako_client/ticket_count.rb +14 -0
  44. data/lib/kayako_client/ticket_custom_field.rb +14 -0
  45. data/lib/kayako_client/ticket_note.rb +14 -1
  46. data/lib/kayako_client/ticket_post.rb +15 -0
  47. data/lib/kayako_client/ticket_priority.rb +14 -0
  48. data/lib/kayako_client/ticket_status.rb +14 -0
  49. data/lib/kayako_client/ticket_time_track.rb +14 -0
  50. data/lib/kayako_client/ticket_type.rb +14 -0
  51. data/lib/kayako_client/troubleshooter_attachment.rb +68 -0
  52. data/lib/kayako_client/troubleshooter_category.rb +51 -0
  53. data/lib/kayako_client/troubleshooter_comment.rb +32 -0
  54. data/lib/kayako_client/troubleshooter_step.rb +100 -0
  55. data/lib/kayako_client/user.rb +42 -0
  56. data/lib/kayako_client/user_group.rb +14 -0
  57. data/lib/kayako_client/user_organization.rb +14 -0
  58. data/lib/kayako_client/xml/lib_xml.rb +14 -0
  59. data/lib/kayako_client/xml/rexml_document.rb +14 -0
  60. data/lib/kayako_client/xml/xml.rb +14 -0
  61. data/lib/kayako_client/xml/xml_backend.rb +14 -0
  62. data/test/test_attachment.rb +77 -0
  63. data/test/test_client.rb +191 -0
  64. data/test/test_configuration.rb +110 -0
  65. data/test/test_count.rb +162 -0
  66. data/test/test_custom_field.rb +86 -0
  67. data/test/test_department.rb +136 -0
  68. data/test/test_http.rb +34 -0
  69. data/test/test_knowledgebase.rb +155 -0
  70. data/test/test_news.rb +117 -0
  71. data/test/test_note.rb +64 -0
  72. data/test/test_post.rb +64 -0
  73. data/test/test_priority.rb +46 -0
  74. data/test/test_properties.rb +114 -0
  75. data/test/test_staff.rb +77 -0
  76. data/test/test_status.rb +52 -0
  77. data/test/test_ticket.rb +152 -0
  78. data/test/test_ticket_custom_field.rb +193 -0
  79. data/test/test_time_track.rb +68 -0
  80. data/test/test_troubleshooter.rb +106 -0
  81. data/test/test_type.rb +65 -0
  82. data/test/test_user.rb +95 -0
  83. data/test/test_xml.rb +183 -0
  84. metadata +89 -42
@@ -0,0 +1,162 @@
1
+ #######################################################################
2
+ #
3
+ # Kayako Ruby REST API library
4
+ # _____________________________________________________________________
5
+ #
6
+ # @author Andriy Lesyuk
7
+ #
8
+ # @package KayakoClient
9
+ # @copyright Copyright (c) 2011-2013, Kayako
10
+ # @license FreeBSD
11
+ # @link http://forge.kayako.com/projects/kayako-ruby-api-library
12
+ #
13
+ #######################################################################
14
+
15
+ require 'test/unit'
16
+ require 'kayako_client'
17
+
18
+ class TestCount < Test::Unit::TestCase
19
+
20
+ def test_count_embedded
21
+ test = KayakoClient::TicketCount.new(
22
+ :departments => {
23
+ :department => [ {
24
+ :id => 1,
25
+ :lastactivity => 1311888965,
26
+ :totalitems => 100,
27
+ :totalunresolveditems => 50,
28
+ :ticketstatus => {
29
+ :id => 1,
30
+ :lastactivity => 1311888965,
31
+ :totalitems => 100
32
+ },
33
+ :tickettype => [ {
34
+ :id => 0,
35
+ :lastactivity => 1311888965,
36
+ :totalitems => 50,
37
+ :totalunresolveditems => 25
38
+ }, {
39
+ :id => 1,
40
+ :lastactivity => 1311887337,
41
+ :totalitems => 50,
42
+ :totalunresolveditems => 25
43
+ }
44
+ ],
45
+ :ownerstaff => {
46
+ :id => 1,
47
+ :lastactivity => 1311888965,
48
+ :totalitems => 15,
49
+ :totalunresolveditems => 10
50
+ }
51
+ }, {
52
+ :id => 2,
53
+ :lastactivity => 75,
54
+ :totalunresolveditems => 25
55
+ }
56
+ ]
57
+ },
58
+ :statuses => {
59
+ :id => 1,
60
+ :lastactivity => 1311888965,
61
+ :totalitems => 100
62
+ },
63
+ :owners => [ {
64
+ :id => 1,
65
+ :lastactivity => 1311888965,
66
+ :totalitems => 15,
67
+ :totalunresolveditems => 10
68
+ }, {
69
+ :id => 2,
70
+ :lastactivity => 1311888396,
71
+ :totalitems => 80,
72
+ :totalunresolveditems => 30
73
+ }
74
+ ],
75
+ :unassigned => {
76
+ :id => 1,
77
+ :lastactivity => 1311888965,
78
+ :totalitems => 15,
79
+ :totalunresolveditems => 10
80
+ }
81
+ )
82
+
83
+ assert_instance_of Array, test.departments
84
+ assert_instance_of KayakoClient::TicketCountDepartment, test.departments.first
85
+ assert_equal test.departments.size, 2
86
+
87
+ assert_equal test.departments.first.id, 1
88
+ assert_instance_of Time, test.departments.first.last_activity
89
+ assert_equal test.departments.first.last_activity.to_i, 1311888965
90
+ assert_equal test.departments.first.total_items, 100
91
+ assert_equal test.departments.first.total_unresolved_items, 50
92
+
93
+ assert_instance_of Array, test.departments.first.statuses
94
+ assert_instance_of Array, test.departments.first.types
95
+ assert_instance_of Array, test.departments.first.owners
96
+
97
+ assert_instance_of KayakoClient::TicketCountStatus, test.departments.first.statuses.first
98
+ assert_instance_of KayakoClient::TicketCountType, test.departments.first.types.first
99
+ assert_instance_of KayakoClient::TicketCountOwner, test.departments.first.owners.first
100
+
101
+ assert_equal test.departments.first.statuses.size, 1
102
+ assert_equal test.departments.first.types.size, 2
103
+ assert_equal test.departments.first.owners.size, 1
104
+
105
+ assert_instance_of Array, test.statuses
106
+ assert_instance_of KayakoClient::TicketCountStatus, test.statuses.first
107
+ assert_equal test.statuses.size, 1
108
+
109
+ assert_equal test.statuses.first.id, 1
110
+ assert_equal test.statuses.first.last_activity.to_i, 1311888965
111
+ assert_equal test.statuses.first.total_items, 100
112
+
113
+ assert_instance_of Array, test.owners
114
+ assert_instance_of KayakoClient::TicketCountOwner, test.owners.first
115
+ assert_equal test.owners.size, 2
116
+
117
+ assert_equal test.owners.first.id, 1
118
+ assert_equal test.owners.first.last_activity.to_i, 1311888965
119
+ assert_equal test.owners.first.total_items, 15
120
+ assert_equal test.owners.first.total_unresolved_items, 10
121
+
122
+ assert_instance_of Array, test.unassigned
123
+ assert_instance_of KayakoClient::TicketCountUnassigned, test.unassigned.first
124
+ assert_equal test.unassigned.size, 1
125
+
126
+ assert test.departments.first.respond_to?(:department)
127
+ assert test.departments.first.types.first.respond_to?(:ticket_type)
128
+ assert test.statuses.first.respond_to?(:ticket_status)
129
+ assert test.owners.first.respond_to?(:owner_staff)
130
+ end
131
+
132
+ def test_count_methods
133
+ assert_raise NotImplementedError do
134
+ KayakoClient::TicketCount.all
135
+ end
136
+
137
+ test = KayakoClient::TicketCount.new(
138
+ :unassigned => {
139
+ :id => 1,
140
+ :lastactivity => 1311888965,
141
+ :totalitems => 15,
142
+ :totalunresolveditems => 10
143
+ }
144
+ )
145
+ assert_raise NotImplementedError do
146
+ test.put
147
+ end
148
+
149
+ assert_raise NotImplementedError do
150
+ KayakoClient::TicketCount.post
151
+ end
152
+
153
+ assert_raise NotImplementedError do
154
+ test.delete
155
+ end
156
+
157
+ assert_raise NotImplementedError do
158
+ KayakoClient::TicketCount.delete(1)
159
+ end
160
+ end
161
+
162
+ end
@@ -0,0 +1,86 @@
1
+ #######################################################################
2
+ #
3
+ # Kayako Ruby REST API library
4
+ # _____________________________________________________________________
5
+ #
6
+ # @author Andriy Lesyuk
7
+ #
8
+ # @package KayakoClient
9
+ # @copyright Copyright (c) 2011-2013, Kayako
10
+ # @license FreeBSD
11
+ # @link http://forge.kayako.com/projects/kayako-ruby-api-library
12
+ #
13
+ #######################################################################
14
+
15
+ require 'test/unit'
16
+ require 'kayako_client'
17
+
18
+ class TestCustomField < Test::Unit::TestCase
19
+
20
+ def test_custom_field
21
+ test = KayakoClient::CustomField.new(
22
+ :custom_field_id => 1,
23
+ :field_name => 'Test',
24
+ :title => 'Test title',
25
+ :description => 'Test description',
26
+ :field_type => 1,
27
+ :is_required => true,
28
+ :default_value => 'Test',
29
+ :regexp_validate => '/test/',
30
+ :encrypt_in_db => false,
31
+ :display_order => 1,
32
+ :user_editable => false,
33
+ :staff_editable => true
34
+ )
35
+
36
+ assert_equal test.custom_field_id, 1
37
+ assert_equal test.field_name, 'Test'
38
+ assert_equal test.title, 'Test title'
39
+ assert_equal test.description, 'Test description'
40
+ assert_equal test.field_type, KayakoClient::CustomField::TYPE_TEXT
41
+ assert_equal test.default_value, 'Test'
42
+ assert_equal test.regexp_validate, '/test/'
43
+ assert_equal test.display_order, 1
44
+
45
+ assert test.is_required?
46
+ assert test.staff_editable?
47
+
48
+ assert !test.encrypt_in_db?
49
+ assert !test.user_editable?
50
+
51
+ assert test.respond_to?(:options)
52
+ end
53
+
54
+ def test_custom_field_types
55
+ assert_equal KayakoClient::CustomField::TYPE_TEXT, KayakoClient::TicketCustomField::TYPE_TEXT
56
+ assert_equal KayakoClient::CustomField::TYPE_TEXT_AREA, KayakoClient::TicketCustomField::TYPE_TEXT_AREA
57
+ assert_equal KayakoClient::CustomField::TYPE_PASSWORD, KayakoClient::TicketCustomField::TYPE_PASSWORD
58
+ assert_equal KayakoClient::CustomField::TYPE_CHECKBOX, KayakoClient::TicketCustomField::TYPE_CHECKBOX
59
+ assert_equal KayakoClient::CustomField::TYPE_RADIO, KayakoClient::TicketCustomField::TYPE_RADIO
60
+ assert_equal KayakoClient::CustomField::TYPE_SELECT, KayakoClient::TicketCustomField::TYPE_SELECT
61
+ assert_equal KayakoClient::CustomField::TYPE_MULTI_SELECT, KayakoClient::TicketCustomField::TYPE_MULTI_SELECT
62
+ assert_equal KayakoClient::CustomField::TYPE_CUSTOM, KayakoClient::TicketCustomField::TYPE_CUSTOM
63
+ assert_equal KayakoClient::CustomField::TYPE_LINKED_SELECT, KayakoClient::TicketCustomField::TYPE_LINKED_SELECT
64
+ assert_equal KayakoClient::CustomField::TYPE_DATE, KayakoClient::TicketCustomField::TYPE_DATE
65
+ assert_equal KayakoClient::CustomField::TYPE_FILE, KayakoClient::TicketCustomField::TYPE_FILE
66
+ end
67
+
68
+ def test_custom_field_option
69
+ test = KayakoClient::CustomFieldOption.new(
70
+ :custom_field_option_id => 1,
71
+ :custom_field_id => 1,
72
+ :option_value => 'Test',
73
+ :display_order => 1,
74
+ :is_selected => true
75
+ )
76
+
77
+ assert_equal test.custom_field_option_id, 1
78
+ assert_equal test.custom_field_id, 1
79
+ assert_equal test.option_value, 'Test'
80
+ assert_equal test.display_order, 1
81
+
82
+ assert test.is_selected?
83
+ assert !test.has_parent_custom_field_option?
84
+ end
85
+
86
+ end
@@ -0,0 +1,136 @@
1
+ #######################################################################
2
+ #
3
+ # Kayako Ruby REST API library
4
+ # _____________________________________________________________________
5
+ #
6
+ # @author Andriy Lesyuk
7
+ #
8
+ # @package KayakoClient
9
+ # @copyright Copyright (c) 2011-2013, Kayako
10
+ # @license FreeBSD
11
+ # @link http://forge.kayako.com/projects/kayako-ruby-api-library
12
+ #
13
+ #######################################################################
14
+
15
+ require 'test/unit'
16
+ require 'kayako_client'
17
+
18
+ class TestDepartment < Test::Unit::TestCase
19
+
20
+ def test_department_readonly
21
+ test = KayakoClient::Department.new(
22
+ :id => 1,
23
+ :title => 'Test',
24
+ :type => :public,
25
+ :app => :tickets
26
+ )
27
+ assert_raise NoMethodError do
28
+ test.id = 2
29
+ end
30
+
31
+ assert_nothing_raised do
32
+ test.app = :livechat
33
+ end
34
+
35
+ test.loaded!
36
+ assert_raise ArgumentError do
37
+ test.app = :livechat
38
+ end
39
+ end
40
+
41
+ def test_department_assign
42
+ test = KayakoClient::Department.new
43
+
44
+ test.type = "public"
45
+ assert_equal test.type, :public
46
+
47
+ test.app = "tickets"
48
+ assert_equal test.app, :tickets
49
+
50
+ test.display_order = "nan"
51
+ assert_equal test.display_order, 0
52
+
53
+ parent = KayakoClient::Department.new(
54
+ :id => 1
55
+ )
56
+
57
+ test.parent_department_id = parent
58
+ assert_equal test.parent_department_id, 1
59
+
60
+ test.user_visibility_custom = 1
61
+ assert_equal test.user_visibility_custom, true
62
+ end
63
+
64
+ def test_department_required
65
+ test = KayakoClient::Department.new(
66
+ :id => 1,
67
+ :display_order => 1
68
+ )
69
+ assert_raise ArgumentError do
70
+ test.put
71
+ end
72
+
73
+ test = KayakoClient::Department.new(
74
+ :title => "Test"
75
+ )
76
+ assert_raise ArgumentError do
77
+ test.post
78
+ end
79
+ end
80
+
81
+ def test_department_validate
82
+ test = KayakoClient::Department.new(
83
+ :id => 1,
84
+ :title => "Test",
85
+ :type => :test
86
+ )
87
+ assert_equal test.put, false
88
+ assert test.has_errors?
89
+ end
90
+
91
+ def test_department_customs
92
+ test = KayakoClient::Department.new(
93
+ :id => 1,
94
+ :title => 'Test',
95
+ :type => :public,
96
+ :app => :tickets
97
+ )
98
+ assert_equal test.has_parent_department?, false
99
+
100
+ test.parent_department_id = 2
101
+ assert test.has_parent_department?
102
+
103
+ assert test.visible_to_user_group?(1)
104
+
105
+ test.user_visibility_custom = true
106
+ assert test.visible_to_user_group?(1) == false
107
+
108
+ test.user_group_ids = [ 1 ]
109
+ assert test.visible_to_user_group?(1)
110
+ end
111
+
112
+ def test_department_aliases
113
+ test = KayakoClient::Department.new
114
+
115
+ assert_nothing_raised do
116
+ test.parentdepartmentid = 1
117
+ end
118
+
119
+ assert_nothing_raised do
120
+ test.parentdepartmentid
121
+ end
122
+ assert_equal test.parentdepartmentid, 1
123
+
124
+ assert_nothing_raised do
125
+ test.usergroupid = [ 1 ]
126
+ end
127
+
128
+ assert_nothing_raised do
129
+ test.usergroups
130
+ end
131
+ assert_instance_of Array, test.usergroups
132
+ assert_equal test.usergroups.size, 1
133
+ assert_equal test.usergroups[0], 1
134
+ end
135
+
136
+ end
@@ -0,0 +1,34 @@
1
+ #######################################################################
2
+ #
3
+ # Kayako Ruby REST API library
4
+ # _____________________________________________________________________
5
+ #
6
+ # @author Andriy Lesyuk
7
+ #
8
+ # @package KayakoClient
9
+ # @copyright Copyright (c) 2011-2013, Kayako
10
+ # @license FreeBSD
11
+ # @link http://forge.kayako.com/projects/kayako-ruby-api-library
12
+ #
13
+ #######################################################################
14
+
15
+ require 'test/unit'
16
+ require 'kayako_client'
17
+
18
+ class TestHTTP < Test::Unit::TestCase
19
+
20
+ def test_response
21
+ test = KayakoClient::HTTPResponse.new(303, 'Test')
22
+ assert_equal test.status, 303
23
+ assert_equal test.body, 'Test'
24
+
25
+ test = KayakoClient::HTTPOK.new
26
+ assert_equal test.status, 200
27
+ assert_equal test.body, ''
28
+
29
+ test = KayakoClient::HTTPForbidden.new('Test')
30
+ assert_equal test.status, 403
31
+ assert_equal test.body, 'Test'
32
+ end
33
+
34
+ end
@@ -0,0 +1,155 @@
1
+ #######################################################################
2
+ #
3
+ # Kayako Ruby REST API library
4
+ # _____________________________________________________________________
5
+ #
6
+ # @author Andriy Lesyuk
7
+ #
8
+ # @package KayakoClient
9
+ # @copyright Copyright (c) 2011-2013, Kayako
10
+ # @license FreeBSD
11
+ # @link http://forge.kayako.com/projects/kayako-ruby-api-library
12
+ #
13
+ #######################################################################
14
+
15
+ require 'test/unit'
16
+ require 'kayako_client'
17
+
18
+ class TestKnowledgebase < Test::Unit::TestCase
19
+
20
+ def test_knowledgebase_api
21
+ assert_equal KayakoClient::KnowledgebaseArticle.path, '/Knowledgebase/Article'
22
+ assert_equal KayakoClient::KnowledgebaseAttachment.path, '/Knowledgebase/Attachment'
23
+ assert_equal KayakoClient::KnowledgebaseCategory.path, '/Knowledgebase/Category'
24
+ assert_equal KayakoClient::KnowledgebaseComment.path, '/Knowledgebase/Comment'
25
+ end
26
+
27
+ def test_creator_api
28
+ test = KayakoClient::KnowledgebaseArticle.new
29
+
30
+ assert !test.created_by_user?
31
+ assert !test.created_by_staff?
32
+
33
+ test = KayakoClient::KnowledgebaseArticle.new(
34
+ :creator_type => KayakoClient::KnowledgebaseArticle::CREATOR_USER
35
+ )
36
+
37
+ assert test.created_by_user?
38
+
39
+ test = KayakoClient::KnowledgebaseArticle.new(
40
+ :creator_type => KayakoClient::KnowledgebaseArticle::CREATOR_STAFF
41
+ )
42
+
43
+ assert test.created_by_staff?
44
+ end
45
+
46
+ def test_article
47
+ test = KayakoClient::KnowledgebaseArticle.new(
48
+ :kbarticleid => 1,
49
+ :categories => [ 0 ]
50
+ )
51
+
52
+ assert test.respond_to?(:id)
53
+ assert_equal test.id, test.kb_article_id
54
+
55
+ assert_raise ArgumentError do
56
+ KayakoClient::KnowledgebaseArticle.all(1, 2)
57
+ end
58
+
59
+ assert test.in_root_category?
60
+ end
61
+
62
+ def test_article_api
63
+ assert_raise ArgumentError do
64
+ KayakoClient::KnowledgebaseAttachment.all
65
+ end
66
+
67
+ assert_raise ArgumentError do
68
+ KayakoClient::KnowledgebaseAttachment.all(0)
69
+ end
70
+
71
+ assert_raise ArgumentError do
72
+ KayakoClient::KnowledgebaseAttachment.get(1)
73
+ end
74
+
75
+ assert_raise ArgumentError do
76
+ KayakoClient::KnowledgebaseAttachment.delete(1)
77
+ end
78
+
79
+ test = KayakoClient::KnowledgebaseAttachment.new(
80
+ :id => 1
81
+ )
82
+ test.loaded!
83
+
84
+ assert_raise RuntimeError do
85
+ test.delete
86
+ end
87
+ end
88
+
89
+ def test_attachment
90
+ test = KayakoClient::KnowledgebaseAttachment.new
91
+
92
+ assert_raise NotImplementedError do
93
+ test.put
94
+ end
95
+
96
+ assert test.respond_to?(:file)
97
+ assert test.respond_to?(:file=)
98
+ end
99
+
100
+ def test_category
101
+ test = KayakoClient::KnowledgebaseCategory.new(
102
+ :parent_kb_category_id => 0,
103
+ :user_visibility_custom => true,
104
+ :usergroupidlist => [ 1 ],
105
+ :staff_visibility_custom => true,
106
+ :staffgroupidlist => [ 1 ]
107
+ )
108
+
109
+ assert !test.has_parent_category?
110
+ assert test.parent_is_root?
111
+
112
+ assert test.visible_to_user_group?(1)
113
+ assert test.visible_to_staff_group?(1)
114
+
115
+ assert !test.visible_to_user_group?(2)
116
+ assert !test.visible_to_staff_group?(2)
117
+ end
118
+
119
+ def test_comment
120
+ test = KayakoClient::KnowledgebaseComment.new(
121
+ :parent_comment_id => 1
122
+ )
123
+
124
+ assert test.respond_to?(:creator=)
125
+
126
+ staff = KayakoClient::Staff.new(
127
+ :id => 1,
128
+ :full_name => 'Test Test',
129
+ :email => 'test@test.com'
130
+ )
131
+
132
+ test.creator = staff
133
+
134
+ assert_equal test.creator_type, KayakoClient::KnowledgebaseComment::CREATOR_STAFF
135
+ assert_equal test.creator_id, 1
136
+ assert_equal test.full_name, 'Test Test'
137
+ assert_equal test.email, 'test@test.com'
138
+
139
+ user = KayakoClient::User.new(
140
+ :id => 2,
141
+ :full_name => 'Test2 Test2',
142
+ :emails => [ 'test2@test2.com' ]
143
+ )
144
+
145
+ test.creator = user
146
+
147
+ assert_equal test.creator_type, KayakoClient::KnowledgebaseComment::CREATOR_USER
148
+ assert_equal test.creator_id, 2
149
+ assert_equal test.full_name, 'Test2 Test2'
150
+ assert_equal test.email, 'test2@test2.com'
151
+
152
+ assert test.has_parent_comment?
153
+ end
154
+
155
+ end