discourse_api 0.10.0 → 0.10.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3af8ad3a0d23af70f79f3ddb2f65793588101c8f
|
4
|
+
data.tar.gz: 05ad2d4a02ea54c36327e6a8b2f0802cc9bf1481
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68449b81818c0e042ac7b55f016e8919b3f91a2ab58fdc84b07f4fd311a149f9d5854ef9dcd54516f52b8616d29e630833c68fae30bd0473550d7429459f4a35
|
7
|
+
data.tar.gz: 9992861878efb6dc3448b2fc6893c4e11b4f191091599ba2b4ab31d3d5c8e7137a40ae3aa7bc6cba7f1a0a16d010577d4724b19a32383a4c26b73bf49656fa17
|
data/examples/groups.rb
CHANGED
@@ -27,16 +27,24 @@ module DiscourseApi
|
|
27
27
|
url = "#{url}?page=#{params[:page]}"
|
28
28
|
end
|
29
29
|
response = get(url)
|
30
|
-
response[:body]['
|
30
|
+
if response[:body]['errors']
|
31
|
+
response[:body]['errors']
|
32
|
+
else
|
33
|
+
response[:body]['topic_list']['topics']
|
34
|
+
end
|
31
35
|
end
|
32
36
|
|
33
37
|
def category_top_topics(category_slug)
|
34
|
-
response = get("/
|
35
|
-
response[:body]['
|
38
|
+
response = get("/c/#{category_slug}/l/top.json")
|
39
|
+
if response[:body]['errors']
|
40
|
+
response[:body]['errors']
|
41
|
+
else
|
42
|
+
response[:body]['topic_list']['topics']
|
43
|
+
end
|
36
44
|
end
|
37
45
|
|
38
46
|
def category_new_topics(category_slug)
|
39
|
-
response = get("/
|
47
|
+
response = get("/c/#{category_slug}/l/new.json")
|
40
48
|
response[:body]['topic_list']['topics']
|
41
49
|
end
|
42
50
|
|
@@ -8,6 +8,9 @@ module DiscourseApi
|
|
8
8
|
# @option options [String] :type_filter Returns results of the specified type.
|
9
9
|
# @return [Array] Return results as an array of Hashes.
|
10
10
|
def search(term, options={})
|
11
|
+
raise ArgumentError.new("#{term} is required but not specified") unless term
|
12
|
+
raise ArgumentError.new("#{term} is required but not specified") unless !term.empty?
|
13
|
+
|
11
14
|
response = get('/search/query', options.merge(term: term))
|
12
15
|
response[:body]
|
13
16
|
end
|
@@ -41,7 +41,7 @@ describe DiscourseApi::API::Categories do
|
|
41
41
|
|
42
42
|
describe '#category_top_topics' do
|
43
43
|
before do
|
44
|
-
stub_get("http://localhost:3000/
|
44
|
+
stub_get("http://localhost:3000/c/category-slug/l/top.json?api_key=test_d7fd0429940&api_username=test_user")
|
45
45
|
.to_return(
|
46
46
|
body: fixture("category_topics.json"),
|
47
47
|
headers: { content_type: "application/json" }
|
@@ -56,7 +56,7 @@ describe DiscourseApi::API::Categories do
|
|
56
56
|
|
57
57
|
describe '#category_new_topics' do
|
58
58
|
before do
|
59
|
-
stub_get("http://localhost:3000/
|
59
|
+
stub_get("http://localhost:3000/c/category-slug/l/new.json?api_key=test_d7fd0429940&api_username=test_user")
|
60
60
|
.to_return(
|
61
61
|
body: fixture("category_topics.json"),
|
62
62
|
headers: { content_type: "application/json" }
|
@@ -18,5 +18,13 @@ describe DiscourseApi::API::Search do
|
|
18
18
|
expect(results).to be_an Array
|
19
19
|
expect(results.first).to be_a Hash
|
20
20
|
end
|
21
|
+
|
22
|
+
it "raises an ArgumentError for nil" do
|
23
|
+
expect { subject.search(nil) }.to raise_error(ArgumentError)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "raises an ArgumentError for empty string" do
|
27
|
+
expect { subject.search('') }.to raise_error(ArgumentError)
|
28
|
+
end
|
21
29
|
end
|
22
30
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: discourse_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Saffron
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2016-
|
14
|
+
date: 2016-05-05 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: faraday
|