discourse_api 1.1.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +23 -10
- data/.rubocop.yml +1 -1
- data/.streerc +2 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +1 -1
- data/README.md +0 -4
- data/discourse_api.gemspec +7 -4
- data/examples/backups.rb +5 -5
- data/examples/badges.rb +5 -5
- data/examples/bookmark_topic.rb +5 -5
- data/examples/category.rb +10 -6
- data/examples/change_topic_status.rb +12 -11
- data/examples/create_private_message.rb +6 -6
- data/examples/create_topic.rb +9 -9
- data/examples/create_update_category.rb +13 -16
- data/examples/create_user.rb +12 -11
- data/examples/dashboard.rb +5 -5
- data/examples/disposable_invite_tokens.rb +9 -10
- data/examples/example.rb +5 -5
- data/examples/group_set_user_notification_level.rb +18 -19
- data/examples/groups.rb +7 -7
- data/examples/invite_users.rb +5 -5
- data/examples/manage_api_keys.rb +6 -11
- data/examples/notifications.rb +6 -6
- data/examples/polls.rb +12 -12
- data/examples/post_action.rb +5 -5
- data/examples/search.rb +5 -5
- data/examples/sent_private_messages.rb +6 -6
- data/examples/sso.rb +6 -6
- data/examples/topic_lists.rb +5 -5
- data/examples/update_user.rb +15 -7
- data/examples/upload_file.rb +7 -7
- data/lib/discourse_api/api/api_key.rb +1 -3
- data/lib/discourse_api/api/backups.rb +1 -1
- data/lib/discourse_api/api/badges.rb +21 -6
- data/lib/discourse_api/api/categories.rb +69 -37
- data/lib/discourse_api/api/dashboard.rb +2 -6
- data/lib/discourse_api/api/groups.rb +68 -73
- data/lib/discourse_api/api/invite.rb +30 -30
- data/lib/discourse_api/api/notifications.rb +2 -3
- data/lib/discourse_api/api/params.rb +4 -14
- data/lib/discourse_api/api/polls.rb +9 -12
- data/lib/discourse_api/api/posts.rb +5 -8
- data/lib/discourse_api/api/private_messages.rb +9 -8
- data/lib/discourse_api/api/search.rb +2 -2
- data/lib/discourse_api/api/topics.rb +20 -22
- data/lib/discourse_api/api/uploads.rb +7 -5
- data/lib/discourse_api/api/user_actions.rb +2 -2
- data/lib/discourse_api/api/users.rb +31 -19
- data/lib/discourse_api/client.rb +58 -56
- data/lib/discourse_api/example_helper.rb +2 -4
- data/lib/discourse_api/single_sign_on.rb +53 -57
- data/lib/discourse_api/version.rb +1 -1
- data/spec/discourse_api/api/api_key_spec.rb +39 -25
- data/spec/discourse_api/api/backups_spec.rb +8 -3
- data/spec/discourse_api/api/badges_spec.rb +17 -7
- data/spec/discourse_api/api/categories_spec.rb +95 -53
- data/spec/discourse_api/api/email_spec.rb +17 -7
- data/spec/discourse_api/api/groups_spec.rb +71 -52
- data/spec/discourse_api/api/invite_spec.rb +41 -21
- data/spec/discourse_api/api/notifications_spec.rb +8 -4
- data/spec/discourse_api/api/params_spec.rb +5 -3
- data/spec/discourse_api/api/polls_spec.rb +53 -44
- data/spec/discourse_api/api/posts_spec.rb +33 -16
- data/spec/discourse_api/api/private_messages_spec.rb +25 -12
- data/spec/discourse_api/api/search_spec.rb +8 -3
- data/spec/discourse_api/api/site_settings_spec.rb +2 -3
- data/spec/discourse_api/api/sso_spec.rb +29 -25
- data/spec/discourse_api/api/topics_spec.rb +100 -31
- data/spec/discourse_api/api/uploads_spec.rb +16 -7
- data/spec/discourse_api/api/user_actions_spec.rb +13 -3
- data/spec/discourse_api/api/users_spec.rb +137 -55
- data/spec/discourse_api/client_spec.rb +32 -32
- data/spec/discourse_api/single_sign_on_spec.rb +15 -15
- data/spec/fixtures/categories.json +1 -1
- data/spec/spec_helper.rb +10 -15
- metadata +55 -12
@@ -1,13 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
require
|
2
|
+
require "spec_helper"
|
3
3
|
|
4
4
|
describe DiscourseApi::API::Notifications do
|
5
5
|
subject { DiscourseApi::Client.new("#{host}", "test_d7fd0429940", "test_user") }
|
6
6
|
|
7
7
|
describe "#notifications" do
|
8
|
-
|
9
8
|
before do
|
10
|
-
stub_get("#{host}/notifications.json").to_return(
|
9
|
+
stub_get("#{host}/notifications.json").to_return(
|
10
|
+
body: fixture("notifications.json"),
|
11
|
+
headers: {
|
12
|
+
content_type: "application/json",
|
13
|
+
},
|
14
|
+
)
|
11
15
|
end
|
12
16
|
|
13
17
|
it "requests the correct resource" do
|
@@ -19,7 +23,7 @@ describe DiscourseApi::API::Notifications do
|
|
19
23
|
notifications = subject.notifications
|
20
24
|
expect(notifications).to be_an Array
|
21
25
|
expect(notifications.first).to be_an Hash
|
22
|
-
expect(notifications[0][
|
26
|
+
expect(notifications[0]["notification_type"]).to eq(9)
|
23
27
|
end
|
24
28
|
end
|
25
29
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
require
|
2
|
+
require "spec_helper"
|
3
3
|
|
4
4
|
describe DiscourseApi::API::Params do
|
5
5
|
def params_for(h)
|
@@ -31,7 +31,9 @@ describe DiscourseApi::API::Params do
|
|
31
31
|
end
|
32
32
|
|
33
33
|
it "should include optional and default params when defined and provided" do
|
34
|
-
expect(params_for({ r1: "test", o1: "optional", d1: "override" }).to_h).to include(
|
34
|
+
expect(params_for({ r1: "test", o1: "optional", d1: "override" }).to_h).to include(
|
35
|
+
o1: "optional",
|
36
|
+
d1: "override",
|
37
|
+
)
|
35
38
|
end
|
36
|
-
|
37
39
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
require
|
2
|
+
require "spec_helper"
|
3
3
|
|
4
4
|
describe DiscourseApi::API::Polls do
|
5
5
|
subject { DiscourseApi::Client.new("#{host}", "test_d7fd0429940", "test_user") }
|
@@ -7,65 +7,74 @@ describe DiscourseApi::API::Polls do
|
|
7
7
|
describe "#poll vote" do
|
8
8
|
before do
|
9
9
|
path = "#{host}/polls/vote"
|
10
|
-
stub_put(path)
|
11
|
-
|
12
|
-
|
10
|
+
stub_put(path).to_return(
|
11
|
+
body: fixture("polls_vote.json"),
|
12
|
+
headers: {
|
13
|
+
content_type: "application/json",
|
14
|
+
},
|
15
|
+
)
|
13
16
|
end
|
14
17
|
|
15
18
|
it "requests the correct resource" do
|
16
|
-
options = [
|
17
|
-
subject.poll_vote post_id: 5, poll_name:
|
19
|
+
options = ["8b4736b1ae3dfb5a28088530f036f9e5"]
|
20
|
+
subject.poll_vote post_id: 5, poll_name: "poll", options: options
|
18
21
|
expect(a_put("#{host}/polls/vote")).to have_been_made
|
19
22
|
end
|
20
23
|
|
21
24
|
it "returns the expected votes" do
|
22
|
-
options = [
|
23
|
-
vote = subject.poll_vote post_id: 5, poll_name:
|
25
|
+
options = ["8b4736b1ae3dfb5a28088530f036f9e5"]
|
26
|
+
vote = subject.poll_vote post_id: 5, poll_name: "poll", options: options
|
24
27
|
expect(vote.body).to be_a Hash
|
25
|
-
expect(vote.body[
|
26
|
-
expect(vote.body[
|
28
|
+
expect(vote.body["poll"]["options"]).to be_an Array
|
29
|
+
expect(vote.body["vote"]).to eq(["8b4736b1ae3dfb5a28088530f036f9e5"])
|
27
30
|
end
|
28
31
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
32
|
+
describe "#poll toggle_status" do
|
33
|
+
before do
|
34
|
+
path = "#{host}/polls/toggle_status"
|
35
|
+
stub_put(path).to_return(
|
36
|
+
body: fixture("polls_toggle_status.json"),
|
37
|
+
headers: {
|
38
|
+
content_type: "application/json",
|
39
|
+
},
|
40
|
+
)
|
41
|
+
end
|
34
42
|
|
35
|
-
|
43
|
+
it "toggles the poll status to closed" do
|
44
|
+
subject.toggle_poll_status post_id: 5, poll_name: "poll", status: "closed"
|
45
|
+
expect(a_put("#{host}/polls/toggle_status")).to have_been_made
|
46
|
+
end
|
36
47
|
|
37
|
-
|
38
|
-
|
39
|
-
|
48
|
+
it "returns the expected results of closed poll" do
|
49
|
+
returned_poll_status =
|
50
|
+
subject.toggle_poll_status post_id: 5, poll_name: "poll", status: "closed"
|
51
|
+
expect(returned_poll_status.body).to be_a Hash
|
52
|
+
returned_poll_status.body["poll"]["options"].each { |g| expect(g).to be_a Hash }
|
53
|
+
end
|
40
54
|
end
|
41
55
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
before do
|
52
|
-
stub_get("#{host}/polls/voters.json?post_id=5&poll_name=poll")
|
53
|
-
.to_return(body: fixture("polls_voters.json"), headers: { content_type: "application/json" })
|
54
|
-
end
|
56
|
+
describe "#poll voters" do
|
57
|
+
before do
|
58
|
+
stub_get("#{host}/polls/voters.json?post_id=5&poll_name=poll").to_return(
|
59
|
+
body: fixture("polls_voters.json"),
|
60
|
+
headers: {
|
61
|
+
content_type: "application/json",
|
62
|
+
},
|
63
|
+
)
|
64
|
+
end
|
55
65
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
66
|
+
it "requests the correct resource" do
|
67
|
+
subject.poll_voters post_id: 5, poll_name: "poll"
|
68
|
+
expect(a_get("#{host}/polls/voters.json?post_id=5&poll_name=poll")).to have_been_made
|
69
|
+
end
|
60
70
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
71
|
+
it "returns the expected votes" do
|
72
|
+
voters = subject.poll_voters post_id: 5, poll_name: "poll"
|
73
|
+
expect(voters).to be_a Hash
|
74
|
+
voters.each { |g| expect(g).to be_an Array }
|
75
|
+
expect(voters["voters"]["e539a9df8700d0d05c69356a07b768cf"]).to be_an Array
|
76
|
+
expect(voters["voters"]["e539a9df8700d0d05c69356a07b768cf"][0]["id"]).to eq(356)
|
77
|
+
end
|
67
78
|
end
|
68
79
|
end
|
69
|
-
|
70
|
-
end
|
71
80
|
end
|
@@ -1,44 +1,59 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
require
|
2
|
+
require "spec_helper"
|
3
3
|
|
4
4
|
describe DiscourseApi::API::Posts do
|
5
|
-
let (:client) {
|
5
|
+
let (:client) {
|
6
|
+
DiscourseApi::Client.new("#{host}", "test_d7fd0429940", "test_user")
|
7
|
+
}
|
6
8
|
|
7
9
|
describe "#get_post" do
|
8
10
|
before do
|
9
|
-
stub_get("#{host}/posts/11.json").to_return(
|
11
|
+
stub_get("#{host}/posts/11.json").to_return(
|
12
|
+
body: fixture("post.json"),
|
13
|
+
headers: {
|
14
|
+
content_type: "application/json",
|
15
|
+
},
|
16
|
+
)
|
10
17
|
end
|
11
18
|
|
12
19
|
it "fetches a post" do
|
13
20
|
the_post = client.get_post(11)
|
14
21
|
expect(the_post).to be_a Hash
|
15
|
-
expect(the_post[
|
22
|
+
expect(the_post["id"]).to eq(11)
|
16
23
|
end
|
17
24
|
end
|
18
25
|
|
19
26
|
describe "#posts" do
|
20
27
|
before do
|
21
|
-
stub_get("#{host}/posts.json?before=0").to_return(
|
22
|
-
|
28
|
+
stub_get("#{host}/posts.json?before=0").to_return(
|
29
|
+
body: fixture("posts_latest.json"),
|
30
|
+
headers: {
|
31
|
+
content_type: "application/json",
|
32
|
+
},
|
33
|
+
)
|
34
|
+
stub_get("#{host}/posts.json?before=14").to_return(
|
35
|
+
body: fixture("posts_before.json"),
|
36
|
+
headers: {
|
37
|
+
content_type: "application/json",
|
38
|
+
},
|
39
|
+
)
|
23
40
|
end
|
24
41
|
|
25
42
|
it "fetches latest posts" do
|
26
43
|
the_posts = client.posts()
|
27
44
|
expect(the_posts).to be_a Hash
|
28
|
-
expect(the_posts[
|
45
|
+
expect(the_posts["latest_posts"][0]["id"]).to eq(15)
|
29
46
|
end
|
30
47
|
|
31
48
|
it "fetches posts before 14" do
|
32
49
|
the_posts = client.posts(before: 14)
|
33
50
|
expect(the_posts).to be_a Hash
|
34
|
-
expect(the_posts[
|
51
|
+
expect(the_posts["latest_posts"][0]["id"]).to eq(14)
|
35
52
|
end
|
36
53
|
end
|
37
54
|
|
38
55
|
describe "#wikify_post" do
|
39
|
-
before
|
40
|
-
stub_put("#{host}/posts/9999/wiki")
|
41
|
-
end
|
56
|
+
before { stub_put("#{host}/posts/9999/wiki") }
|
42
57
|
|
43
58
|
it "fails on unknown post" do
|
44
59
|
client.wikify_post(9999)
|
@@ -47,9 +62,7 @@ describe DiscourseApi::API::Posts do
|
|
47
62
|
end
|
48
63
|
|
49
64
|
describe "#delete_post" do
|
50
|
-
before
|
51
|
-
stub_delete("#{host}/posts/9999.json")
|
52
|
-
end
|
65
|
+
before { stub_delete("#{host}/posts/9999.json") }
|
53
66
|
|
54
67
|
it "deletes a post" do
|
55
68
|
client.delete_post(9999)
|
@@ -59,7 +72,12 @@ describe DiscourseApi::API::Posts do
|
|
59
72
|
|
60
73
|
describe "#post_action_users" do
|
61
74
|
before do
|
62
|
-
stub_get("#{host}/post_action_users.json?id=11&post_action_type_id=2").to_return(
|
75
|
+
stub_get("#{host}/post_action_users.json?id=11&post_action_type_id=2").to_return(
|
76
|
+
body: fixture("post_action_users.json"),
|
77
|
+
headers: {
|
78
|
+
content_type: "application/json",
|
79
|
+
},
|
80
|
+
)
|
63
81
|
end
|
64
82
|
|
65
83
|
it "fetches post_action_users" do
|
@@ -68,5 +86,4 @@ describe DiscourseApi::API::Posts do
|
|
68
86
|
expect(post_action_users["post_action_users"][0]["id"]).to eq(1286)
|
69
87
|
end
|
70
88
|
end
|
71
|
-
|
72
89
|
end
|
@@ -1,55 +1,68 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
require
|
2
|
+
require "spec_helper"
|
3
3
|
|
4
4
|
describe DiscourseApi::API::PrivateMessages do
|
5
5
|
subject { DiscourseApi::Client.new("#{host}", "test_d7fd0429940", "test_user") }
|
6
6
|
|
7
7
|
describe "#private_messages" do
|
8
8
|
before do
|
9
|
-
stub_get("#{host}/topics/private-messages/test_user.json").to_return(
|
9
|
+
stub_get("#{host}/topics/private-messages/test_user.json").to_return(
|
10
|
+
body: fixture("private_messages.json"),
|
11
|
+
headers: {
|
12
|
+
content_type: "application/json",
|
13
|
+
},
|
14
|
+
)
|
10
15
|
end
|
11
16
|
|
12
17
|
it "requests the correct resource" do
|
13
|
-
subject.private_messages(
|
18
|
+
subject.private_messages("test_user")
|
14
19
|
expect(a_get("#{host}/topics/private-messages/test_user.json")).to have_been_made
|
15
20
|
end
|
16
21
|
|
17
22
|
it "returns the requested private messages" do
|
18
|
-
private_messages = subject.private_messages(
|
23
|
+
private_messages = subject.private_messages("test_user")
|
19
24
|
expect(private_messages).to be_an Array
|
20
25
|
end
|
21
26
|
end
|
22
27
|
|
23
28
|
describe "#sent_private_messages" do
|
24
29
|
before do
|
25
|
-
stub_get("#{host}/topics/private-messages-sent/test_user.json").to_return(
|
30
|
+
stub_get("#{host}/topics/private-messages-sent/test_user.json").to_return(
|
31
|
+
body: fixture("private_messages.json"),
|
32
|
+
headers: {
|
33
|
+
content_type: "application/json",
|
34
|
+
},
|
35
|
+
)
|
26
36
|
end
|
27
37
|
|
28
38
|
it "requests the correct resource" do
|
29
|
-
subject.sent_private_messages(
|
39
|
+
subject.sent_private_messages("test_user")
|
30
40
|
expect(a_get("#{host}/topics/private-messages-sent/test_user.json")).to have_been_made
|
31
41
|
end
|
32
42
|
|
33
43
|
it "returns the requested sent private messages" do
|
34
|
-
private_messages = subject.sent_private_messages(
|
44
|
+
private_messages = subject.sent_private_messages("test_user")
|
35
45
|
expect(private_messages).to be_an Array
|
36
46
|
end
|
37
47
|
end
|
38
48
|
|
39
|
-
describe
|
49
|
+
describe "#create_pm" do
|
40
50
|
before do
|
41
51
|
stub_post("#{host}/posts")
|
42
52
|
subject.create_pm(
|
43
53
|
title: "Confidential: Hello World!",
|
44
54
|
raw: "This is the raw markdown for my private message",
|
45
|
-
target_recipients: "user1,user2"
|
55
|
+
target_recipients: "user1,user2",
|
46
56
|
)
|
47
57
|
end
|
48
58
|
|
49
59
|
it "makes a create private message request" do
|
50
|
-
expect(
|
51
|
-
|
52
|
-
|
60
|
+
expect(
|
61
|
+
a_post("#{host}/posts").with(
|
62
|
+
body:
|
63
|
+
"archetype=private_message&raw=This+is+the+raw+markdown+for+my+private+message&target_recipients=user1%2Cuser2&title=Confidential%3A+Hello+World%21",
|
64
|
+
),
|
65
|
+
).to have_been_made
|
53
66
|
end
|
54
67
|
end
|
55
68
|
end
|
@@ -1,12 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
require
|
2
|
+
require "spec_helper"
|
3
3
|
|
4
4
|
describe DiscourseApi::API::Search do
|
5
5
|
subject { DiscourseApi::Client.new("#{host}", "test_d7fd0429940", "test_user") }
|
6
6
|
|
7
7
|
describe "#search" do
|
8
8
|
before do
|
9
|
-
stub_get("#{host}/search").with(query: { q: "test" }).to_return(
|
9
|
+
stub_get("#{host}/search").with(query: { q: "test" }).to_return(
|
10
|
+
body: fixture("search.json"),
|
11
|
+
headers: {
|
12
|
+
content_type: "application/json",
|
13
|
+
},
|
14
|
+
)
|
10
15
|
end
|
11
16
|
|
12
17
|
it "requests the correct resource" do
|
@@ -25,7 +30,7 @@ describe DiscourseApi::API::Search do
|
|
25
30
|
end
|
26
31
|
|
27
32
|
it "raises an ArgumentError for empty string" do
|
28
|
-
expect { subject.search(
|
33
|
+
expect { subject.search("") }.to raise_error(ArgumentError)
|
29
34
|
end
|
30
35
|
end
|
31
36
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
require
|
2
|
+
require "spec_helper"
|
3
3
|
|
4
4
|
describe DiscourseApi::API::SiteSettings do
|
5
5
|
subject { DiscourseApi::Client.new("#{host}", "test_d7fd0429940", "test_user") }
|
@@ -11,8 +11,7 @@ describe DiscourseApi::API::SiteSettings do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
it "makes a site_settings_update request" do
|
14
|
-
expect(a_put("#{host}/admin/site_settings/foo")
|
15
|
-
.with(body: "foo=bar")).to have_been_made
|
14
|
+
expect(a_put("#{host}/admin/site_settings/foo").with(body: "foo=bar")).to have_been_made
|
16
15
|
end
|
17
16
|
end
|
18
17
|
end
|
@@ -1,36 +1,36 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
require
|
2
|
+
require "spec_helper"
|
3
3
|
|
4
4
|
describe DiscourseApi::API::SSO do
|
5
5
|
subject { DiscourseApi::Client.new("#{host}", "test_d7fd0429940", "test_user") }
|
6
6
|
|
7
7
|
let(:params) do
|
8
8
|
{
|
9
|
-
sso_secret
|
10
|
-
sso_url
|
11
|
-
name
|
12
|
-
username
|
13
|
-
email
|
14
|
-
external_id
|
15
|
-
suppress_welcome_message
|
16
|
-
avatar_url
|
17
|
-
title
|
18
|
-
avatar_force_update
|
19
|
-
add_groups
|
20
|
-
remove_groups
|
9
|
+
:sso_secret => "abc",
|
10
|
+
:sso_url => "www.google.com",
|
11
|
+
:name => "Some User",
|
12
|
+
:username => "some_user",
|
13
|
+
:email => "some@email.com",
|
14
|
+
:external_id => "abc",
|
15
|
+
:suppress_welcome_message => false,
|
16
|
+
:avatar_url => "https://www.website.com",
|
17
|
+
:title => "ruby",
|
18
|
+
:avatar_force_update => false,
|
19
|
+
:add_groups => %w[a b],
|
20
|
+
:remove_groups => %w[c d],
|
21
21
|
# old format (which results in custom.custom.field_1 in unsigned_payload)
|
22
|
-
|
22
|
+
"custom.field_1" => "tomato",
|
23
23
|
# new format
|
24
|
-
custom_fields
|
25
|
-
field_2:
|
26
|
-
}
|
24
|
+
:custom_fields => {
|
25
|
+
field_2: "potato",
|
26
|
+
},
|
27
27
|
}
|
28
28
|
end
|
29
29
|
let(:expected_unsigned_payload) do
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
30
|
+
"add_groups=a&add_groups=b&avatar_url=https%3A%2F%2Fwww.website.com" \
|
31
|
+
"&email=some%40email.com&external_id=abc&name=Some+User&remove_groups=c" \
|
32
|
+
"&remove_groups=d&title=ruby&username=some_user&custom.field_2=potato" \
|
33
|
+
"&custom.custom.field_1=tomato"
|
34
34
|
end
|
35
35
|
let(:sso_double) { DiscourseApi::SingleSignOn.parse_hash(params) }
|
36
36
|
|
@@ -38,21 +38,25 @@ describe DiscourseApi::API::SSO do
|
|
38
38
|
before do
|
39
39
|
stub_post(/.*sync_sso.*/).to_return(
|
40
40
|
body: fixture("user.json"),
|
41
|
-
headers: {
|
41
|
+
headers: {
|
42
|
+
content_type: "application/json",
|
43
|
+
},
|
42
44
|
)
|
43
45
|
end
|
44
46
|
|
45
|
-
it
|
47
|
+
it "assigns params to sso instance" do
|
46
48
|
allow(DiscourseApi::SingleSignOn).to(receive(:parse_hash).with(params).and_return(sso_double))
|
47
49
|
|
48
50
|
subject.sync_sso(params)
|
49
51
|
|
50
|
-
expect(sso_double.custom_fields).to eql(
|
52
|
+
expect(sso_double.custom_fields).to eql(
|
53
|
+
{ "custom.field_1" => "tomato", :field_2 => "potato" },
|
54
|
+
)
|
51
55
|
expect(sso_double.unsigned_payload).to eql(expected_unsigned_payload)
|
52
56
|
end
|
53
57
|
|
54
58
|
it "requests the correct resource" do
|
55
|
-
subject.sync_sso({ sso_secret
|
59
|
+
subject.sync_sso({ :sso_secret => "test_d7fd0429940", "custom.riffle_url" => "test" })
|
56
60
|
expect(a_post(/.*sync_sso.*/)).to have_been_made
|
57
61
|
end
|
58
62
|
end
|