DEV: Fix ruby warnings and other issues (#242)

DEV: Fix ruby warnings and other issues (#242)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 84de3ad..0492fe7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -17,7 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 - Pass params to get notifications API
 
 ### Deprecated
-- `invite_user_to_topic` has been deprecated, use `invite_user` instead.
+- `invite_user_to_topic` has been deprecated, use `invite_to_topic` instead.
 - `create_private_message` has been deprecated, use `create_pm` instead.
 
 ## [0.46.0] - 2021-04-12
diff --git a/examples/invite_users.rb b/examples/invite_users.rb
index ae5d711..97e675d 100644
--- a/examples/invite_users.rb
+++ b/examples/invite_users.rb
@@ -18,10 +18,10 @@ client.update_invite(invite["id"], email: "namee@example.com")
 client.resend_invite("namee@example.com")
 
 # invite to a topic
-client.invite_user_to_topic(email: "foo@bar.com", topic_id: 1)
+client.invite_to_topic(1, email: "foo@bar.com")
 
 # if the user is an admin you may invite to a group as well
-client.invite_user_to_topic(email: "foo@bar.com", group_ids: "1,2,3", topic_id: 1)
+client.invite_to_topic(1, email: "foo@bar.com", group_ids: "1,2,3")
 
 # retrieve invite
 puts client.retrieve_invite(email: "foo@bar.com")
diff --git a/lib/discourse_api/api/dashboard.rb b/lib/discourse_api/api/dashboard.rb
index 4de2867..41c056c 100644
--- a/lib/discourse_api/api/dashboard.rb
+++ b/lib/discourse_api/api/dashboard.rb
@@ -14,10 +14,10 @@ module DiscourseApi
         topics = global_reports[3]
         posts = global_reports[4]
 
-        totals = {
+        {
           'users' => users['total'],
           'topics' => topics['total'],
-          'posts' => posts['total']
+          'posts' => posts['total'],
         }
       end
     end
diff --git a/lib/discourse_api/api/site_settings.rb b/lib/discourse_api/api/site_settings.rb
index f8c5f6b..0e1f868 100644
--- a/lib/discourse_api/api/site_settings.rb
+++ b/lib/discourse_api/api/site_settings.rb
@@ -3,10 +3,10 @@ module DiscourseApi
   module API
     module SiteSettings
       def site_setting_update(args = {})
-        params = API.params(args)
-          .required(:name, :value).to_h
+        params = API.params(args).required(:name, :value).to_h
         new_site_setting = { params[:name] => params[:value] }
-        response = put("/admin/site_settings/#{params[:name]}", new_site_setting)
+
+        put("/admin/site_settings/#{params[:name]}", new_site_setting)
       end
     end
   end
diff --git a/lib/discourse_api/single_sign_on.rb b/lib/discourse_api/single_sign_on.rb
index 4c560ff..de64221 100644
--- a/lib/discourse_api/single_sign_on.rb
+++ b/lib/discourse_api/single_sign_on.rb
@@ -15,8 +15,7 @@ module DiscourseApi
     #NONCE_EXPIRY_TIME = 10.minutes # minutes is a rails method and is causing an error. Is this needed in the api?
 
     attr_accessor(*ACCESSORS)
-    attr_accessor :custom_fields
-    attr_writer :sso_secret, :sso_url
+    attr_writer :custom_fields, :sso_secret, :sso_url
 
     def self.sso_secret
       raise RuntimeError, "sso_secret not implemented on class, be sure to set it on instance"
@@ -27,7 +26,6 @@ module DiscourseApi
     end
 
     def self.parse_hash(payload)
-      payload
       sso = new
 
       sso.sso_secret = payload.delete(:sso_secret)
@@ -43,8 +41,10 @@ module DiscourseApi
         val = Array(val) if ARRAYS.include?(k) && !val.nil?
         sso.send("#{k}=", val)
       end
+
       # Set custom_fields
       sso.custom_fields = payload[:custom_fields]
+
       # Add custom_fields (old format)
       payload.each do |k, v|
         if field = k[/^custom\.(.+)$/, 1]
@@ -127,7 +127,7 @@ module DiscourseApi
 
       ACCESSORS.each do |k|
         next if (val = send k) == nil
-       payload[k] = val
+        payload[k] = val
       end
 
       if @custom_fields
diff --git a/spec/discourse_api/api/topics_spec.rb b/spec/discourse_api/api/topics_spec.rb
index 0adbabe..0370d0a 100644
--- a/spec/discourse_api/api/topics_spec.rb
+++ b/spec/discourse_api/api/topics_spec.rb
@@ -15,23 +15,18 @@ describe DiscourseApi::API::Topics do
     end
   end
 
-  describe "#invite_user_to_topic" do
+  describe "#invite_to_topic" do
     before do
       stub_post("#{host}/t/12/invite").to_return(body: fixture("topic_invite_user.json"), headers: { content_type: "application/json" })
     end
 
     it "requests the correct resource" do
-      subject.invite_user_to_topic(email: "fake_user@example.com", topic_id: 12)
-      expect(a_post("#{host}/t/12/invite")).to have_been_made
-    end
-
-    it "requests the correct resource with new method 'invite_to_topic'" do
       subject.invite_to_topic(12, email: "fake_user@example.com")
       expect(a_post("#{host}/t/12/invite")).to have_been_made
     end
 
     it "returns success" do
-      response = subject.invite_user_to_topic(email: "fake_user@example.com", topic_id: 12)
+      response = subject.invite_to_topic(12, email: "fake_user@example.com")
       expect(response).to be_a Hash
       expect(response['success']).to be_truthy
     end

GitHub sha: 745fb589afacb7edf0a50838382de7ebe17ccd69

This commit appears in #242 which was approved by tgxworld. It was merged by CvX.