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.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +23 -10
  3. data/.rubocop.yml +1 -1
  4. data/.streerc +2 -0
  5. data/CHANGELOG.md +5 -0
  6. data/Gemfile +1 -1
  7. data/README.md +0 -4
  8. data/discourse_api.gemspec +7 -4
  9. data/examples/backups.rb +5 -5
  10. data/examples/badges.rb +5 -5
  11. data/examples/bookmark_topic.rb +5 -5
  12. data/examples/category.rb +10 -6
  13. data/examples/change_topic_status.rb +12 -11
  14. data/examples/create_private_message.rb +6 -6
  15. data/examples/create_topic.rb +9 -9
  16. data/examples/create_update_category.rb +13 -16
  17. data/examples/create_user.rb +12 -11
  18. data/examples/dashboard.rb +5 -5
  19. data/examples/disposable_invite_tokens.rb +9 -10
  20. data/examples/example.rb +5 -5
  21. data/examples/group_set_user_notification_level.rb +18 -19
  22. data/examples/groups.rb +7 -7
  23. data/examples/invite_users.rb +5 -5
  24. data/examples/manage_api_keys.rb +6 -11
  25. data/examples/notifications.rb +6 -6
  26. data/examples/polls.rb +12 -12
  27. data/examples/post_action.rb +5 -5
  28. data/examples/search.rb +5 -5
  29. data/examples/sent_private_messages.rb +6 -6
  30. data/examples/sso.rb +6 -6
  31. data/examples/topic_lists.rb +5 -5
  32. data/examples/update_user.rb +15 -7
  33. data/examples/upload_file.rb +7 -7
  34. data/lib/discourse_api/api/api_key.rb +1 -3
  35. data/lib/discourse_api/api/backups.rb +1 -1
  36. data/lib/discourse_api/api/badges.rb +21 -6
  37. data/lib/discourse_api/api/categories.rb +69 -37
  38. data/lib/discourse_api/api/dashboard.rb +2 -6
  39. data/lib/discourse_api/api/groups.rb +68 -73
  40. data/lib/discourse_api/api/invite.rb +30 -30
  41. data/lib/discourse_api/api/notifications.rb +2 -3
  42. data/lib/discourse_api/api/params.rb +4 -14
  43. data/lib/discourse_api/api/polls.rb +9 -12
  44. data/lib/discourse_api/api/posts.rb +5 -8
  45. data/lib/discourse_api/api/private_messages.rb +9 -8
  46. data/lib/discourse_api/api/search.rb +2 -2
  47. data/lib/discourse_api/api/topics.rb +20 -22
  48. data/lib/discourse_api/api/uploads.rb +7 -5
  49. data/lib/discourse_api/api/user_actions.rb +2 -2
  50. data/lib/discourse_api/api/users.rb +31 -19
  51. data/lib/discourse_api/client.rb +58 -56
  52. data/lib/discourse_api/example_helper.rb +2 -4
  53. data/lib/discourse_api/single_sign_on.rb +53 -57
  54. data/lib/discourse_api/version.rb +1 -1
  55. data/spec/discourse_api/api/api_key_spec.rb +39 -25
  56. data/spec/discourse_api/api/backups_spec.rb +8 -3
  57. data/spec/discourse_api/api/badges_spec.rb +17 -7
  58. data/spec/discourse_api/api/categories_spec.rb +95 -53
  59. data/spec/discourse_api/api/email_spec.rb +17 -7
  60. data/spec/discourse_api/api/groups_spec.rb +71 -52
  61. data/spec/discourse_api/api/invite_spec.rb +41 -21
  62. data/spec/discourse_api/api/notifications_spec.rb +8 -4
  63. data/spec/discourse_api/api/params_spec.rb +5 -3
  64. data/spec/discourse_api/api/polls_spec.rb +53 -44
  65. data/spec/discourse_api/api/posts_spec.rb +33 -16
  66. data/spec/discourse_api/api/private_messages_spec.rb +25 -12
  67. data/spec/discourse_api/api/search_spec.rb +8 -3
  68. data/spec/discourse_api/api/site_settings_spec.rb +2 -3
  69. data/spec/discourse_api/api/sso_spec.rb +29 -25
  70. data/spec/discourse_api/api/topics_spec.rb +100 -31
  71. data/spec/discourse_api/api/uploads_spec.rb +16 -7
  72. data/spec/discourse_api/api/user_actions_spec.rb +13 -3
  73. data/spec/discourse_api/api/users_spec.rb +137 -55
  74. data/spec/discourse_api/client_spec.rb +32 -32
  75. data/spec/discourse_api/single_sign_on_spec.rb +15 -15
  76. data/spec/fixtures/categories.json +1 -1
  77. data/spec/spec_helper.rb +10 -15
  78. metadata +55 -12
@@ -1,13 +1,17 @@
1
1
  # frozen_string_literal: true
