discourse_api 0.36.0 → 0.37.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/discourse_api/api/badges.rb +1 -1
- data/lib/discourse_api/api/groups.rb +1 -2
- data/lib/discourse_api/api/users.rb +11 -1
- data/lib/discourse_api/version.rb +1 -1
- data/spec/discourse_api/api/badges_spec.rb +3 -3
- data/spec/discourse_api/api/groups_spec.rb +12 -0
- data/spec/discourse_api/api/users_spec.rb +35 -0
- data/spec/fixtures/user_grant_moderator.json +37 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11fa2d5cdcb3800c4bae5679d2644790c12d46c8d0797018f5a220a1f39d6ebe
|
4
|
+
data.tar.gz: fb596a1e54cac03f298492561d86afb226cb51c3a69400fb4461eeec3ab39836
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ed9ad86bc438113850a8313d9672b7dfb67fdcb70c1d2c0ca668544f8f9babf2e4e0aa3b4392f6887592fdaa821aaae12e3e2c53277dede8fef06e8ca626d17
|
7
|
+
data.tar.gz: 23ce5939282ca3686dd62f09eedb191d78592c64c1ce47f7e58df92368cda1471bf9da6c1697718307e96a1b12fb800ad85a63080798a91c95ee1669a9022f4a
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,12 @@
|
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
4
4
|
|
5
|
+
## [0.37.0] - 2019-09-23
|
6
|
+
### Added
|
7
|
+
- user-badges endpoint for full badges list
|
8
|
+
- expanded list of allowed messages
|
9
|
+
- grant/revoke moderation
|
10
|
+
|
5
11
|
## [0.36.0] - 2019-07-18
|
6
12
|
### Added
|
7
13
|
- Added poll methods
|
@@ -116,8 +116,7 @@ module DiscourseApi
|
|
116
116
|
end
|
117
117
|
|
118
118
|
def group_set_user_notification_level(group, user_id, notification_level)
|
119
|
-
|
120
|
-
response
|
119
|
+
post("/groups/#{group}/notifications?user_id=#{user_id}¬ification_level=#{notification_level}")
|
121
120
|
end
|
122
121
|
end
|
123
122
|
end
|
@@ -31,7 +31,8 @@ module DiscourseApi
|
|
31
31
|
|
32
32
|
def update_user(username, args)
|
33
33
|
args = API.params(args)
|
34
|
-
.optional(:name, :title, :bio_raw, :location, :website, :profile_background, :card_background
|
34
|
+
.optional(:name, :title, :bio_raw, :location, :website, :profile_background, :card_background,
|
35
|
+
:email_messages_level, :mailing_list_mode, :homepage_id, :theme_ids, :user_fields)
|
35
36
|
.to_h
|
36
37
|
put("/u/#{username}", args)
|
37
38
|
end
|
@@ -79,6 +80,15 @@ module DiscourseApi
|
|
79
80
|
response[:body]
|
80
81
|
end
|
81
82
|
|
83
|
+
def grant_moderation(user_id)
|
84
|
+
response = put("admin/users/#{user_id}/grant_moderation")
|
85
|
+
response[:body]
|
86
|
+
end
|
87
|
+
|
88
|
+
def revoke_moderation(user_id)
|
89
|
+
put("admin/users/#{user_id}/revoke_moderation")
|
90
|
+
end
|
91
|
+
|
82
92
|
def by_external_id(external_id)
|
83
93
|
response = get("/users/by-external/#{external_id}")
|
84
94
|
response[:body]['user']
|
@@ -20,14 +20,14 @@ describe DiscourseApi::API::Badges do
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
describe "#
|
23
|
+
describe "#user-badges" do
|
24
24
|
before do
|
25
|
-
stub_get("http://localhost:3000/
|
25
|
+
stub_get("http://localhost:3000/user-badges/test_user.json").to_return(body: fixture("user_badges.json"), headers: { content_type: "application/json" })
|
26
26
|
end
|
27
27
|
|
28
28
|
it "requests the correct resource" do
|
29
29
|
subject.user_badges('test_user')
|
30
|
-
expect(a_get("http://localhost:3000/
|
30
|
+
expect(a_get("http://localhost:3000/user-badges/test_user.json")).to have_been_made
|
31
31
|
end
|
32
32
|
|
33
33
|
it "returns the requested user badges" do
|
@@ -106,5 +106,17 @@ describe DiscourseApi::API::Groups do
|
|
106
106
|
end
|
107
107
|
end
|
108
108
|
|
109
|
+
describe "group user notification level" do
|
110
|
+
before do
|
111
|
+
stub_post("http://localhost:3000/groups/mygroup/notifications?user_id=77¬ification_level=3")
|
112
|
+
end
|
113
|
+
|
114
|
+
it "updates user's notification level for group" do
|
115
|
+
subject.group_set_user_notification_level("mygroup", 77, 3)
|
116
|
+
expect(a_post("http://localhost:3000/groups/mygroup/notifications?user_id=77¬ification_level=3"))
|
117
|
+
.to have_been_made
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
109
121
|
end
|
110
122
|
end
|
@@ -226,6 +226,41 @@ describe DiscourseApi::API::Users do
|
|
226
226
|
end
|
227
227
|
end
|
228
228
|
|
229
|
+
describe "#grant moderation" do
|
230
|
+
before do
|
231
|
+
url = "http://localhost:3000/admin/users/11/grant_moderation"
|
232
|
+
stub_put(url).to_return(body: fixture("user_grant_moderator.json"),
|
233
|
+
headers: { content_type: "application/json" })
|
234
|
+
end
|
235
|
+
|
236
|
+
it "makes the correct put request" do
|
237
|
+
subject.grant_moderation(11)
|
238
|
+
url = "http://localhost:3000/admin/users/11/grant_moderation"
|
239
|
+
expect(a_put(url)).to have_been_made
|
240
|
+
end
|
241
|
+
|
242
|
+
it "makes the user a moderator" do
|
243
|
+
result = subject.grant_moderation(11)
|
244
|
+
expect(result).to be_a Hash
|
245
|
+
expect(result['admin_user']['moderator']).to eq(true)
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
describe "#revoke moderation" do
|
250
|
+
before do
|
251
|
+
url = "http://localhost:3000/admin/users/11/revoke_moderation"
|
252
|
+
stub_put(url).to_return(body: '', status: 200)
|
253
|
+
end
|
254
|
+
|
255
|
+
it "makes the correct put request" do
|
256
|
+
result = subject.revoke_moderation(11)
|
257
|
+
url = "http://localhost:3000/admin/users/11/revoke_moderation"
|
258
|
+
expect(a_put(url)).to have_been_made
|
259
|
+
expect(result.status).to eq(200)
|
260
|
+
end
|
261
|
+
|
262
|
+
end
|
263
|
+
|
229
264
|
describe "#by_external_id" do
|
230
265
|
before do
|
231
266
|
stub_get("http://localhost:3000/users/by-external/1").to_return(body: fixture("user.json"), headers: { content_type: "application/json" })
|
@@ -0,0 +1,37 @@
|
|
1
|
+
{
|
2
|
+
"admin_user": {
|
3
|
+
"id": 11,
|
4
|
+
"username": "dave4",
|
5
|
+
"uploaded_avatar_id": null,
|
6
|
+
"avatar_template": "/letter_avatar/dave4/{size}/2.png",
|
7
|
+
"active": true,
|
8
|
+
"admin": false,
|
9
|
+
"moderator": true,
|
10
|
+
"last_seen_at": null,
|
11
|
+
"last_emailed_at": "2014-12-31T17:11:51.189Z",
|
12
|
+
"created_at": "2014-12-08T14:32:29.906Z",
|
13
|
+
"last_seen_age": null,
|
14
|
+
"last_emailed_age": "20d",
|
15
|
+
"created_at_age": "43d",
|
16
|
+
"username_lower": "dave4",
|
17
|
+
"trust_level": 0,
|
18
|
+
"trust_level_locked": false,
|
19
|
+
"flag_level": 0,
|
20
|
+
"title": null,
|
21
|
+
"suspended_at": null,
|
22
|
+
"suspended_till": null,
|
23
|
+
"suspended": null,
|
24
|
+
"blocked": false,
|
25
|
+
"time_read": "< 1m",
|
26
|
+
"days_visited": 0,
|
27
|
+
"posts_read_count": 0,
|
28
|
+
"topics_entered": 0,
|
29
|
+
"post_count": 0,
|
30
|
+
"can_send_activation_email": true,
|
31
|
+
"can_activate": false,
|
32
|
+
"can_deactivate": false,
|
33
|
+
"ip_address": "127.0.0.1",
|
34
|
+
"registration_ip_address": "127.0.0.1",
|
35
|
+
"single_sign_on_record": null
|
36
|
+
}
|
37
|
+
}
|
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.37.0
|
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: 2019-
|
14
|
+
date: 2019-09-23 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: faraday
|
@@ -308,6 +308,7 @@ files:
|
|
308
308
|
- spec/fixtures/user_badges.json
|
309
309
|
- spec/fixtures/user_create_success.json
|
310
310
|
- spec/fixtures/user_grant_admin.json
|
311
|
+
- spec/fixtures/user_grant_moderator.json
|
311
312
|
- spec/fixtures/user_list.json
|
312
313
|
- spec/fixtures/user_log_out_success.json
|
313
314
|
- spec/fixtures/user_update_avatar_success.json
|
@@ -397,6 +398,7 @@ test_files:
|
|
397
398
|
- spec/fixtures/user_badges.json
|
398
399
|
- spec/fixtures/user_create_success.json
|
399
400
|
- spec/fixtures/user_grant_admin.json
|
401
|
+
- spec/fixtures/user_grant_moderator.json
|
400
402
|
- spec/fixtures/user_list.json
|
401
403
|
- spec/fixtures/user_log_out_success.json
|
402
404
|
- spec/fixtures/user_update_avatar_success.json
|