discourse_api 0.27.0 → 0.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/discourse_api/api/groups.rb +15 -2
- data/lib/discourse_api/api/users.rb +5 -0
- data/lib/discourse_api/version.rb +1 -1
- data/spec/discourse_api/api/users_spec.rb +19 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac0d5e801885cf4c2f505292d4caa47c3f7716fe19691952f140ccc8177ef86d
|
4
|
+
data.tar.gz: a96ae94f70262aef6334cf5aa2d2c740d33cee3235d69184dde0354173ff6134
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ee9c491b8a7864ff71f71d46df767c2d6daa1c1fe8e554ce5102c9a1ea72e4a86545a470959bddaf2fb3ecf815312a4195476bc24468016ec28377fabf4073b
|
7
|
+
data.tar.gz: 500de1352f63b8b3d7ef0f48737e0e1720795091c6ede9f10d79786b8140787e7b176e0e2a00a18f99e9f8ef04163c1ac8de722136c4de4926a54363f3fea8df
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,10 @@
|
|
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.28.0] - 2018-10-23
|
6
|
+
### Added
|
7
|
+
- Added `check_username` method
|
8
|
+
|
5
9
|
## [0.27.0] - 2018-09-14
|
6
10
|
### Added
|
7
11
|
- Added `site_settings_update` method
|
@@ -84,8 +84,21 @@ module DiscourseApi
|
|
84
84
|
put("/admin/groups/#{group_id}/members.json", users)
|
85
85
|
end
|
86
86
|
|
87
|
-
def group_remove(group_id,
|
88
|
-
|
87
|
+
def group_remove(group_id, users)
|
88
|
+
users.keys.each do |key|
|
89
|
+
# Accept arrays and convert to comma-delimited string.
|
90
|
+
if users[key].respond_to? :join
|
91
|
+
users[key] = users[key].join(",")
|
92
|
+
end
|
93
|
+
|
94
|
+
# Accept non-plural user_id or username, but send pluralized version in the request.
|
95
|
+
if key.to_s[-1] != 's'
|
96
|
+
users["#{key}s"] = users[key]
|
97
|
+
users.delete(key)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
delete("/admin/groups/#{group_id}/members.json", users)
|
89
102
|
end
|
90
103
|
|
91
104
|
def delete_group(group_id)
|
@@ -92,6 +92,11 @@ module DiscourseApi
|
|
92
92
|
def delete_user(user_id, delete_posts = false)
|
93
93
|
delete("/admin/users/#{user_id}.json?delete_posts=#{delete_posts}")
|
94
94
|
end
|
95
|
+
|
96
|
+
def check_username(username)
|
97
|
+
response = get("/users/check_username.json?username=#{username}")
|
98
|
+
response[:body]
|
99
|
+
end
|
95
100
|
end
|
96
101
|
end
|
97
102
|
end
|
@@ -284,4 +284,23 @@ describe DiscourseApi::API::Users do
|
|
284
284
|
expect(result.status).to eq(200)
|
285
285
|
end
|
286
286
|
end
|
287
|
+
|
288
|
+
describe "#check_username" do
|
289
|
+
let(:url) { "http://localhost:3000/users/check_username.json?username=sparrow&api_key=test_d7fd0429940&api_username=test_user" }
|
290
|
+
|
291
|
+
before do
|
292
|
+
body = '{"available":false,"suggestion":"sparrow1"}'
|
293
|
+
stub_get(url).to_return(body: body, headers: { content_type: "application/json" })
|
294
|
+
end
|
295
|
+
|
296
|
+
it "requests the correct resource" do
|
297
|
+
subject.check_username("sparrow")
|
298
|
+
expect(a_get(url)).to have_been_made
|
299
|
+
end
|
300
|
+
|
301
|
+
it "returns the result" do
|
302
|
+
result = subject.check_username("sparrow")
|
303
|
+
expect(result['available']).to eq false
|
304
|
+
end
|
305
|
+
end
|
287
306
|
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.
|
4
|
+
version: 0.28.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: 2018-
|
14
|
+
date: 2018-10-23 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: faraday
|