discourse_api 0.28.0 → 0.28.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
  SHA256:
3
- metadata.gz: ac0d5e801885cf4c2f505292d4caa47c3f7716fe19691952f140ccc8177ef86d
4
- data.tar.gz: a96ae94f70262aef6334cf5aa2d2c740d33cee3235d69184dde0354173ff6134
3
+ metadata.gz: dfbf0f7096f27cfc80d554849976a9b061ea3915b31b74b52b81bc5642376516
4
+ data.tar.gz: 0bfad1c8ee9a66154f9eb0e20f5e95d04173480f40616670697d54139ca16120
5
5
  SHA512:
6
- metadata.gz: 7ee9c491b8a7864ff71f71d46df767c2d6daa1c1fe8e554ce5102c9a1ea72e4a86545a470959bddaf2fb3ecf815312a4195476bc24468016ec28377fabf4073b
7
- data.tar.gz: 500de1352f63b8b3d7ef0f48737e0e1720795091c6ede9f10d79786b8140787e7b176e0e2a00a18f99e9f8ef04163c1ac8de722136c4de4926a54363f3fea8df
6
+ metadata.gz: 67f10c18d2ec354583ac205f0d0da1897147260d2822c87c0032357686b919602b7e6d3fff9966f00e5851eff9a1d6258239d40554dca8220ee6564eb16511dd
7
+ data.tar.gz: cbe23cec7233b872bc9efa2f9ff50fdf1805b6033ca410f38124fea8720d48077246dd4eadec747858576a70e296403d3b7c64347ca822a6e8c33cc20a1bc92f
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.1] - 2018-10-26
6
+ ### Fixed
7
+ - Fixed non-URI chars in `check_username` method
8
+
5
9
  ## [0.28.0] - 2018-10-23
6
10
  ### Added
7
11
  - Added `check_username` method
@@ -94,7 +94,7 @@ module DiscourseApi
94
94
  end
95
95
 
96
96
  def check_username(username)
97
- response = get("/users/check_username.json?username=#{username}")
97
+ response = get("/users/check_username.json?username=#{CGI.escape(username)}")
98
98
  response[:body]
99
99
  end
100
100
  end
@@ -1,3 +1,3 @@
1
1
  module DiscourseApi
2
- VERSION = "0.28.0"
2
+ VERSION = "0.28.1"
3
3
  end
@@ -78,14 +78,15 @@ describe DiscourseApi::API::Groups do
78
78
  end
79
79
 
80
80
  describe "remove members" do
81
+ let(:url) { "http://localhost:3000/admin/groups/123/members.json?api_key=test_d7fd0429940&api_username=test_user&usernames=sam" }
82
+
81
83
  before do
82
- url = "http://localhost:3000/admin/groups/123/members.json?api_key=test_d7fd0429940&api_username=test_user&username=sam"
83
84
  stub_delete(url)
84
85
  end
85
86
 
86
87
  it "removes member" do
87
88
  subject.group_remove(123, username: "sam")
88
- expect(a_delete("http://localhost:3000/admin/groups/123/members.json?api_key=test_d7fd0429940&api_username=test_user&username=sam")).to have_been_made
89
+ expect(a_delete(url)).to have_been_made
89
90
  end
90
91
  end
91
92
 
@@ -287,9 +287,9 @@ describe DiscourseApi::API::Users do
287
287
 
288
288
  describe "#check_username" do
289
289
  let(:url) { "http://localhost:3000/users/check_username.json?username=sparrow&api_key=test_d7fd0429940&api_username=test_user" }
290
+ let(:body) { '{"available":false,"suggestion":"sparrow1"}' }
290
291
 
291
292
  before do
292
- body = '{"available":false,"suggestion":"sparrow1"}'
293
293
  stub_get(url).to_return(body: body, headers: { content_type: "application/json" })
294
294
  end
295
295
 
@@ -302,5 +302,20 @@ describe DiscourseApi::API::Users do
302
302
  result = subject.check_username("sparrow")
303
303
  expect(result['available']).to eq false
304
304
  end
305
+
306
+ context "when non-URI characters are used" do
307
+ let(:url) { "http://localhost:3000/users/check_username.json?username=1_%5B4%5D%21+%40the%24%23%3F&api_key=test_d7fd0429940&api_username=test_user" }
308
+ let(:body) { '{"errors":["must only include numbers, letters, dashes, and underscores"]}' }
309
+
310
+ it "escapes them" do
311
+ subject.check_username("1_[4]! @the$#?")
312
+ expect(a_get(url)).to have_been_made
313
+ end
314
+
315
+ it "returns the result" do
316
+ result = subject.check_username("1_[4]! @the$#?")
317
+ expect(result['errors'].first).to eq "must only include numbers, letters, dashes, and underscores"
318
+ end
319
+ end
305
320
  end
306
321
  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.28.0
4
+ version: 0.28.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: 2018-10-23 00:00:00.000000000 Z
14
+ date: 2018-10-26 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: faraday