desk 0.3.3 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (193) hide show
  1. checksums.yaml +7 -0
  2. data/README.mkd +305 -106
  3. data/TRANSITION.mkd +133 -0
  4. data/desk.gemspec +1 -1
  5. data/lib/desk.rb +1 -1
  6. data/lib/desk/api.rb +5 -1
  7. data/lib/desk/client.rb +184 -10
  8. data/lib/desk/client/article.rb +4 -83
  9. data/lib/desk/client/brand.rb +11 -0
  10. data/lib/desk/client/case.rb +59 -42
  11. data/lib/desk/client/company.rb +11 -0
  12. data/lib/desk/client/custom_field.rb +10 -0
  13. data/lib/desk/client/customer.rb +26 -124
  14. data/lib/desk/client/facebook_user.rb +11 -0
  15. data/lib/desk/client/filter.rb +11 -0
  16. data/lib/desk/client/group.rb +3 -29
  17. data/lib/desk/client/insight.rb +17 -0
  18. data/lib/desk/client/integration_url.rb +11 -0
  19. data/lib/desk/client/job.rb +11 -0
  20. data/lib/desk/client/label.rb +11 -0
  21. data/lib/desk/client/macro.rb +3 -133
  22. data/lib/desk/client/mailbox.rb +26 -0
  23. data/lib/desk/client/rule.rb +14 -0
  24. data/lib/desk/client/site_setting.rb +11 -0
  25. data/lib/desk/client/system_message.rb +16 -0
  26. data/lib/desk/client/topic.rb +4 -81
  27. data/lib/desk/client/twitter_account.rb +11 -0
  28. data/lib/desk/client/twitter_user.rb +11 -0
  29. data/lib/desk/client/user.rb +3 -30
  30. data/lib/desk/configuration.rb +1 -1
  31. data/lib/desk/connection.rb +2 -1
  32. data/lib/desk/deash.rb +100 -0
  33. data/lib/desk/request.rb +33 -20
  34. data/lib/desk/version.rb +1 -1
  35. data/lib/faraday/request/oauth.rb +6 -3
  36. data/lib/faraday/response/deashify.rb +23 -0
  37. data/spec/desk/client/article_spec.rb +62 -117
  38. data/spec/desk/client/brand_spec.rb +18 -0
  39. data/spec/desk/client/case_spec.rb +182 -66
  40. data/spec/desk/client/companies_spec.rb +26 -0
  41. data/spec/desk/client/custom_fields_spec.rb +18 -0
  42. data/spec/desk/client/customer_spec.rb +16 -145
  43. data/spec/desk/client/facebook_users_spec.rb +17 -0
  44. data/spec/desk/client/filter_spec.rb +28 -0
  45. data/spec/desk/client/group_spec.rb +32 -49
  46. data/spec/desk/client/inbound_mailboxes_spec.rb +70 -0
  47. data/spec/desk/client/integration_url_spec.rb +28 -0
  48. data/spec/desk/client/job_spec.rb +32 -0
  49. data/spec/desk/client/label_spec.rb +31 -0
  50. data/spec/desk/client/macro_spec.rb +22 -185
  51. data/spec/desk/client/rule_spec.rb +18 -0
  52. data/spec/desk/client/site_setting_spec.rb +18 -0
  53. data/spec/desk/client/system_message_spec.rb +42 -0
  54. data/spec/desk/client/topic_spec.rb +31 -112
  55. data/spec/desk/client/twitter_account_spec.rb +32 -0
  56. data/spec/desk/client/twitter_user_spec.rb +27 -0
  57. data/spec/desk/client/user_spec.rb +19 -42
  58. data/spec/desk_spec.rb +2 -2
  59. data/spec/faraday/response_spec.rb +3 -6
  60. data/spec/fixtures/article +50 -0
  61. data/spec/fixtures/article_create +50 -0
  62. data/spec/fixtures/article_translation +29 -0
  63. data/spec/fixtures/article_translation_create +29 -0
  64. data/spec/fixtures/article_translation_update +29 -0
  65. data/spec/fixtures/article_translations +81 -0
  66. data/spec/fixtures/article_update +50 -0
  67. data/spec/fixtures/articles +123 -0
  68. data/spec/fixtures/articles_search +124 -0
  69. data/spec/fixtures/brand +11 -0
  70. data/spec/fixtures/brands +45 -0
  71. data/spec/fixtures/case +44 -0
  72. data/spec/fixtures/case_attachment +19 -0
  73. data/spec/fixtures/case_attachment_create +19 -0
  74. data/spec/fixtures/case_attachments +61 -0
  75. data/spec/fixtures/case_create +51 -0
  76. data/spec/fixtures/case_message +26 -0
  77. data/spec/fixtures/case_note +21 -0
  78. data/spec/fixtures/case_note_create +26 -0
  79. data/spec/fixtures/case_notes +65 -0
  80. data/spec/fixtures/case_replies +75 -0
  81. data/spec/fixtures/case_reply +26 -0
  82. data/spec/fixtures/case_reply_create +26 -0
  83. data/spec/fixtures/case_reply_update +26 -0
  84. data/spec/fixtures/case_update +49 -0
  85. data/spec/fixtures/cases +111 -0
  86. data/spec/fixtures/cases_search +113 -0
  87. data/spec/fixtures/companies +75 -0
  88. data/spec/fixtures/companies_search +76 -0
  89. data/spec/fixtures/company +26 -0
  90. data/spec/fixtures/company_create +26 -0
  91. data/spec/fixtures/company_search +76 -0
  92. data/spec/fixtures/company_update +27 -0
  93. data/spec/fixtures/custom_field +15 -0
  94. data/spec/fixtures/custom_fields +58 -0
  95. data/spec/fixtures/customer +60 -0
  96. data/spec/fixtures/customer_create +54 -0
  97. data/spec/fixtures/customer_update +60 -0
  98. data/spec/fixtures/customers +143 -0
  99. data/spec/fixtures/customers_search +143 -0
  100. data/spec/fixtures/facebook_user +16 -0
  101. data/spec/fixtures/facebook_users +55 -0
  102. data/spec/fixtures/filter +16 -0
  103. data/spec/fixtures/filter_cases +111 -0
  104. data/spec/fixtures/filters +55 -0
  105. data/spec/fixtures/group +9 -0
  106. data/spec/fixtures/group_filters +55 -0
  107. data/spec/fixtures/group_users +63 -0
  108. data/spec/fixtures/groups +42 -0
  109. data/spec/fixtures/inbound_mailbox +32 -0
  110. data/spec/fixtures/inbound_mailboxes +87 -0
  111. data/spec/fixtures/integration_url +15 -0
  112. data/spec/fixtures/integration_url_create +15 -0
  113. data/spec/fixtures/integration_url_update +15 -0
  114. data/spec/fixtures/integration_urls +54 -0
  115. data/spec/fixtures/job +17 -0
  116. data/spec/fixtures/job_create +17 -0
  117. data/spec/fixtures/jobs +57 -0
  118. data/spec/fixtures/label +17 -0
  119. data/spec/fixtures/label_create +17 -0
  120. data/spec/fixtures/label_update +17 -0
  121. data/spec/fixtures/labels +57 -0
  122. data/spec/fixtures/macro +20 -0
  123. data/spec/fixtures/macro_action +17 -0
  124. data/spec/fixtures/macro_action_update +17 -0
  125. data/spec/fixtures/macro_actions +57 -0
  126. data/spec/fixtures/macro_create +20 -0
  127. data/spec/fixtures/macro_update +20 -0
  128. data/spec/fixtures/macros +63 -0
  129. data/spec/fixtures/rule +13 -0
  130. data/spec/fixtures/rules +49 -0
  131. data/spec/fixtures/site_setting +10 -0
  132. data/spec/fixtures/site_settings +43 -0
  133. data/spec/fixtures/system_message +4 -0
  134. data/spec/fixtures/topic +23 -0
  135. data/spec/fixtures/topic_create +23 -0
  136. data/spec/fixtures/topic_translation +12 -0
  137. data/spec/fixtures/topic_translation_create +12 -0
  138. data/spec/fixtures/topic_translation_update +12 -0
  139. data/spec/fixtures/topic_translations +47 -0
  140. data/spec/fixtures/topic_update +23 -0
  141. data/spec/fixtures/topics +69 -0
  142. data/spec/fixtures/twitter_account +14 -0
  143. data/spec/fixtures/twitter_account_tweet +20 -0
  144. data/spec/fixtures/twitter_account_tweet_create +20 -0
  145. data/spec/fixtures/twitter_account_tweets +63 -0
  146. data/spec/fixtures/twitter_accounts +51 -0
  147. data/spec/fixtures/twitter_user +18 -0
  148. data/spec/fixtures/twitter_user_create +18 -0
  149. data/spec/fixtures/twitter_users +59 -0
  150. data/spec/fixtures/user +20 -0
  151. data/spec/fixtures/user_preference +18 -0
  152. data/spec/fixtures/user_preference_update +14 -0
  153. data/spec/fixtures/user_preferences +223 -0
  154. data/spec/fixtures/users +63 -0
  155. data/spec/helper.rb +12 -0
  156. data/spec/shared_context.rb +16 -0
  157. data/spec/shared_examples.rb +312 -0
  158. metadata +247 -181
  159. data/lib/desk/client/interaction.rb +0 -75
  160. data/spec/desk/client/interaction_spec.rb +0 -191
  161. data/spec/fixtures/article.json +0 -50
  162. data/spec/fixtures/article_create.json +0 -54
  163. data/spec/fixtures/article_destroy.json +0 -3
  164. data/spec/fixtures/article_update.json +0 -54
  165. data/spec/fixtures/articles.json +0 -58
  166. data/spec/fixtures/case.json +0 -59
  167. data/spec/fixtures/case_update.json +0 -59
  168. data/spec/fixtures/cases.json +0 -182
  169. data/spec/fixtures/customer.json +0 -58
  170. data/spec/fixtures/customer_create.json +0 -56
  171. data/spec/fixtures/customer_create_email.json +0 -15
  172. data/spec/fixtures/customer_update.json +0 -47
  173. data/spec/fixtures/customer_update_email.json +0 -15
  174. data/spec/fixtures/customers.json +0 -98
  175. data/spec/fixtures/group.json +0 -8
  176. data/spec/fixtures/groups.json +0 -23
  177. data/spec/fixtures/interaction_create.json +0 -126
  178. data/spec/fixtures/interactions.json +0 -139
  179. data/spec/fixtures/macro.json +0 -8
  180. data/spec/fixtures/macro_action.json +0 -9
  181. data/spec/fixtures/macro_action_update.json +0 -12
  182. data/spec/fixtures/macro_actions.json +0 -69
  183. data/spec/fixtures/macro_create.json +0 -13
  184. data/spec/fixtures/macro_destroy.json +0 -3
  185. data/spec/fixtures/macro_update.json +0 -13
  186. data/spec/fixtures/macros.json +0 -24
  187. data/spec/fixtures/topic.json +0 -9
  188. data/spec/fixtures/topic_create.json +0 -14
  189. data/spec/fixtures/topic_destroy.json +0 -3
  190. data/spec/fixtures/topic_update.json +0 -14
  191. data/spec/fixtures/topics.json +0 -35
  192. data/spec/fixtures/user.json +0 -15
  193. data/spec/fixtures/users.json +0 -24