2
- require 'spec_helper'
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(body: fixture("notifications.json"), headers: { content_type: "application/json" })
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]['notification_type']).to eq(9)
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 'spec_helper'
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(o1: "optional", d1: "override")
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 'spec_helper'
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
- .to_return(body: fixture("polls_vote.json"), headers: { content_type: "application/json" })
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 = ['8b4736b1ae3dfb5a28088530f036f9e5']
17
- subject.poll_vote post_id: 5, poll_name: 'poll', options: options
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 = ['8b4736b1ae3dfb5a28088530f036f9e5']
23
- vote = subject.poll_vote post_id: 5, poll_name: 'poll', options: options
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['poll']['options']).to be_an Array
26
- expect(vote.body['vote']).to eq(['8b4736b1ae3dfb5a28088530f036f9e5'])
28
+ expect(vote.body["poll"]["options"]).to be_an Array
29
+ expect(vote.body["vote"]).to eq(["8b4736b1ae3dfb5a28088530f036f9e5"])
27
30
  end
28
31
 
29
- describe "#poll toggle_status" do
30
- before do
31
- path = "#{host}/polls/toggle_status"
32
- stub_put(path)
33
- .to_return(body: fixture("polls_toggle_status.json"), headers: { content_type: "application/json" })
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
- end
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
- it "toggles the poll status to closed" do
38
- subject.toggle_poll_status post_id: 5, poll_name: 'poll', status: 'closed'
39
- expect(a_put("#{host}/polls/toggle_status")).to have_been_made
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
- it "returns the expected results of closed poll" do
43
- returned_poll_status = subject.toggle_poll_status post_id: 5, poll_name: 'poll', status: 'closed'
44
- expect(returned_poll_status.body).to be_a Hash
45
- returned_poll_status.body['poll']['options'].each { |g| expect(g).to be_a Hash }
46
- end
47
-
48
- end
49
-
50
- describe "#poll voters" do
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
- it "requests the correct resource" do
57
- subject.poll_voters post_id: 5, poll_name: 'poll'
58
- expect(a_get("#{host}/polls/voters.json?post_id=5&poll_name=poll")).to have_been_made
59
- end
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
- it "returns the expected votes" do
62
- voters = subject.poll_voters post_id: 5, poll_name: 'poll'
63
- expect(voters).to be_a Hash
64
- voters.each { |g| expect(g).to be_an Array }
65
- expect(voters['voters']['e539a9df8700d0d05c69356a07b768cf']).to be_an Array
66
- expect(voters['voters']['e539a9df8700d0d05c69356a07b768cf'][0]['id']).to eq(356)
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 'spec_helper'
2
+ require "spec_helper"
3
3
 
4
4
  describe DiscourseApi::API::Posts do
5
- let (:client) { DiscourseApi::Client.new("#{host}", "test_d7fd0429940", "test_user") }
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(body: fixture("post.json"), headers: { content_type: "application/json" })
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['id']).to eq(11)
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(body: fixture("posts_latest.json"), headers: { content_type: "application/json" })
22
- stub_get("#{host}/posts.json?before=14").to_return(body: fixture("posts_before.json"), headers: { content_type: "application/json" })
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['latest_posts'][0]['id']).to eq(15)
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['latest_posts'][0]['id']).to eq(14)
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 do
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 do
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(body: fixture("post_action_users.json"), headers: { content_type: "application/json" })
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 'spec_helper'
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(body: fixture("private_messages.json"), headers: { content_type: "application/json" })
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('test_user')
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('test_user')
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(body: fixture("private_messages.json"), headers: { content_type: "application/json" })
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('test_user')
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('test_user')
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 '#create_pm' do
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(a_post("#{host}/posts").with(body:
51
- 'archetype=private_message&raw=This+is+the+raw+markdown+for+my+private+message&target_recipients=user1%2Cuser2&title=Confidential%3A+Hello+World%21')
52
- ).to have_been_made
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 'spec_helper'
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(body: fixture("search.json"), headers: { content_type: "application/json" })
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('') }.to raise_error(ArgumentError)
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 'spec_helper'
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 'spec_helper'
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: '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: ['a', 'b'],
20
- remove_groups: ['c', 'd'],
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
- 'custom.field_1' => 'tomato',
22
+ "custom.field_1" => "tomato",
23
23
  # new format
24
- custom_fields: {
25
- field_2: 'potato'
26
- }
24
+ :custom_fields => {
25
+ field_2: "potato",
26
+ },
27
27
  }
28
28
  end
29
29
  let(:expected_unsigned_payload) do
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'
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: { content_type: "application/json" }
41
+ headers: {
42
+ content_type: "application/json",
43
+ },
42
44
  )
43
45
  end
44
46
 
45
- it 'assigns params to sso instance' do
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({ 'custom.field_1' => 'tomato', :field_2 => 'potato' })
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: "test_d7fd0429940", "custom.riffle_url" => "test" })
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