discourse_api 0.39.3 → 0.43.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +54 -0
- data/.gitignore +0 -2
- data/.rubocop.yml +2 -6
- data/CHANGELOG.md +40 -8
- data/README.md +13 -2
- data/discourse_api.gemspec +4 -6
- data/examples/change_topic_status.rb +3 -4
- data/examples/create_topic.rb +10 -0
- data/lib/discourse_api/api/api_key.rb +0 -8
- data/lib/discourse_api/api/categories.rb +5 -0
- data/lib/discourse_api/api/groups.rb +10 -2
- data/lib/discourse_api/api/sso.rb +1 -15
- data/lib/discourse_api/api/topics.rb +8 -2
- data/lib/discourse_api/client.rb +20 -4
- data/lib/discourse_api/single_sign_on.rb +32 -3
- data/lib/discourse_api/version.rb +1 -1
- data/spec/discourse_api/api/api_key_spec.rb +2 -28
- data/spec/discourse_api/api/backups_spec.rb +2 -1
- data/spec/discourse_api/api/badges_spec.rb +2 -1
- data/spec/discourse_api/api/categories_spec.rb +9 -8
- data/spec/discourse_api/api/email_spec.rb +2 -1
- data/spec/discourse_api/api/groups_spec.rb +7 -6
- data/spec/discourse_api/api/notifications_spec.rb +1 -0
- data/spec/discourse_api/api/params_spec.rb +8 -7
- data/spec/discourse_api/api/polls_spec.rb +7 -6
- data/spec/discourse_api/api/posts_spec.rb +1 -0
- data/spec/discourse_api/api/private_messages_spec.rb +1 -0
- data/spec/discourse_api/api/search_spec.rb +4 -3
- data/spec/discourse_api/api/site_settings_spec.rb +2 -1
- data/spec/discourse_api/api/sso_spec.rb +46 -3
- data/spec/discourse_api/api/topics_spec.rb +20 -1
- data/spec/discourse_api/api/uploads_spec.rb +1 -0
- data/spec/discourse_api/api/user_actions_spec.rb +1 -0
- data/spec/discourse_api/api/users_spec.rb +4 -3
- data/spec/discourse_api/client_spec.rb +11 -10
- data/spec/fixtures/create_topic_with_tags.json +65 -0
- data/spec/spec_helper.rb +2 -1
- metadata +17 -45
- data/.travis.yml +0 -11
- data/spec/fixtures/generate_api_key.json +0 -12
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'spec_helper'
|
2
3
|
|
3
4
|
describe DiscourseApi::Client do
|
@@ -90,26 +91,26 @@ describe DiscourseApi::Client do
|
|
90
91
|
|
91
92
|
describe "#post" do
|
92
93
|
before do
|
93
|
-
stub_post("#{host}/test/post").with(body: { created: "object"})
|
94
|
+
stub_post("#{host}/test/post").with(body: { created: "object" })
|
94
95
|
subject.api_key = 'test_d7fd0429940'
|
95
96
|
subject.api_username = 'test_user'
|
96
97
|
end
|
97
98
|
|
98
99
|
it "allows custom post requests" do
|
99
100
|
subject.post("/test/post", { created: "object" })
|
100
|
-
expect(a_post("#{host}/test/post").with(body: { created: "object"})).to have_been_made
|
101
|
+
expect(a_post("#{host}/test/post").with(body: { created: "object" })).to have_been_made
|
101
102
|
end
|
102
103
|
|
103
104
|
context 'when using a host with a subdirectory' do
|
104
105
|
subject { DiscourseApi::Client.new("#{host}/forum") }
|
105
106
|
|
106
107
|
before do
|
107
|
-
stub_post("#{host}/forum/test/post").with(body: { created: "object"})
|
108
|
+
stub_post("#{host}/forum/test/post").with(body: { created: "object" })
|
108
109
|
end
|
109
110
|
|
110
111
|
it "allows custom post requests" do
|
111
112
|
subject.post("/test/post", { created: "object" })
|
112
|
-
expect(a_post("#{host}/forum/test/post").with(body: { created: "object"})).to have_been_made
|
113
|
+
expect(a_post("#{host}/forum/test/post").with(body: { created: "object" })).to have_been_made
|
113
114
|
end
|
114
115
|
end
|
115
116
|
end
|
@@ -144,18 +145,18 @@ describe DiscourseApi::Client do
|
|
144
145
|
it "catches 500 errors" do
|
145
146
|
connection = instance_double(Faraday::Connection)
|
146
147
|
allow(connection).to receive(:get).and_return(OpenStruct.new(env: { body: 'error page html' }, status: 500))
|
147
|
-
allow(
|
148
|
-
expect{subject.send(:request, :get, "/test")}.to raise_error DiscourseApi::Error
|
148
|
+
allow(Faraday).to receive(:new).and_return(connection)
|
149
|
+
expect { subject.send(:request, :get, "/test") }.to raise_error DiscourseApi::Error
|
149
150
|
end
|
150
151
|
|
151
152
|
it "catches Faraday errors" do
|
152
|
-
allow(
|
153
|
-
expect{subject.send(:request, :get, "/test")}.to raise_error DiscourseApi::Error
|
153
|
+
allow(Faraday).to receive(:new).and_raise(Faraday::ClientError.new("BOOM!"))
|
154
|
+
expect { subject.send(:request, :get, "/test") }.to raise_error DiscourseApi::Error
|
154
155
|
end
|
155
156
|
|
156
157
|
it "catches JSON::ParserError errors" do
|
157
|
-
allow(
|
158
|
-
expect{subject.send(:request, :get, "/test")}.to raise_error DiscourseApi::Error
|
158
|
+
allow(Faraday).to receive(:new).and_raise(JSON::ParserError.new("unexpected token"))
|
159
|
+
expect { subject.send(:request, :get, "/test") }.to raise_error DiscourseApi::Error
|
159
160
|
end
|
160
161
|
end
|
161
162
|
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
{
|
2
|
+
"id": 29,
|
3
|
+
"name": null,
|
4
|
+
"username": "blake",
|
5
|
+
"avatar_template": "/user_avatar/localhost/blake/{size}/3_2.png",
|
6
|
+
"created_at": "2020-07-09T15:52:43.802Z",
|
7
|
+
"cooked": "<p>cb8ee24eb3c5a81139958cf2b6bee9bd 2a7f7ea218e24c9ee6528cd383527f99 5a3006b92918946230385393a83b6005</p>",
|
8
|
+
"post_number": 1,
|
9
|
+
"post_type": 1,
|
10
|
+
"updated_at": "2020-07-09T15:52:43.802Z",
|
11
|
+
"reply_count": 0,
|
12
|
+
"reply_to_post_number": null,
|
13
|
+
"quote_count": 0,
|
14
|
+
"incoming_link_count": 0,
|
15
|
+
"reads": 0,
|
16
|
+
"readers_count": 0,
|
17
|
+
"score": 0,
|
18
|
+
"yours": true,
|
19
|
+
"topic_id": 21,
|
20
|
+
"topic_slug": "1412a036bfe-6480718525e-9f71f98ef46",
|
21
|
+
"display_username": null,
|
22
|
+
"primary_group_name": null,
|
23
|
+
"primary_group_flair_url": null,
|
24
|
+
"primary_group_flair_bg_color": null,
|
25
|
+
"primary_group_flair_color": null,
|
26
|
+
"version": 1,
|
27
|
+
"can_edit": true,
|
28
|
+
"can_delete": false,
|
29
|
+
"can_recover": false,
|
30
|
+
"can_wiki": true,
|
31
|
+
"user_title": null,
|
32
|
+
"actions_summary": [
|
33
|
+
{
|
34
|
+
"id": 3,
|
35
|
+
"can_act": true
|
36
|
+
},
|
37
|
+
{
|
38
|
+
"id": 4,
|
39
|
+
"can_act": true
|
40
|
+
},
|
41
|
+
{
|
42
|
+
"id": 8,
|
43
|
+
"can_act": true
|
44
|
+
},
|
45
|
+
{
|
46
|
+
"id": 7,
|
47
|
+
"can_act": true
|
48
|
+
}
|
49
|
+
],
|
50
|
+
"moderator": false,
|
51
|
+
"admin": true,
|
52
|
+
"staff": true,
|
53
|
+
"user_id": 1,
|
54
|
+
"draft_sequence": 0,
|
55
|
+
"hidden": false,
|
56
|
+
"trust_level": 1,
|
57
|
+
"deleted_at": null,
|
58
|
+
"user_deleted": false,
|
59
|
+
"edit_reason": null,
|
60
|
+
"can_view_edit_history": true,
|
61
|
+
"wiki": false,
|
62
|
+
"reviewable_id": null,
|
63
|
+
"reviewable_score_count": 0,
|
64
|
+
"reviewable_score_pending_count": 0
|
65
|
+
}
|
data/spec/spec_helper.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'simplecov'
|
2
3
|
|
3
4
|
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
|
@@ -18,7 +19,7 @@ RSpec.configure do |config|
|
|
18
19
|
end
|
19
20
|
end
|
20
21
|
|
21
|
-
WebMock.disable_net_connect!(:
|
22
|
+
WebMock.disable_net_connect!(allow_localhost: true)
|
22
23
|
|
23
24
|
def host
|
24
25
|
'http://localhost:3000'
|
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.
|
4
|
+
version: 0.43.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: 2020-
|
14
|
+
date: 2020-11-05 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: faraday
|
@@ -19,28 +19,28 @@ dependencies:
|
|
19
19
|
requirements:
|
20
20
|
- - "~>"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '0
|
22
|
+
version: '1.0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - "~>"
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '0
|
29
|
+
version: '1.0'
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: faraday_middleware
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
33
33
|
requirements:
|
34
34
|
- - "~>"
|
35
35
|
- !ruby/object:Gem::Version
|
36
|
-
version: '0
|
36
|
+
version: '1.0'
|
37
37
|
type: :runtime
|
38
38
|
prerelease: false
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
40
40
|
requirements:
|
41
41
|
- - "~>"
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: '0
|
43
|
+
version: '1.0'
|
44
44
|
- !ruby/object:Gem::Dependency
|
45
45
|
name: rack
|
46
46
|
requirement: !ruby/object:Gem::Requirement
|
@@ -101,16 +101,16 @@ dependencies:
|
|
101
101
|
name: rake
|
102
102
|
requirement: !ruby/object:Gem::Requirement
|
103
103
|
requirements:
|
104
|
-
- - "
|
104
|
+
- - ">="
|
105
105
|
- !ruby/object:Gem::Version
|
106
|
-
version:
|
106
|
+
version: 12.3.3
|
107
107
|
type: :development
|
108
108
|
prerelease: false
|
109
109
|
version_requirements: !ruby/object:Gem::Requirement
|
110
110
|
requirements:
|
111
|
-
- - "
|
111
|
+
- - ">="
|
112
112
|
- !ruby/object:Gem::Version
|
113
|
-
version:
|
113
|
+
version: 12.3.3
|
114
114
|
- !ruby/object:Gem::Dependency
|
115
115
|
name: rb-inotify
|
116
116
|
requirement: !ruby/object:Gem::Requirement
|
@@ -139,20 +139,6 @@ dependencies:
|
|
139
139
|
- - "~>"
|
140
140
|
- !ruby/object:Gem::Version
|
141
141
|
version: '3.4'
|
142
|
-
- !ruby/object:Gem::Dependency
|
143
|
-
name: rubocop
|
144
|
-
requirement: !ruby/object:Gem::Requirement
|
145
|
-
requirements:
|
146
|
-
- - "~>"
|
147
|
-
- !ruby/object:Gem::Version
|
148
|
-
version: '0.69'
|
149
|
-
type: :development
|
150
|
-
prerelease: false
|
151
|
-
version_requirements: !ruby/object:Gem::Requirement
|
152
|
-
requirements:
|
153
|
-
- - "~>"
|
154
|
-
- !ruby/object:Gem::Version
|
155
|
-
version: '0.69'
|
156
142
|
- !ruby/object:Gem::Dependency
|
157
143
|
name: simplecov
|
158
144
|
requirement: !ruby/object:Gem::Requirement
|
@@ -185,30 +171,16 @@ dependencies:
|
|
185
171
|
name: rubocop-discourse
|
186
172
|
requirement: !ruby/object:Gem::Requirement
|
187
173
|
requirements:
|
188
|
-
- - "
|
189
|
-
- !ruby/object:Gem::Version
|
190
|
-
version: '1.0'
|
191
|
-
type: :development
|
192
|
-
prerelease: false
|
193
|
-
version_requirements: !ruby/object:Gem::Requirement
|
194
|
-
requirements:
|
195
|
-
- - "~>"
|
196
|
-
- !ruby/object:Gem::Version
|
197
|
-
version: '1.0'
|
198
|
-
- !ruby/object:Gem::Dependency
|
199
|
-
name: rubocop-rspec
|
200
|
-
requirement: !ruby/object:Gem::Requirement
|
201
|
-
requirements:
|
202
|
-
- - "~>"
|
174
|
+
- - ">="
|
203
175
|
- !ruby/object:Gem::Version
|
204
|
-
version: '
|
176
|
+
version: '0'
|
205
177
|
type: :development
|
206
178
|
prerelease: false
|
207
179
|
version_requirements: !ruby/object:Gem::Requirement
|
208
180
|
requirements:
|
209
|
-
- - "
|
181
|
+
- - ">="
|
210
182
|
- !ruby/object:Gem::Version
|
211
|
-
version: '
|
183
|
+
version: '0'
|
212
184
|
description: Discourse API
|
213
185
|
email:
|
214
186
|
- sam.saffron@gmail.com
|
@@ -219,9 +191,9 @@ executables: []
|
|
219
191
|
extensions: []
|
220
192
|
extra_rdoc_files: []
|
221
193
|
files:
|
194
|
+
- ".github/workflows/ci.yml"
|
222
195
|
- ".gitignore"
|
223
196
|
- ".rubocop.yml"
|
224
|
-
- ".travis.yml"
|
225
197
|
- CHANGELOG.md
|
226
198
|
- Gemfile
|
227
199
|
- Guardfile
|
@@ -305,9 +277,9 @@ files:
|
|
305
277
|
- spec/fixtures/categories.json
|
306
278
|
- spec/fixtures/category_latest_topics.json
|
307
279
|
- spec/fixtures/category_topics.json
|
280
|
+
- spec/fixtures/create_topic_with_tags.json
|
308
281
|
- spec/fixtures/email_list_all.json
|
309
282
|
- spec/fixtures/email_settings.json
|
310
|
-
- spec/fixtures/generate_api_key.json
|
311
283
|
- spec/fixtures/generate_master_key.json
|
312
284
|
- spec/fixtures/group.json
|
313
285
|
- spec/fixtures/groups.json
|
@@ -399,9 +371,9 @@ test_files:
|
|
399
371
|
- spec/fixtures/categories.json
|
400
372
|
- spec/fixtures/category_latest_topics.json
|
401
373
|
- spec/fixtures/category_topics.json
|
374
|
+
- spec/fixtures/create_topic_with_tags.json
|
402
375
|
- spec/fixtures/email_list_all.json
|
403
376
|
- spec/fixtures/email_settings.json
|
404
|
-
- spec/fixtures/generate_api_key.json
|
405
377
|
- spec/fixtures/generate_master_key.json
|
406
378
|
- spec/fixtures/group.json
|
407
379
|
- spec/fixtures/groups.json
|
data/.travis.yml
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"api_key": {
|
3
|
-
"id": 5,
|
4
|
-
"key": "e722e04df8cf6d097d565ca04eea1ff8e9e8f09beb405bae6f0c79852916f334",
|
5
|
-
"user": {
|
6
|
-
"id": 2,
|
7
|
-
"username": "robin",
|
8
|
-
"uploaded_avatar_id": 3,
|
9
|
-
"avatar_template": "/user_avatar/localhost/robin/{size}/3.png"
|
10
|
-
}
|
11
|
-
}
|
12
|
-
}
|