Skip to content

Commit 8665b8e

Browse files
authored
Merge pull request #485 from zendesk/issue294-article-votes
Fix #294 Get article votes
2 parents 47c1a64 + 7c11f03 commit 8665b8e

File tree

4 files changed

+7
-15
lines changed

4 files changed

+7
-15
lines changed

lib/zendesk_api/collection.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,8 +420,6 @@ def set_association_from_options
420420
@collection_path ||= [@resource]
421421
end
422422

423-
## Fetch
424-
425423
def get_response(path)
426424
@error = nil
427425
@response = @client.connection.send(@verb || "get", path) do |req|

lib/zendesk_api/resources.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,9 @@ def resource_path
203203

204204
has Category
205205

206+
class Vote < Resource; end
206207
class Article < Resource
208+
has_many Vote
207209
end
208210

209211
has_many Article
@@ -215,6 +217,9 @@ def resource_path
215217
"help_center/articles"
216218
end
217219
end
220+
221+
class Vote < Resource; end
222+
has_many Vote
218223
end
219224

220225
class TopicSubscription < Resource

spec/live/article_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require 'core/spec_helper'
22

3-
describe ZendeskAPI::Article, :delete_after do
3+
RSpec.describe ZendeskAPI::Article, :delete_after do
44
it "expects article to exist" do
55
expect(article).not_to be_nil
66
end
@@ -34,6 +34,7 @@ def valid_attributes
3434

3535
expect(actual.count).to be > 0
3636
expect(actual.last.title).to eq("What are these sections and articles doing here?")
37+
expect(actual.last.votes.any?).to be(true) # Manually set in UI
3738
end
3839
end
3940
end

spec/live/topic_subscription_spec.rb

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,4 @@
88
end
99

1010
it_should_be_readable topic, :subscriptions
11-
12-
# TODO: This resource cannot be found since the response from the server
13-
# is using `subscription` as the model name, instead of `topic_subscription`
14-
# which is what the save handle_response method is expecting:
15-
# https://github.com/zendesk/zendesk_api_client_rb/blob/master/lib/zendesk_api/actions.rb#L5
16-
# we should modify it to use the `model_key` if present, but I don't want to do
17-
# that now, when I modifying a lot of tests
18-
xit "subscription can be found via the topic" do
19-
VCR.use_cassette("find_created_topic_subscription") do
20-
expect(topic.subscriptions.find(id: subscription.id)).not_to be nil
21-
end
22-
end
2311
end

0 commit comments

Comments
 (0)