@@ -0,0 +1,32 @@
1
+ require 'helper'
2
+
3
+ describe Desk::Client do
4
+ context "Job" do
5
+
6
+ let(:endpoint) { "job" }
7
+ let(:id) { 1 }
8
+ let(:check_key) { "type" }
9
+ let(:check_value) { "bulk_case_update" }
10
+
11
+ include_context "basic configuration"
12
+
13
+ it_behaves_like "a list endpoint"
14
+
15
+ it_behaves_like "a show endpoint"
16
+
17
+ it_behaves_like "a create endpoint", {
18
+ :type => "bulk_case_update",
19
+ :case => {
20
+ :priority => 5,
21
+ :_links => {
22
+ :assigned_user => {
23
+ :href => "/api/v2/users/1",
24
+ :class => "user"
25
+ }
26
+ }
27
+ },
28
+ :case_ids => [ 1, 2, 3 ]
29
+ }
30
+
31
+ end
32
+ end
@@ -0,0 +1,31 @@
1
+ require 'helper'
2
+
3
+ describe Desk::Client do
4
+ context "Label" do
5
+
6
+ let(:endpoint) { "label" }
7
+ let(:id) { 1 }
8
+ let(:check_key) { "name" }
9
+ let(:check_value) { "MyLabel" }
10
+
11
+ include_context "basic configuration"
12
+
13
+ it_behaves_like "a list endpoint"
14
+
15
+ it_behaves_like "a show endpoint"
16
+
17
+ it_behaves_like "a create endpoint", {
18
+ :name => "MyLabel",
19
+ :description => "A Test Label",
20
+ :types => [ "case", "macro" ],
21
+ :color => "blue"
22
+ }
23
+
24
+ it_behaves_like "an update endpoint", { :name => "Label 5" } do
25
+ let(:check_value) { "Label 5" }
26
+ end
27
+
28
+ it_behaves_like "a delete endpoint"
29
+
30
+ end
31
+ end
@@ -1,204 +1,41 @@
1
1
  require 'helper'
