discourse_api 0.16.0 → 0.16.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
  SHA1:
3
- metadata.gz: dbc919ed6b4b910836e7c49ee0eeeba549089ab0
4
- data.tar.gz: 66a670a076264fed42fc8763358c94a698d2fc0d
3
+ metadata.gz: e3f92e1ed90f6df6ffb356583eedab8e43328a3c
4
+ data.tar.gz: 0351cf6da95703da9b167590833a72aacb59f688
5
5
  SHA512:
6
- metadata.gz: d29e787eb57d150ee9ceac985e41ac185a56316a2083a59f756e9f4a04ca3bb1ee0440cc772f33198c7222b1ff322dc67080c8ff1ac0610a550938a8b09c4c69
7
- data.tar.gz: 696ff6e30a2c947d7a3c4906ebff3cc43b55b71ca7c3c95e77d530b083ceece1a7bf6ffd2899da18a5976f7fc7becc817fc472c572e201f531979e5426b05f6e
6
+ metadata.gz: 27c8905ba8c68f2a06e11fa6dab834006c062676609242585ff5cc993b721247f78867b07d0ea617c56b9b4ea6a45b89d323232cadd8267b381a262b687bd56c
7
+ data.tar.gz: c32b0b29622c8ccff5e48bdb427f5dab52289ee481e6f60a8d36d036821dee69e5c6a19d7bfa5fe870ea3f96aff9e007e7fedaca0b8c9625c352d64e45fa8769
@@ -2,6 +2,11 @@
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.16.1] - 2017-06-23
6
+ ### Fixed
7
+ - `user_sso` should use `user_id` instead of `username`
8
+ - `upload_file` should also include optional `user_id` param
9
+
5
10
  ## [0.16.0] - 2017-05-14
6
11
  ### Added
7
12
  - added `upload_file`
@@ -3,7 +3,7 @@ module DiscourseApi
3
3
  module Uploads
4
4
  def upload_file(args)
5
5
  args = API.params(args)
6
- .optional(:file, :url)
6
+ .optional(:file, :url, :user_id)
7
7
  .default(type: 'composer', synchronous: true)
8
8
  .to_h
9
9
  post('/uploads', args)
@@ -10,8 +10,8 @@ module DiscourseApi
10
10
  response[:body]['user']
11
11
  end
12
12
 
13
- def user_sso(username)
14
- response = get("/admin/users/#{username.downcase}")
13
+ def user_sso(user_id)
14
+ response = get("/admin/users/#{user_id}.json")
15
15
  response[:body]['single_sign_on_record']
16
16
  end
17
17
 
@@ -1,3 +1,3 @@
1
1
  module DiscourseApi
2
- VERSION = "0.16.0"
2
+ VERSION = "0.16.1"
3
3
  end
@@ -24,6 +24,23 @@ describe DiscourseApi::API::Users do
24
24
  end
25
25
  end
26
26
 
27
+ describe "#user_sso" do
28
+ before do
29
+ stub_get("http://localhost:3000/admin/users/15.json?api_key=test_d7fd0429940&api_username=test_user").to_return(body: fixture("admin_user.json"), headers: { content_type: "application/json" })
30
+ end
31
+
32
+ it "requests the correct resource" do
33
+ subject.user_sso(15)
34
+ expect(a_get("http://localhost:3000/admin/users/15.json?api_key=test_d7fd0429940&api_username=test_user")).to have_been_made
35
+ end
36
+
37
+ it "has single_sign_on_record" do
38
+ user_sso = subject.user_sso(15)
39
+ expect(user_sso).to be_a Hash
40
+ expect(user_sso).to have_key("external_id")
41
+ end
42
+ end
43
+
27
44
  describe "#update_avatar" do
28
45
  before do
29
46
  stub_post("http://localhost:3000/uploads?api_key=test_d7fd0429940&api_username=test_user").to_return(body: fixture("upload_avatar.json"), headers: { content_type: "application/json" })
