discourse_api 2.0.1 → 2.1.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/.github/workflows/ci.yml +6 -6
- data/.rubocop.yml +3 -0
- data/.streerc +1 -1
- data/CHANGELOG.md +10 -0
- data/config_example.yml +1 -1
- data/discourse_api.gemspec +36 -31
- data/lib/discourse_api/api/categories.rb +45 -54
- data/lib/discourse_api/api/topics.rb +13 -1
- data/lib/discourse_api/single_sign_on.rb +3 -3
- data/lib/discourse_api/version.rb +1 -1
- data/spec/discourse_api/api/api_key_spec.rb +11 -11
- data/spec/discourse_api/api/backups_spec.rb +3 -3
- data/spec/discourse_api/api/badges_spec.rb +5 -5
- data/spec/discourse_api/api/categories_spec.rb +37 -15
- data/spec/discourse_api/api/email_spec.rb +5 -5
- data/spec/discourse_api/api/groups_spec.rb +17 -17
- data/spec/discourse_api/api/invite_spec.rb +11 -11
- data/spec/discourse_api/api/notifications_spec.rb +3 -3
- data/spec/discourse_api/api/polls_spec.rb +7 -7
- data/spec/discourse_api/api/posts_spec.rb +1 -3
- data/spec/discourse_api/api/private_messages_spec.rb +6 -6
- data/spec/discourse_api/api/search_spec.rb +5 -5
- data/spec/discourse_api/api/site_settings_spec.rb +2 -2
- data/spec/discourse_api/api/sso_spec.rb +3 -3
- data/spec/discourse_api/api/topics_spec.rb +32 -32
- data/spec/discourse_api/api/uploads_spec.rb +3 -3
- data/spec/discourse_api/api/user_actions_spec.rb +5 -5
- data/spec/discourse_api/api/users_spec.rb +51 -51
- data/spec/discourse_api/client_spec.rb +33 -33
- data/spec/discourse_api/single_sign_on_spec.rb +23 -6
- data/spec/spec_helper.rb +1 -0
- metadata +9 -26
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
require "spec_helper"
|
|
3
3
|
|
|
4
4
|
describe DiscourseApi::API::Email do
|
|
5
|
-
subject { DiscourseApi::Client.new("#{host}", "test_d7fd0429940", "test_user") }
|
|
5
|
+
subject(:client) { DiscourseApi::Client.new("#{host}", "test_d7fd0429940", "test_user") }
|
|
6
6
|
|
|
7
7
|
describe "#email_settings" do
|
|
8
8
|
before do
|
|
@@ -15,12 +15,12 @@ describe DiscourseApi::API::Email do
|
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
it "requests the correct resource" do
|
|
18
|
-
|
|
18
|
+
client.email_settings
|
|
19
19
|
expect(a_get("#{host}/admin/email.json")).to have_been_made
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
it "returns the requested settings" do
|
|
23
|
-
settings =
|
|
23
|
+
settings = client.email_settings
|
|
24
24
|
expect(settings).to be_a Hash
|
|
25
25
|
expect(settings).to have_key("delivery_method")
|
|
26
26
|
expect(settings).to have_key("settings")
|
|
@@ -38,12 +38,12 @@ describe DiscourseApi::API::Email do
|
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
it "requests the correct resource" do
|
|
41
|
-
|
|
41
|
+
client.list_email("all")
|
|
42
42
|
expect(a_get("#{host}/admin/email/all.json")).to have_been_made
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
it "returns all email" do
|
|
46
|
-
all_email =
|
|
46
|
+
all_email = client.list_email("all")
|
|
47
47
|
expect(all_email).to be_an Array
|
|
48
48
|
end
|
|
49
49
|
end
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
require "spec_helper"
|
|
3
3
|
|
|
4
4
|
describe DiscourseApi::API::Groups do
|
|
5
|
-
subject { DiscourseApi::Client.new("#{host}", "test_d7fd0429940", "test_user") }
|
|
5
|
+
subject(:client) { DiscourseApi::Client.new("#{host}", "test_d7fd0429940", "test_user") }
|
|
6
6
|
|
|
7
7
|
describe "#groups" do
|
|
8
8
|
before do
|
|
@@ -15,12 +15,12 @@ describe DiscourseApi::API::Groups do
|
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
it "requests the correct resource" do
|
|
18
|
-
|
|
18
|
+
client.groups
|
|
19
19
|
expect(a_get("#{host}/groups.json")).to have_been_made
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
it "returns the requested groups" do
|
|
23
|
-
groups =
|
|
23
|
+
groups = client.groups
|
|
24
24
|
expect(groups).to be_an Array
|
|
25
25
|
groups.each { |g| expect(g).to be_a Hash }
|
|
26
26
|
end
|
|
@@ -32,20 +32,20 @@ describe DiscourseApi::API::Groups do
|
|
|
32
32
|
content_type: "application/json",
|
|
33
33
|
},
|
|
34
34
|
)
|
|
35
|
-
group =
|
|
35
|
+
group = client.group("some-group")
|
|
36
36
|
expect(group["basic_group"]).to be_a Hash
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
it "create new groups" do
|
|
40
40
|
stub_post("#{host}/admin/groups")
|
|
41
|
-
|
|
41
|
+
client.create_group(name: "test_group")
|
|
42
42
|
params = escape_params("group[name]" => "test_group", "group[visibility_level]" => 0)
|
|
43
43
|
expect(a_post("#{host}/admin/groups").with(body: params)).to have_been_made
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
it "update an existing group" do
|
|
47
47
|
stub_put("#{host}/groups/42")
|
|
48
|
-
|
|
48
|
+
client.update_group(42, name: "test_group")
|
|
49
49
|
params = escape_params("group[name]" => "test_group", "group[visibility_level]" => 0)
|
|
50
50
|
expect(a_put("#{host}/groups/42").with(body: params)).to have_been_made
|
|
51
51
|
end
|
|
@@ -54,14 +54,14 @@ describe DiscourseApi::API::Groups do
|
|
|
54
54
|
before { stub_request(:put, "#{host}/admin/groups/123/members.json") }
|
|
55
55
|
|
|
56
56
|
it "adds a single member by username" do
|
|
57
|
-
|
|
57
|
+
client.group_add(123, username: "sam")
|
|
58
58
|
expect(
|
|
59
59
|
a_request(:put, "#{host}/admin/groups/123/members.json").with(body: { usernames: "sam" }),
|
|
60
60
|
).to have_been_made
|
|
61
61
|
end
|
|
62
62
|
|
|
63
63
|
it "adds an array of members by username" do
|
|
64
|
-
|
|
64
|
+
client.group_add(123, usernames: %w[sam jeff])
|
|
65
65
|
expect(
|
|
66
66
|
a_request(:put, "#{host}/admin/groups/123/members.json").with(
|
|
67
67
|
body: {
|
|
@@ -72,14 +72,14 @@ describe DiscourseApi::API::Groups do
|
|
|
72
72
|
end
|
|
73
73
|
|
|
74
74
|
it "adds a single member by user_id" do
|
|
75
|
-
|
|
75
|
+
client.group_add(123, user_id: 456)
|
|
76
76
|
expect(
|
|
77
77
|
a_request(:put, "#{host}/admin/groups/123/members.json").with(body: { user_ids: "456" }),
|
|
78
78
|
).to have_been_made
|
|
79
79
|
end
|
|
80
80
|
|
|
81
81
|
it "adds an array of members by user_id" do
|
|
82
|
-
|
|
82
|
+
client.group_add(123, user_id: [123, 456])
|
|
83
83
|
expect(
|
|
84
84
|
a_request(:put, "#{host}/admin/groups/123/members.json").with(
|
|
85
85
|
body: {
|
|
@@ -96,7 +96,7 @@ describe DiscourseApi::API::Groups do
|
|
|
96
96
|
before { stub_delete(url) }
|
|
97
97
|
|
|
98
98
|
it "removes member" do
|
|
99
|
-
|
|
99
|
+
client.group_remove(123, username: "sam")
|
|
100
100
|
expect(a_delete(url)).to have_been_made
|
|
101
101
|
end
|
|
102
102
|
end
|
|
@@ -107,7 +107,7 @@ describe DiscourseApi::API::Groups do
|
|
|
107
107
|
before { stub_put(url) }
|
|
108
108
|
|
|
109
109
|
it "makes the member an owner" do
|
|
110
|
-
|
|
110
|
+
client.group_add_owners(123, usernames: "sam")
|
|
111
111
|
params = escape_params("group[usernames]" => "sam")
|
|
112
112
|
expect(
|
|
113
113
|
a_request(:put, "#{host}/admin/groups/123/owners.json").with(body: params),
|
|
@@ -121,7 +121,7 @@ describe DiscourseApi::API::Groups do
|
|
|
121
121
|
before { stub_delete(url) }
|
|
122
122
|
|
|
123
123
|
it "removes the owner role from the group member" do
|
|
124
|
-
|
|
124
|
+
client.group_remove_owners(123, usernames: "sam")
|
|
125
125
|
expect(a_delete(url)).to have_been_made
|
|
126
126
|
end
|
|
127
127
|
end
|
|
@@ -140,10 +140,10 @@ describe DiscourseApi::API::Groups do
|
|
|
140
140
|
content_type: "application/json",
|
|
141
141
|
},
|
|
142
142
|
)
|
|
143
|
-
members =
|
|
143
|
+
members = client.group_members("mygroup")
|
|
144
144
|
expect(a_get("#{host}/groups/mygroup/members.json?limit=100&offset=0")).to have_been_made
|
|
145
145
|
expect(members.length).to eq(100)
|
|
146
|
-
members =
|
|
146
|
+
members = client.group_members("mygroup", offset: 100)
|
|
147
147
|
expect(a_get("#{host}/groups/mygroup/members.json?limit=100&offset=100")).to have_been_made
|
|
148
148
|
expect(members.length).to eq(90)
|
|
149
149
|
end
|
|
@@ -156,7 +156,7 @@ describe DiscourseApi::API::Groups do
|
|
|
156
156
|
content_type: "application/json",
|
|
157
157
|
},
|
|
158
158
|
)
|
|
159
|
-
member_data =
|
|
159
|
+
member_data = client.group_members("mygroup", all: true)
|
|
160
160
|
expect(a_get("#{host}/groups/mygroup/members.json?limit=100&offset=0")).to have_been_made
|
|
161
161
|
expect(member_data["members"].length).to eq(100)
|
|
162
162
|
expect(member_data["owners"].length).to eq(7)
|
|
@@ -169,7 +169,7 @@ describe DiscourseApi::API::Groups do
|
|
|
169
169
|
before { stub_post("#{host}/groups/mygroup/notifications?user_id=77¬ification_level=3") }
|
|
170
170
|
|
|
171
171
|
it "updates user's notification level for group" do
|
|
172
|
-
|
|
172
|
+
client.group_set_user_notification_level("mygroup", 77, 3)
|
|
173
173
|
expect(
|
|
174
174
|
a_post("#{host}/groups/mygroup/notifications?user_id=77¬ification_level=3"),
|
|
175
175
|
).to have_been_made
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
require "spec_helper"
|
|
3
3
|
|
|
4
4
|
describe DiscourseApi::API::Invite do
|
|
5
|
-
subject { DiscourseApi::Client.new("#{host}", "test_d7fd0429940", "test_user") }
|
|
5
|
+
subject(:client) { DiscourseApi::Client.new("#{host}", "test_d7fd0429940", "test_user") }
|
|
6
6
|
|
|
7
7
|
describe "#invite_user" do
|
|
8
8
|
before do
|
|
@@ -15,12 +15,12 @@ describe DiscourseApi::API::Invite do
|
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
it "requests the correct resource" do
|
|
18
|
-
|
|
18
|
+
client.invite_user(email: "fake_user@example.com", group_ids: "41,42")
|
|
19
19
|
expect(a_post("#{host}/invites")).to have_been_made
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
it "returns success" do
|
|
23
|
-
response =
|
|
23
|
+
response = client.invite_user(email: "fake_user@example.com", group_ids: "41,42")
|
|
24
24
|
expect(response).to be_a Hash
|
|
25
25
|
expect(response["success"]).to be_truthy
|
|
26
26
|
end
|
|
@@ -37,7 +37,7 @@ describe DiscourseApi::API::Invite do
|
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
it "updates invite" do
|
|
40
|
-
|
|
40
|
+
client.update_invite(27, email: "namee@example.com")
|
|
41
41
|
expect(a_put("#{host}/invites/27")).to have_been_made
|
|
42
42
|
end
|
|
43
43
|
end
|
|
@@ -53,17 +53,17 @@ describe DiscourseApi::API::Invite do
|
|
|
53
53
|
end
|
|
54
54
|
|
|
55
55
|
it "requests the correct resource" do
|
|
56
|
-
|
|
56
|
+
client.retrieve_invite(email: "foo@bar.com")
|
|
57
57
|
expect(a_get("#{host}/invites/retrieve.json?email=foo@bar.com")).to have_been_made
|
|
58
58
|
end
|
|
59
59
|
|
|
60
60
|
it "returns the requested topics" do
|
|
61
|
-
invites =
|
|
61
|
+
invites = client.retrieve_invite(email: "foo@bar.com")
|
|
62
62
|
expect(invites).to be_an Hash
|
|
63
63
|
end
|
|
64
64
|
|
|
65
65
|
it "returns the requested invite" do
|
|
66
|
-
invites =
|
|
66
|
+
invites = client.retrieve_invite(email: "foo@bar.com")
|
|
67
67
|
expect(invites["email"]).to eq("foo@bar.com")
|
|
68
68
|
expect(invites).to have_key("invite_key")
|
|
69
69
|
end
|
|
@@ -82,7 +82,7 @@ describe DiscourseApi::API::Invite do
|
|
|
82
82
|
end
|
|
83
83
|
|
|
84
84
|
it "destroys all expired invites" do
|
|
85
|
-
|
|
85
|
+
client.destroy_all_expired_invites
|
|
86
86
|
expect(a_post(url)).to have_been_made
|
|
87
87
|
end
|
|
88
88
|
end
|
|
@@ -100,7 +100,7 @@ describe DiscourseApi::API::Invite do
|
|
|
100
100
|
end
|
|
101
101
|
|
|
102
102
|
it "resends all invites" do
|
|
103
|
-
|
|
103
|
+
client.resend_all_invites
|
|
104
104
|
expect(a_post(url)).to have_been_made
|
|
105
105
|
end
|
|
106
106
|
end
|
|
@@ -118,7 +118,7 @@ describe DiscourseApi::API::Invite do
|
|
|
118
118
|
end
|
|
119
119
|
|
|
120
120
|
it "resends invite" do
|
|
121
|
-
|
|
121
|
+
client.resend_invite("foo@bar.com")
|
|
122
122
|
expect(a_post(url)).to have_been_made
|
|
123
123
|
end
|
|
124
124
|
end
|
|
@@ -136,7 +136,7 @@ describe DiscourseApi::API::Invite do
|
|
|
136
136
|
end
|
|
137
137
|
|
|
138
138
|
it "destroys the invite" do
|
|
139
|
-
|
|
139
|
+
client.destroy_invite(27)
|
|
140
140
|
expect(a_delete(url)).to have_been_made
|
|
141
141
|
end
|
|
142
142
|
end
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
require "spec_helper"
|
|
3
3
|
|
|
4
4
|
describe DiscourseApi::API::Notifications do
|
|
5
|
-
subject { DiscourseApi::Client.new("#{host}", "test_d7fd0429940", "test_user") }
|
|
5
|
+
subject(:client) { DiscourseApi::Client.new("#{host}", "test_d7fd0429940", "test_user") }
|
|
6
6
|
|
|
7
7
|
describe "#notifications" do
|
|
8
8
|
before do
|
|
@@ -15,12 +15,12 @@ describe DiscourseApi::API::Notifications do
|
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
it "requests the correct resource" do
|
|
18
|
-
|
|
18
|
+
client.notifications
|
|
19
19
|
expect(a_get("#{host}/notifications.json")).to have_been_made
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
it "returns the requested notifications" do
|
|
23
|
-
notifications =
|
|
23
|
+
notifications = client.notifications
|
|
24
24
|
expect(notifications).to be_an Array
|
|
25
25
|
expect(notifications.first).to be_an Hash
|
|
26
26
|
expect(notifications[0]["notification_type"]).to eq(9)
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
require "spec_helper"
|
|
3
3
|
|
|
4
4
|
describe DiscourseApi::API::Polls do
|
|
5
|
-
subject { DiscourseApi::Client.new("#{host}", "test_d7fd0429940", "test_user") }
|
|
5
|
+
subject(:client) { DiscourseApi::Client.new("#{host}", "test_d7fd0429940", "test_user") }
|
|
6
6
|
|
|
7
7
|
describe "#poll vote" do
|
|
8
8
|
before do
|
|
@@ -17,13 +17,13 @@ describe DiscourseApi::API::Polls do
|
|
|
17
17
|
|
|
18
18
|
it "requests the correct resource" do
|
|
19
19
|
options = ["8b4736b1ae3dfb5a28088530f036f9e5"]
|
|
20
|
-
|
|
20
|
+
client.poll_vote post_id: 5, poll_name: "poll", options: options
|
|
21
21
|
expect(a_put("#{host}/polls/vote")).to have_been_made
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
it "returns the expected votes" do
|
|
25
25
|
options = ["8b4736b1ae3dfb5a28088530f036f9e5"]
|
|
26
|
-
vote =
|
|
26
|
+
vote = client.poll_vote post_id: 5, poll_name: "poll", options: options
|
|
27
27
|
expect(vote.body).to be_a Hash
|
|
28
28
|
expect(vote.body["poll"]["options"]).to be_an Array
|
|
29
29
|
expect(vote.body["vote"]).to eq(["8b4736b1ae3dfb5a28088530f036f9e5"])
|
|
@@ -41,13 +41,13 @@ describe DiscourseApi::API::Polls do
|
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
it "toggles the poll status to closed" do
|
|
44
|
-
|
|
44
|
+
client.toggle_poll_status post_id: 5, poll_name: "poll", status: "closed"
|
|
45
45
|
expect(a_put("#{host}/polls/toggle_status")).to have_been_made
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
it "returns the expected results of closed poll" do
|
|
49
49
|
returned_poll_status =
|
|
50
|
-
|
|
50
|
+
client.toggle_poll_status post_id: 5, poll_name: "poll", status: "closed"
|
|
51
51
|
expect(returned_poll_status.body).to be_a Hash
|
|
52
52
|
returned_poll_status.body["poll"]["options"].each { |g| expect(g).to be_a Hash }
|
|
53
53
|
end
|
|
@@ -64,12 +64,12 @@ describe DiscourseApi::API::Polls do
|
|
|
64
64
|
end
|
|
65
65
|
|
|
66
66
|
it "requests the correct resource" do
|
|
67
|
-
|
|
67
|
+
client.poll_voters post_id: 5, poll_name: "poll"
|
|
68
68
|
expect(a_get("#{host}/polls/voters.json?post_id=5&poll_name=poll")).to have_been_made
|
|
69
69
|
end
|
|
70
70
|
|
|
71
71
|
it "returns the expected votes" do
|
|
72
|
-
voters =
|
|
72
|
+
voters = client.poll_voters post_id: 5, poll_name: "poll"
|
|
73
73
|
expect(voters).to be_a Hash
|
|
74
74
|
voters.each { |g| expect(g).to be_an Array }
|
|
75
75
|
expect(voters["voters"]["e539a9df8700d0d05c69356a07b768cf"]).to be_an Array
|
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
require "spec_helper"
|
|
3
3
|
|
|
4
4
|
describe DiscourseApi::API::Posts do
|
|
5
|
-
let
|
|
6
|
-
DiscourseApi::Client.new("#{host}", "test_d7fd0429940", "test_user")
|
|
7
|
-
}
|
|
5
|
+
let(:client) { DiscourseApi::Client.new("#{host}", "test_d7fd0429940", "test_user") }
|
|
8
6
|
|
|
9
7
|
describe "#get_post" do
|
|
10
8
|
before do
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
require "spec_helper"
|
|
3
3
|
|
|
4
4
|
describe DiscourseApi::API::PrivateMessages do
|
|
5
|
-
subject { DiscourseApi::Client.new("#{host}", "test_d7fd0429940", "test_user") }
|
|
5
|
+
subject(:client) { DiscourseApi::Client.new("#{host}", "test_d7fd0429940", "test_user") }
|
|
6
6
|
|
|
7
7
|
describe "#private_messages" do
|
|
8
8
|
before do
|
|
@@ -15,12 +15,12 @@ describe DiscourseApi::API::PrivateMessages do
|
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
it "requests the correct resource" do
|
|
18
|
-
|
|
18
|
+
client.private_messages("test_user")
|
|
19
19
|
expect(a_get("#{host}/topics/private-messages/test_user.json")).to have_been_made
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
it "returns the requested private messages" do
|
|
23
|
-
private_messages =
|
|
23
|
+
private_messages = client.private_messages("test_user")
|
|
24
24
|
expect(private_messages).to be_an Array
|
|
25
25
|
end
|
|
26
26
|
end
|
|
@@ -36,12 +36,12 @@ describe DiscourseApi::API::PrivateMessages do
|
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
it "requests the correct resource" do
|
|
39
|
-
|
|
39
|
+
client.sent_private_messages("test_user")
|
|
40
40
|
expect(a_get("#{host}/topics/private-messages-sent/test_user.json")).to have_been_made
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
it "returns the requested sent private messages" do
|
|
44
|
-
private_messages =
|
|
44
|
+
private_messages = client.sent_private_messages("test_user")
|
|
45
45
|
expect(private_messages).to be_an Array
|
|
46
46
|
end
|
|
47
47
|
end
|
|
@@ -49,7 +49,7 @@ describe DiscourseApi::API::PrivateMessages do
|
|
|
49
49
|
describe "#create_pm" do
|
|
50
50
|
before do
|
|
51
51
|
stub_post("#{host}/posts")
|
|
52
|
-
|
|
52
|
+
client.create_pm(
|
|
53
53
|
title: "Confidential: Hello World!",
|
|
54
54
|
raw: "This is the raw markdown for my private message",
|
|
55
55
|
target_recipients: "user1,user2",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
require "spec_helper"
|
|
3
3
|
|
|
4
4
|
describe DiscourseApi::API::Search do
|
|
5
|
-
subject { DiscourseApi::Client.new("#{host}", "test_d7fd0429940", "test_user") }
|
|
5
|
+
subject(:client) { DiscourseApi::Client.new("#{host}", "test_d7fd0429940", "test_user") }
|
|
6
6
|
|
|
7
7
|
describe "#search" do
|
|
8
8
|
before do
|
|
@@ -15,22 +15,22 @@ describe DiscourseApi::API::Search do
|
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
it "requests the correct resource" do
|
|
18
|
-
|
|
18
|
+
client.search("test")
|
|
19
19
|
expect(a_get("#{host}/search").with(query: { q: "test" })).to have_been_made
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
it "returns the requested search" do
|
|
23
|
-
results =
|
|
23
|
+
results = client.search("test")
|
|
24
24
|
expect(results).to be_an Array
|
|
25
25
|
expect(results.first).to be_a Hash
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
it "raises an ArgumentError for nil" do
|
|
29
|
-
expect {
|
|
29
|
+
expect { client.search(nil) }.to raise_error(ArgumentError)
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
it "raises an ArgumentError for empty string" do
|
|
33
|
-
expect {
|
|
33
|
+
expect { client.search("") }.to raise_error(ArgumentError)
|
|
34
34
|
end
|
|
35
35
|
end
|
|
36
36
|
end
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
require "spec_helper"
|
|
3
3
|
|
|
4
4
|
describe DiscourseApi::API::SiteSettings do
|
|
5
|
-
subject { DiscourseApi::Client.new("#{host}", "test_d7fd0429940", "test_user") }
|
|
5
|
+
subject(:client) { DiscourseApi::Client.new("#{host}", "test_d7fd0429940", "test_user") }
|
|
6
6
|
|
|
7
7
|
describe "#site_setting_update" do
|
|
8
8
|
before do
|
|
9
9
|
stub_put("#{host}/admin/site_settings/foo")
|
|
10
|
-
|
|
10
|
+
client.site_setting_update(name: "foo", value: "bar")
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
it "makes a site_settings_update request" do
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
require "spec_helper"
|
|
3
3
|
|
|
4
4
|
describe DiscourseApi::API::SSO do
|
|
5
|
-
subject { DiscourseApi::Client.new("#{host}", "test_d7fd0429940", "test_user") }
|
|
5
|
+
subject(:client) { DiscourseApi::Client.new("#{host}", "test_d7fd0429940", "test_user") }
|
|
6
6
|
|
|
7
7
|
let(:params) do
|
|
8
8
|
{
|
|
@@ -47,7 +47,7 @@ describe DiscourseApi::API::SSO do
|
|
|
47
47
|
it "assigns params to sso instance" do
|
|
48
48
|
allow(DiscourseApi::SingleSignOn).to(receive(:parse_hash).with(params).and_return(sso_double))
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
client.sync_sso(params)
|
|
51
51
|
|
|
52
52
|
expect(sso_double.custom_fields).to eql(
|
|
53
53
|
{ "custom.field_1" => "tomato", :field_2 => "potato" },
|
|
@@ -56,7 +56,7 @@ describe DiscourseApi::API::SSO do
|
|
|
56
56
|
end
|
|
57
57
|
|
|
58
58
|
it "requests the correct resource" do
|
|
59
|
-
|
|
59
|
+
client.sync_sso({ :sso_secret => "test_d7fd0429940", "custom.riffle_url" => "test" })
|
|
60
60
|
expect(a_post(/.*sync_sso.*/)).to have_been_made
|
|
61
61
|
end
|
|
62
62
|
end
|