discourse_api 0.27.0 → 0.28.0

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
  SHA256:
3
- metadata.gz: 027a0cf42cc22b38ef1231a6da581bd9712e8994b1146be486bf649a0a8fd43c
4
- data.tar.gz: 8411ff9d157d4878882f0627015413177fe5ff4a74534a5ac354f0ff600d4429
3
+ metadata.gz: ac0d5e801885cf4c2f505292d4caa47c3f7716fe19691952f140ccc8177ef86d
4
+ data.tar.gz: a96ae94f70262aef6334cf5aa2d2c740d33cee3235d69184dde0354173ff6134
5
5
  SHA512:
6
- metadata.gz: d4fa3b475556573c567702f6e5480d1fcd9ed30208beeec66bf784e38ae0a8c109708b2098481fd23a69efbe8f5bd91ffa463726b16fe0b3ac8cccc0f682db30
7
- data.tar.gz: 00a134e132b3b9731a7f0d2bc3b707627961110dab24f95fbe94db3f277347d7ae39d49cd496f61484e801f58516c07cc6c507ab7d1c7763622850683b4cb6ff
6
+ metadata.gz: 7ee9c491b8a7864ff71f71d46df767c2d6daa1c1fe8e554ce5102c9a1ea72e4a86545a470959bddaf2fb3ecf815312a4195476bc24468016ec28377fabf4073b
7
+ data.tar.gz: 500de1352f63b8b3d7ef0f48737e0e1720795091c6ede9f10d79786b8140787e7b176e0e2a00a18f99e9f8ef04163c1ac8de722136c4de4926a54363f3fea8df
@@ -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, user)
88
- delete("/admin/groups/#{group_id}/members.json", user)
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
@@ -1,3 +1,3 @@
1
1
  module DiscourseApi
2
- VERSION = "0.27.0"
2
+ VERSION = "0.28.0"
3
3
  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.27.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-09-14 00:00:00.000000000 Z
14
+ date: 2018-10-23 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: faraday