@@ -0,0 +1,96 @@
1
+ {
2
+ "id": 4,
3
+ "username": "47f6974294f6e3eb9686",
4
+ "avatar_template": "/letter_avatar_proxy/v2/letter/4/8e8cbc/{size}.png",
5
+ "active": false,
6
+ "admin": false,
7
+ "moderator": false,
8
+ "last_seen_at": null,
9
+ "last_emailed_at": null,
10
+ "created_at": "2017-06-23T16:30:22.539Z",
11
+ "last_seen_age": null,
12
+ "last_emailed_age": null,
13
+ "created_at_age": "17m",
14
+ "username_lower": "47f6974294f6e3eb9686",
15
+ "trust_level": 0,
16
+ "trust_level_locked": false,
17
+ "flag_level": 0,
18
+ "title": null,
19
+ "suspended_at": null,
20
+ "suspended_till": null,
21
+ "suspended": null,
22
+ "blocked": false,
23
+ "time_read": "< 1m",
24
+ "staged": false,
25
+ "days_visited": 0,
26
+ "posts_read_count": 0,
27
+ "topics_entered": 0,
28
+ "post_count": 0,
29
+ "name": "47f6974294f6e3eb9686f898f98a67d7",
30
+ "can_send_activation_email": true,
31
+ "can_activate": true,
32
+ "can_deactivate": true,
33
+ "ip_address": "192.168.56.1",
34
+ "registration_ip_address": null,
35
+ "can_grant_admin": true,
36
+ "can_revoke_admin": false,
37
+ "can_grant_moderation": true,
38
+ "can_revoke_moderation": false,
39
+ "can_impersonate": true,
40
+ "like_count": 0,
41
+ "like_given_count": 0,
42
+ "topic_count": 0,
43
+ "flags_given_count": 0,
44
+ "flags_received_count": 0,
45
+ "private_topics_count": 0,
46
+ "can_delete_all_posts": true,
47
+ "can_be_deleted": true,
48
+ "can_be_anonymized": true,
49
+ "suspend_reason": null,
50
+ "primary_group_id": null,
51
+ "badge_count": 0,
52
+ "warnings_received_count": 0,
53
+ "bounce_score": 0,
54
+ "reset_bounce_score_after": null,
55
+ "can_view_action_logs": true,
56
+ "single_sign_on_record": {
57
+ "user_id": 4,
58
+ "external_id": "847",
59
+ "last_payload": "nonce=bcbe1f1b1202fe597feaa2e3f23d566c&name=47f6974294f6e3eb9686f898f98a67d7&username=47f6974294f6e3eb9686f898f98a67d7&email=47f6974294f6e3eb9686f898f98a67d7%40test.com&require_activation=true&external_id=847",
60
+ "created_at": "2017-06-23T16:30:22.658Z",
61
+ "updated_at": "2017-06-23T16:30:22.658Z",
62
+ "external_username": "47f6974294f6e3eb9686f898f98a67d7",
63
+ "external_email": "47f6974294f6e3eb9686f898f98a67d7@test.com",
64
+ "external_name": "47f6974294f6e3eb9686f898f98a67d7",
65
+ "external_avatar_url": null
66
+ },
67
+ "approved_by": null,
68
+ "suspended_by": null,
69
+ "groups": [
70
+ {
71
+ "id": 10,
72
+ "automatic": true,
73
+ "name": "trust_level_0",
74
+ "display_name": "trust_level_0",
75
+ "user_count": 6,
76
+ "alias_level": 0,
77
+ "visible": true,
78
+ "automatic_membership_email_domains": null,
79
+ "automatic_membership_retroactive": false,
80
+ "primary_group": false,
81
+ "title": null,
82
+ "grant_trust_level": null,
83
+ "incoming_email": null,
84
+ "has_messages": false,
85
+ "flair_url": null,
86
+ "flair_bg_color": null,
87
+ "flair_color": null,
88
+ "bio_raw": null,
89
+ "bio_cooked": null,
90
+ "public": false,
91
+ "allow_membership_requests": false,
92
+ "full_name": null,
93
+ "default_notification_level": 3
94
+ }
95
+ ]
96
+ }
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.16.0
4
+ version: 0.16.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: 2017-05-14 00:00:00.000000000 Z
14
+ date: 2017-06-23 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: faraday
@@ -246,6 +246,7 @@ files:
246
246
  - spec/discourse_api/api/uploads_spec.rb
247
247
  - spec/discourse_api/api/users_spec.rb
248
248
  - spec/discourse_api/client_spec.rb
249
+ - spec/fixtures/admin_user.json
249
250
  - spec/fixtures/api.json
250
251
  - spec/fixtures/backups.json
251
252
  - spec/fixtures/badges.json
@@ -326,6 +327,7 @@ test_files:
326
327
  - spec/discourse_api/api/uploads_spec.rb
327
328
  - spec/discourse_api/api/users_spec.rb
328
329
  - spec/discourse_api/client_spec.rb
330
+ - spec/fixtures/admin_user.json
329
331
  - spec/fixtures/api.json
330
332
  - spec/fixtures/backups.json
331
333
  - spec/fixtures/badges.json