Skip to content

Commit

Permalink
FIX: Revert formatting of sync_sso groups to match API
Browse files Browse the repository at this point in the history
  • Loading branch information
bgastelo committed Oct 27, 2023
1 parent e4b02bf commit 6390110
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/discourse_api/single_sign_on.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def self.parse_hash(payload)

val = val.to_i if FIXNUMS.include? k
val = %w[true false].include?(val) ? val == "true" : nil if BOOLS.include? k
val = val.split(",") if ARRAYS.include?(k) && !val.nil?
val = Array(val) if ARRAYS.include?(k) && !val.nil?
sso.send("#{k}=", val)
end

Expand Down
4 changes: 3 additions & 1 deletion spec/discourse_api/api/sso_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
:avatar_force_update => false,
:add_groups => %w[a b],
:remove_groups => %w[c d],
:groups => 'a,b',
# old format (which results in custom.custom.field_1 in unsigned_payload)
"custom.field_1" => "tomato",
# new format
Expand All @@ -28,7 +29,7 @@
end
let(:expected_unsigned_payload) do
"add_groups=a&add_groups=b&avatar_url=https%3A%2F%2Fwww.website.com" \
"&email=some%40email.com&external_id=abc&name=Some+User&remove_groups=c" \
"&email=some%40email.com&external_id=abc&groups=a%2Cb&name=Some+User&remove_groups=c" \
"&remove_groups=d&title=ruby&username=some_user&custom.field_2=potato" \
"&custom.custom.field_1=tomato"
end
Expand All @@ -45,6 +46,7 @@
end

it "assigns params to sso instance" do
RSpec::Support::ObjectFormatter.default_instance.max_formatted_output_length = nil
allow(DiscourseApi::SingleSignOn).to(receive(:parse_hash).with(params).and_return(sso_double))

subject.sync_sso(params)
Expand Down

0 comments on commit 6390110

Please sign in to comment.