2
2
 
3
3
  describe Desk::Client do
4
- Desk::Configuration::VALID_FORMATS.each do |format|
5
- context ".new(:format => '#{format}')" do
6
- before do
7
- @client = Desk::Client.new(:subdomain => "example", :format => format, :consumer_key => 'CK', :consumer_secret => 'CS', :oauth_token => 'OT', :oauth_token_secret => 'OS')
8
- end
4
+ context "Macro" do
9
5
 
10
- describe ".macros" do
6
+ let(:endpoint) { "macro" }
7
+ let(:id) { 1 }
8
+ let(:check_key) { "name" }
9
+ let(:check_value) { "Macro Macro" }
11
10
 
12
- context "lookup" do
11
+ include_context "basic configuration"
13
12
 
14
- before do
15
- stub_get("macros.#{format}").
16
- to_return(:body => fixture("macros.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
17
- end
13
+ it_behaves_like "a list endpoint"
18
14
 
19
- it "should get the correct resource" do
20
- @client.macros
21
- a_get("macros.#{format}").
22
- should have_been_made
23
- end
15
+ it_behaves_like "a show endpoint"
24
16
 
25
- it "should return up to 100 macros worth of extended information" do
26
- macros = @client.macros
17
+ it_behaves_like "a create endpoint", {
18
+ :name => "Macro Macro",
19
+ :description => "It's raining fire!"
20
+ }
27
21
 
28
- macros.results.should be_a Array
29
- macros.results.first.macro.id.should == 11
30
- end
22
+ it_behaves_like "an update endpoint", { :description => "On repeat" }
31
23
 
32
- end
33
- end
24
+ it_behaves_like "a delete endpoint"
34
25
 
35
- describe ".macro" do
26
+ context "Action" do
36
27
 
37
- context "lookup" do
28
+ let(:sub_endpoint) { "action" }
29
+ let(:sub_id) { 1 }
30
+ let(:check_key) { "value" }
31
+ let(:check_value) { "From a VIP Customer" }
38
32
 
39
- before do
40
- stub_get("macros/13.#{format}").
41
- to_return(:body => fixture("macro.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
42
- end
33
+ it_behaves_like "a sub list endpoint"
43
34
 
44
- it "should get the correct resource" do
45
- @client.macro(13)
46
- a_get("macros/13.#{format}").
47
- should have_been_made
48
- end
35
+ it_behaves_like "a sub show endpoint"
49
36
 
50
- it "should return up to 100 cases worth of extended information" do
51
- macro = @client.macro(13)
37
+ it_behaves_like "a sub update endpoint", { :enabled => false }
52
38
 
53
- macro.id.should == 13
54
- macro.name.should == "API Macro"
55
- end
56
-
57
- end
58
- end
59
-
60
- describe ".create_macro" do
61
-
62
- context "create" do
63
-
64
- before do
65
- stub_post("macros.#{format}").
66
- to_return(:body => fixture("macro_create.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
67
- end
68
-
69
- it "should post to the correct resource" do
70
- @client.create_macro("API Macro", :description => "Everything belongs here")
71
- a_post("macros.#{format}").
72
- should have_been_made
73
- end
74
-
75
- it "should return the new macro" do
76
- macro = @client.create_macro("API Macro", :description => "Everything belongs here")
77
-
78
- macro.id.should == 12
79
- macro.name.should == "API Macro"
80
- end
81
-
82
- end
83
- end
84
-
85
- describe ".update_macro" do
86
-
87
- context "update" do
88
-
89
- before do
90
- stub_put("macros/13.#{format}").
91
- to_return(:body => fixture("macro_update.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
92
- end
93
-
94
- it "should post to the correct resource" do
95
- @client.update_macro(13, :name => "Updated")
96
- a_put("macros/13.#{format}").
97
- should have_been_made
98
- end
99
-
100
- it "should return the new macro" do
101
- macro = @client.update_macro(13, :name => "Updated")
102
-
103
- macro.name.should == "Updated"
104
- end
105
-
106
- end
107
- end
108
-
109
- describe ".delete_macro" do
110
-
111
- context "delete" do
112
-
113
- before do
114
- stub_delete("macros/1.#{format}").
115
- to_return(:body => fixture("macro_destroy.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
116
- end
117
-
118
- it "should post to the correct resource" do
119
- @client.delete_macro(1)
120
- a_delete("macros/1.#{format}").
121
- should have_been_made
122
- end
123
-
124
- it "should return a successful response" do
125
- macro = @client.delete_macro(1)
126
- macro.success.should == true
127
- end
128
-
129
- end
130
- end
131
-
132
- describe ".macro_actions" do
133
-
134
- context "lookup" do
135
-
136
- before do
137
- stub_get("macros/1/actions.#{format}").
138
- to_return(:body => fixture("macro_actions.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
139
- end
140
-
141
- it "should get the correct resource" do
142
- @client.macro_actions(1)
143
- a_get("macros/1/actions.#{format}").
144
- should have_been_made
145
- end
146
-
147
- it "should return up to 100 macro actions worth of extended information" do
148
- macro_actions = @client.macro_actions(1)
149
-
150
- macro_actions.should be_a Array
151
- macro_actions.first.action.slug.should == "set-case-description"
152
- end
153
-
154
- end
155
- end
156
-
157
- describe ".macro_action" do
158
-
159
- context "lookup" do
160
-
161
- before do
162
- stub_get("macros/1/actions/set-case-description.#{format}").
163
- to_return(:body => fixture("macro_action.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
164
- end
165
-
166
- it "should get the correct resource" do
167
- @client.macro_action(1,"set-case-description")
168
- a_get("macros/1/actions/set-case-description.#{format}").
169
- should have_been_made
170
- end
171
-
172
- it "should return up to 100 macro actions worth of extended information" do
173
- macro_action = @client.macro_action(1,"set-case-description")
174
- macro_action.slug.should == "set-case-description"
175
- end
176
-
177
- end
178
- end
179
-
180
- describe ".update_macro_action" do
181
-
182
- context "update" do
183
-
184
- before do
185
- stub_put("macros/1/actions/set-case-description.#{format}").
186
- to_return(:body => fixture("macro_action_update.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
187
- end
188
-
189
- it "should post to the correct resource" do
190
- @client.update_macro_action(1, "set-case-description", :value => "This is my case description")
191
- a_put("macros/1/actions/set-case-description.#{format}").
192
- should have_been_made
193
- end
194
-
195
- it "should return the new macro" do
196
- macro_action = @client.update_macro_action(1, "set-case-description", :value => "This is my case description")
197
- macro_action.value.should == "Description to be applied"
198
- end
199
-
200
- end
201
- end
202
39
  end
203
40
  end
204
41
  end
@@ -0,0 +1,18 @@
1
+ require 'helper'
2
+
3
+ describe Desk::Client do
4
+ context "Rule" do
5
+
6
+ let(:endpoint) { "rule" }
7
+ let(:id) { 1 }
8
+ let(:check_key) { "name" }
9
+ let(:check_value) { "Assign to Support" }
10
+
11
+ include_context "basic configuration"
12
+
13
+ it_behaves_like "a list endpoint"
14
+
15
+ it_behaves_like "a show endpoint"
16
+
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ require 'helper'
2
+
3
+ describe Desk::Client do
4
+ context "Site Setting" do
5
+
6
+ let(:endpoint) { "site_setting" }
7
+ let(:id) { 1 }
8
+ let(:check_key) { "name" }
9
+ let(:check_value) { "company_name" }
10
+
11
+ include_context "basic configuration"
12
+
13
+ it_behaves_like "a list endpoint"
14
+
15
+ it_behaves_like "a show endpoint"
16
+
17
+ end
18
+ end
@@ -0,0 +1,42 @@
1
+ require 'helper'
2
+
3
+ describe Desk::Client do
4
+ context "System Message" do
5
+
6
+ let(:endpoint) { "system_message" }
7
+ let(:id) { nil }
8
+ let(:check_key) { "updated_at" }
9
+ let(:check_value) { "2013-11-22T22:49:20Z" }
10
+
11
+ include_context "basic configuration"
12
+
13
+ context "the current message" do
14
+
15
+ include_context "plural endpoint"
16
+
17
+ subject { client.send("show_#{endpoint}") }
18
+
19
+ before do
20
+ stub_get("#{endpoint}").to_return(:body => fixture(endpoint))
21
+ end
22
+
23
+ it "gets the correct resource" do
24
+ subject
25
+ expect(a_get("#{endpoint}")).to have_been_made
26
+ end
27
+
28
+ it { expect(subject).to be_a Hashie::Deash }
29
+
30
+ it "has a valid entry" do
31
+ expect(subject.id).to eq(id)
32
+ expect(subject.send(check_key)).to eq(check_value)
33
+ end
34
+
35
+ it "allows raw access" do
36
+ expect(subject.raw).to be_a Hashie::Deash
37
+ end
38
+
39
+ end
40
+
41
+ end
42
+ end
@@ -1,135 +1,54 @@
1
1
  require 'helper'
2
2
 
3
3
  describe Desk::Client do
4
- Desk::Configuration::VALID_FORMATS.each do |format|
5
- context ".new(:format => '#{format}')" do
6
- before do
7
- @client = Desk::Client.new(:subdomain => "example", :format => format, :consumer_key => 'CK', :consumer_secret => 'CS', :oauth_token => 'OT', :oauth_token_secret => 'OS')
8
- end
9
-
10
- describe ".topics" do
11
-
12
- context "lookup" do
13
-
14
- before do
15
- stub_get("topics.#{format}").
16
- to_return(:body => fixture("topics.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
17
- end
18
-
19
- it "should get the correct resource" do
20
- @client.topics
21
- a_get("topics.#{format}").
22
- should have_been_made
23
- end
24
-
25
- it "should return up to 100 topics worth of extended information" do
26
- topics = @client.topics
4
+ context "Topic" do
27
5
 
28
- topics.results.should be_a Array
29
- topics.results.first.topic.id.should == 1
30
- end
6
+ let(:endpoint) { "topic" }
7
+ let(:id) { 1 }
8
+ let(:check_key) { "name" }
9
+ let(:check_value) { "Customer Support" }
31
10
 
32
- end
33
- end
34
-
35
- describe ".topic" do
36
-
37
- context "lookup" do
11
+ include_context "basic configuration"
38
12
 
39
- before do
40
- stub_get("topics/1.#{format}").
41
- to_return(:body => fixture("topic.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
42
- end
13
+ it_behaves_like "a list endpoint"
43
14
 
44
- it "should get the correct resource" do
45
- @client.topic(1)
46
- a_get("topics/1.#{format}").
47
- should have_been_made
48
- end
15
+ it_behaves_like "a show endpoint"
49
16
 
50
- it "should return up to 100 cases worth of extended information" do
51
- topic = @client.topic(1)
52
-
53
- topic.id.should == 1
54
- topic.name.should == "General"
55
- end
56
-
57
- end
58
- end
17
+ it_behaves_like "a create endpoint", { :name => "Social Media" }
59
18
 
60
- describe ".create_topic" do
19
+ it_behaves_like "an update endpoint", { :name => "New Name" } do
20
+ let(:check_value) { "New Name" }
21
+ end
61
22
 
62
- context "create" do
23
+ it_behaves_like "a delete endpoint"
63
24
 
64
- before do
65
- stub_post("topics.#{format}").
66
- to_return(:body => fixture("topic_create.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
67
- end
25
+ context "Translation" do
68
26
 
69
- it "should post to the correct resource" do
70
- @client.create_topic("General", :description => "Everything belongs here")
71
- a_post("topics.#{format}").
72
- should have_been_made
73
- end
27
+ let(:sub_endpoint) { "translation" }
28
+ let(:sub_id) { "en_us" }
29
+ let(:check_key) { "name" }
30
+ let(:check_value) { "Customer Support" }
74
31
 
75
- it "should return the new topic" do
76
- topic = @client.create_topic("General", :description => "Everything belongs here")
32
+ it_behaves_like "a sub list endpoint"
77
33
 
78
- topic.id.should == 9
79
- topic.name.should == "General"
80
- topic.description.should == "Everything belongs here"
81
- end
34
+ it_behaves_like "a sub show endpoint"
82
35
 
83
- end
36
+ it_behaves_like "a sub create endpoint", {
37
+ :name => "Japanese",
38
+ :locale => "ja"
39
+ } do
40
+ let(:check_value) { "Japanese" }
84
41
  end
85
42
 
86
- describe ".update_topic" do
87
-
88
- context "update" do
89
-
90
- before do
91
- stub_put("topics/1.#{format}").
92
- to_return(:body => fixture("topic_update.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
93
- end
94
-
95
- it "should post to the correct resource" do
96
- @client.update_topic(1, :name => "Updated", :description => "Updated Description")
97
- a_put("topics/1.#{format}").
98
- should have_been_made
99
- end
100
-
101
- it "should return the new topic" do
102
- topic = @client.update_topic(1, :name => "Updated", :description => "Updated Description")
103
-
104
- topic.name.should == "Updated"
105
- topic.description.should == "Updated Description"
106
- end
107
-
108
- end
43
+ it_behaves_like "a sub update endpoint", {
44
+ :name => "Updated Japanese Translation"
45
+ } do
46
+ let(:sub_id) { "ja" }
47
+ let(:check_value) { "Updated Japanese Translation" }
109
48
  end
110
49
 
111
- describe ".delete_topic" do
112
-
113
- context "delete" do
114
-
115
- before do
116
- stub_delete("topics/1.#{format}").
117
- to_return(:body => fixture("topic_destroy.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
118
- end
50
+ it_behaves_like "a sub delete endpoint"
119
51
 
120
- it "should post to the correct resource" do
121
- @client.delete_topic(1)
122
- a_delete("topics/1.#{format}").
123
- should have_been_made
124
- end
125
-
126
- it "should return a successful response" do
127
- topic = @client.delete_topic(1)
128
- topic.success.should == true
129
- end
130
-
131
- end
132
- end
133
52
  end
134
53
  end
135
54
  end