Browse Source

Merge branch 'master' into fix_more_rubocop_issues

Paulo Margarido 3 years ago
parent
commit
7ae659541d
59 changed files with 212 additions and 481 deletions
  1. 5 0
      .rubocop.yml
  2. 0 276
      .rubocop_todo.yml
  3. 7 2
      lib/active_resource/json_errors.rb
  4. 2 2
      lib/shopify_api/countable.rb
  5. 4 6
      lib/shopify_api/graphql.rb
  6. 10 9
      lib/shopify_api/message_enricher.rb
  7. 0 1
      lib/shopify_api/meta.rb
  8. 1 1
      lib/shopify_api/metafields.rb
  9. 1 1
      lib/shopify_api/resources/announcement.rb
  10. 0 1
      lib/shopify_api/resources/assigned_fulfillment_order.rb
  11. 1 1
      lib/shopify_api/resources/cart.rb
  12. 19 5
      lib/shopify_api/resources/comment.rb
  13. 11 3
      lib/shopify_api/resources/fulfillment.rb
  14. 16 16
      lib/shopify_api/resources/fulfillment_order.rb
  15. 2 2
      lib/shopify_api/resources/fulfillment_v2.rb
  16. 1 1
      lib/shopify_api/resources/image.rb
  17. 2 3
      lib/shopify_api/resources/inventory_level.rb
  18. 0 1
      lib/shopify_api/resources/location.rb
  19. 0 1
      lib/shopify_api/resources/price_rule.rb
  20. 4 3
      lib/shopify_api/resources/product.rb
  21. 1 1
      lib/shopify_api/resources/recurring_application_charge.rb
  22. 0 1
      lib/shopify_api/resources/smart_collection.rb
  23. 3 2
      lib/shopify_api/resources/variant.rb
  24. 3 5
      lib/shopify_api/session.rb
  25. 1 1
      shopify_api.gemspec
  26. 0 1
      test/access_token_test.rb
  27. 0 1
      test/active_resource/json_errors_test.rb
  28. 0 1
      test/api_version_test.rb
  29. 3 5
      test/application_charge_test.rb
  30. 0 2
      test/article_test.rb
  31. 2 2
      test/assigned_fulfillment_order_test.rb
  32. 1 3
      test/base_test.rb
  33. 2 2
      test/carrier_service_test.rb
  34. 1 1
      test/cart_test.rb
  35. 0 1
      test/collection_listing_test.rb
  36. 18 18
      test/collection_test.rb
  37. 1 0
      test/customer_saved_search_test.rb
  38. 0 1
      test/customer_test.rb
  39. 28 27
      test/fulfillment_order_test.rb
  40. 12 12
      test/fulfillment_service_test.rb
  41. 16 16
      test/fulfillment_test.rb
  42. 2 2
      test/fulfillment_v2_test.rb
  43. 1 0
      test/gift_card_test.rb
  44. 2 2
      test/inventory_level_test.rb
  45. 1 2
      test/marketing_event_test.rb
  46. 0 1
      test/message_enricher_test.rb
  47. 7 9
      test/meta_test.rb
  48. 6 2
      test/order_test.rb
  49. 2 3
      test/pagination_test.rb
  50. 0 1
      test/product_listing_test.rb
  51. 1 2
      test/recurring_application_charge_test.rb
  52. 0 1
      test/refund_test.rb
  53. 2 2
      test/resource_feedback_test.rb
  54. 3 4
      test/session_test.rb
  55. 0 2
      test/storefront_access_token_test.rb
  56. 0 1
      test/tax_service_test.rb
  57. 4 4
      test/test_helper.rb
  58. 0 2
      test/usage_charge_test.rb
  59. 3 3
      test/user_test.rb

+ 5 - 0
.rubocop.yml

@@ -21,3 +21,8 @@ Lint/UnderscorePrefixedVariableName:
   Exclude:
     # This is an internal attribute and we want to make sure it's called _headers
     - 'lib/shopify_api/resources/base.rb'
+
+Naming/AccessorMethodName:
+  Exclude:
+    # This comes from activesupport, so we can't rename it
+    - 'test/detailed_log_subscriber_test.rb'

+ 0 - 276
.rubocop_todo.yml

@@ -6,196 +6,6 @@
 # Note that changes in the inspected code, or installation of new
 # versions of RuboCop, may require this file to be generated again.
 
-# Offense count: 1
-# Cop supports --auto-correct.
-# Configuration parameters: EnforcedStyle, IndentOneStep, IndentationWidth.
-# SupportedStyles: case, end
-Layout/CaseIndentation:
-  Exclude:
-    - 'lib/shopify_api/countable.rb'
-
-# Offense count: 9
-# Cop supports --auto-correct.
-Layout/ClosingParenthesisIndentation:
-  Exclude:
-    - 'lib/shopify_api/resources/product.rb'
-    - 'lib/shopify_api/resources/variant.rb'
-    - 'test/application_charge_test.rb'
-    - 'test/assigned_fulfillment_order_test.rb'
-    - 'test/collection_test.rb'
-    - 'test/recurring_application_charge_test.rb'
-
-# Offense count: 6
-# Cop supports --auto-correct.
-# Configuration parameters: AllowAdjacentOneLineDefs, NumberOfEmptyLines.
-Layout/EmptyLineBetweenDefs:
-  Exclude:
-    - 'lib/shopify_api/resources/comment.rb'
-    - 'lib/shopify_api/resources/fulfillment.rb'
-
-# Offense count: 4
-# Cop supports --auto-correct.
-Layout/EmptyLines:
-  Exclude:
-    - 'test/base_test.rb'
-    - 'test/customer_test.rb'
-    - 'test/meta_test.rb'
-
-# Offense count: 2
-# Cop supports --auto-correct.
-# Configuration parameters: EnforcedStyle.
-# SupportedStyles: around, only_before
-Layout/EmptyLinesAroundAccessModifier:
-  Exclude:
-    - 'test/customer_saved_search_test.rb'
-    - 'test/gift_card_test.rb'
-
-# Offense count: 3
-# Cop supports --auto-correct.
-# Configuration parameters: EnforcedStyle.
-# SupportedStyles: empty_lines, no_empty_lines
-Layout/EmptyLinesAroundBlockBody:
-  Exclude:
-    - 'test/api_version_test.rb'
-    - 'test/meta_test.rb'
-    - 'test/tax_service_test.rb'
-
-# Offense count: 24
-# Cop supports --auto-correct.
-# Configuration parameters: EnforcedStyle.
-# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines, beginning_only, ending_only
-Layout/EmptyLinesAroundClassBody:
-  Enabled: false
-
-# Offense count: 1
-# Cop supports --auto-correct.
-# Configuration parameters: EnforcedStyle.
-# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines
-Layout/EmptyLinesAroundModuleBody:
-  Exclude:
-    - 'lib/shopify_api/session.rb'
-
-# Offense count: 1
-# Cop supports --auto-correct.
-# Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment.
-Layout/ExtraSpacing:
-  Exclude:
-    - 'lib/shopify_api/resources/product.rb'
-
-# Offense count: 6
-# Cop supports --auto-correct.
-# Configuration parameters: EnforcedStyle, IndentationWidth.
-# SupportedStyles: consistent, consistent_relative_to_receiver, special_for_inner_method_call, special_for_inner_method_call_in_parentheses
-Layout/FirstArgumentIndentation:
-  Exclude:
-    - 'test/application_charge_test.rb'
-    - 'test/assigned_fulfillment_order_test.rb'
-    - 'test/collection_test.rb'
-
-# Offense count: 12
-# Cop supports --auto-correct.
-# Configuration parameters: IndentationWidth, EnforcedStyle.
-# SupportedStyles: spaces, tabs
-Layout/IndentationStyle:
-  Exclude:
-    - 'test/fulfillment_service_test.rb'
-
-# Offense count: 4
-# Cop supports --auto-correct.
-# Configuration parameters: Width, IgnoredPatterns.
-Layout/IndentationWidth:
-  Exclude:
-    - 'test/fulfillment_service_test.rb'
-
-# Offense count: 3
-# Cop supports --auto-correct.
-# Configuration parameters: EnforcedStyle.
-# SupportedStyles: symmetrical, new_line, same_line
-Layout/MultilineMethodCallBraceLayout:
-  Exclude:
-    - 'lib/shopify_api/resources/product.rb'
-    - 'lib/shopify_api/resources/variant.rb'
-    - 'test/fulfillment_order_test.rb'
-
-# Offense count: 1
-# Cop supports --auto-correct.
-Layout/RescueEnsureAlignment:
-  Exclude:
-    - 'lib/shopify_api/message_enricher.rb'
-
-# Offense count: 7
-# Cop supports --auto-correct.
-Layout/SpaceAfterColon:
-  Exclude:
-    - 'test/order_test.rb'
-
-# Offense count: 6
-# Cop supports --auto-correct.
-Layout/SpaceAfterComma:
-  Exclude:
-    - 'lib/active_resource/json_errors.rb'
-    - 'lib/shopify_api/session.rb'
-    - 'test/base_test.rb'
-    - 'test/fulfillment_order_test.rb'
-    - 'test/session_test.rb'
-
-# Offense count: 6
-# Cop supports --auto-correct.
-# Configuration parameters: AllowForAlignment, EnforcedStyleForExponentOperator.
-# SupportedStylesForExponentOperator: space, no_space
-Layout/SpaceAroundOperators:
-  Exclude:
-    - 'lib/shopify_api/resources/product.rb'
-    - 'test/pagination_test.rb'
-    - 'test/test_helper.rb'
-
-# Offense count: 4
-# Cop supports --auto-correct.
-Layout/SpaceBeforeComma:
-  Exclude:
-    - 'test/carrier_service_test.rb'
-    - 'test/fulfillment_service_test.rb'
-
-# Offense count: 4
-# Cop supports --auto-correct.
-# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBrackets.
-# SupportedStyles: space, no_space, compact
-# SupportedStylesForEmptyBrackets: space, no_space
-Layout/SpaceInsideArrayLiteralBrackets:
-  Exclude:
-    - 'test/resource_feedback_test.rb'
-
-# Offense count: 1
-# Cop supports --auto-correct.
-# Configuration parameters: EnforcedStyle.
-# SupportedStyles: space, no_space
-Layout/SpaceInsideParens:
-  Exclude:
-    - 'lib/shopify_api/resources/recurring_application_charge.rb'
-
-# Offense count: 4
-# Cop supports --auto-correct.
-# Configuration parameters: EnforcedStyle.
-# SupportedStyles: final_newline, final_blank_line
-Layout/TrailingEmptyLines:
-  Exclude:
-    - 'lib/shopify_api/meta.rb'
-    - 'lib/shopify_api/resources/announcement.rb'
-    - 'lib/shopify_api/resources/cart.rb'
-    - 'test/cart_test.rb'
-
-# Offense count: 3
-# Cop supports --auto-correct.
-# Configuration parameters: AllowInHeredoc.
-Layout/TrailingWhitespace:
-  Exclude:
-    - 'test/user_test.rb'
-
-# Offense count: 1
-Naming/AccessorMethodName:
-  Exclude:
-    - 'test/detailed_log_subscriber_test.rb'
-
 # Offense count: 6
 # Configuration parameters: EnforcedStyle.
 # SupportedStyles: snake_case, camelCase
@@ -203,17 +13,6 @@ Naming/VariableName:
   Exclude:
     - 'lib/shopify_api/resources/fulfillment.rb'
 
-# Offense count: 1
-# Cop supports --auto-correct.
-# Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, IgnoredMethods, AllowBracesOnProceduralOneLiners, BracesRequiredMethods.
-# SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces
-# ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object
-# FunctionalMethods: let, let!, subject, watch
-# IgnoredMethods: lambda, proc, it
-Style/BlockDelimiters:
-  Exclude:
-    - 'test/inventory_level_test.rb'
-
 # Offense count: 2
 # Cop supports --auto-correct.
 Style/ColonMethodCall:
@@ -228,37 +27,11 @@ Style/CommandLiteral:
   Exclude:
     - 'shopify_api.gemspec'
 
-# Offense count: 1
-# Configuration parameters: AllowIfModifier.
-Style/IfInsideElse:
-  Exclude:
-    - 'lib/shopify_api/graphql.rb'
-
 # Offense count: 1
 Style/MissingRespondToMissing:
   Exclude:
     - 'lib/shopify_api/resources/asset.rb'
 
-# Offense count: 3
-# Cop supports --auto-correct.
-# Configuration parameters: EnforcedStyle.
-# SupportedStyles: short, verbose
-Style/PreferredHashMethods:
-  Exclude:
-    - 'test/test_helper.rb'
-
-# Offense count: 1
-# Cop supports --auto-correct.
-Style/RedundantException:
-  Exclude:
-    - 'lib/shopify_api/session.rb'
-
-# Offense count: 2
-# Cop supports --auto-correct.
-Style/RedundantParentheses:
-  Exclude:
-    - 'test/session_test.rb'
-
 # Offense count: 5
 # Cop supports --auto-correct.
 Style/RedundantPercentQ:
@@ -276,20 +49,6 @@ Style/RedundantSelf:
     - 'lib/shopify_api/resources/product.rb'
     - 'lib/shopify_api/resources/recurring_application_charge.rb'
 
-# Offense count: 1
-# Cop supports --auto-correct.
-# Configuration parameters: EnforcedStyle, AllowInnerSlashes.
-# SupportedStyles: slashes, percent_r, mixed
-Style/RegexpLiteral:
-  Exclude:
-    - 'lib/shopify_api/resources/image.rb'
-
-# Offense count: 1
-# Cop supports --auto-correct.
-Style/RescueModifier:
-  Exclude:
-    - 'lib/active_resource/json_errors.rb'
-
 # Offense count: 1
 # Cop supports --auto-correct.
 # Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods.
@@ -298,14 +57,6 @@ Style/SafeNavigation:
   Exclude:
     - 'lib/shopify_api/resources/custom_collection.rb'
 
-# Offense count: 8
-# Cop supports --auto-correct.
-# Configuration parameters: AllowIfMethodIsEmpty.
-Style/SingleLineMethods:
-  Exclude:
-    - 'lib/shopify_api/resources/comment.rb'
-    - 'lib/shopify_api/resources/fulfillment.rb'
-
 # Offense count: 2
 # Cop supports --auto-correct.
 # Configuration parameters: EnforcedStyle.
@@ -315,33 +66,6 @@ Style/SpecialGlobalVars:
     - 'lib/shopify_api.rb'
     - 'shopify_api.gemspec'
 
-# Offense count: 7
-# Cop supports --auto-correct.
-# Configuration parameters: EnforcedStyleForMultiline.
-# SupportedStylesForMultiline: comma, consistent_comma, no_comma
-Style/TrailingCommaInArrayLiteral:
-  Exclude:
-    - 'shopify_api.gemspec'
-    - 'test/fulfillment_order_test.rb'
-    - 'test/fulfillment_test.rb'
-    - 'test/meta_test.rb'
-
-# Offense count: 66
-# Cop supports --auto-correct.
-# Configuration parameters: EnforcedStyleForMultiline.
-# SupportedStylesForMultiline: comma, consistent_comma, no_comma
-Style/TrailingCommaInHashLiteral:
-  Exclude:
-    - 'lib/shopify_api/metafields.rb'
-    - 'lib/shopify_api/resources/fulfillment_order.rb'
-    - 'lib/shopify_api/resources/fulfillment_v2.rb'
-    - 'lib/shopify_api/resources/inventory_level.rb'
-    - 'test/fulfillment_order_test.rb'
-    - 'test/fulfillment_test.rb'
-    - 'test/fulfillment_v2_test.rb'
-    - 'test/marketing_event_test.rb'
-    - 'test/meta_test.rb'
-
 # Offense count: 2
 # Cop supports --auto-correct.
 # Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, IgnoreClassMethods, AllowedMethods.

+ 7 - 2
lib/active_resource/json_errors.rb

@@ -4,7 +4,12 @@ require 'active_resource/base'
 module ActiveResource
   class Errors < ActiveModel::Errors
     def from_json(json, save_cache = false)
-      data = ActiveSupport::JSON.decode(json)['errors'] || {} rescue {}
+      data =
+        begin
+          ActiveSupport::JSON.decode(json)['errors'] || {}
+        rescue
+          {}
+        end
       case data
       when String
         from_string(data, save_cache)
@@ -16,7 +21,7 @@ module ActiveResource
     def from_hash(messages, save_cache = false)
       clear unless save_cache
 
-      messages.each do |key,errors|
+      messages.each do |key, errors|
         errors.each do |error|
           add(key, error)
         end

+ 2 - 2
lib/shopify_api/countable.rb

@@ -5,8 +5,8 @@ module ShopifyAPI
       data = get(:count, options)
 
       count = case data
-        when Hash then data["count"]
-        else data
+      when Hash then data["count"]
+      else data
       end
 
       Integer(count)

+ 4 - 6
lib/shopify_api/graphql.rb

@@ -53,13 +53,11 @@ module ShopifyAPI
 
           if matches
             api_version = ShopifyAPI::ApiVersion.new(handle: matches[1])
+          elsif raise_on_invalid_schema
+            raise InvalidSchema,
+              "Invalid schema file name `#{schema_file}`. Does not match format of: `<version>.json`."
           else
-            if raise_on_invalid_schema
-              raise InvalidSchema,
-                "Invalid schema file name `#{schema_file}`. Does not match format of: `<version>.json`."
-            else
-              next
-            end
+            next
           end
 
           schema = graphql_client.load_schema(schema_file.to_s)

+ 10 - 9
lib/shopify_api/message_enricher.rb

@@ -5,17 +5,18 @@ module ShopifyAPI
       return super unless (400...500).include?(code.to_i)
 
       @_cached_message ||= begin
-        detailed_error = begin
-          parsed_body = JSON.parse(body)
+        detailed_error =
+          begin
+            parsed_body = JSON.parse(body)
 
-          if parsed_body['error']
-            parsed_body['error'].to_s
-          elsif parsed_body['errors']
-            Array(parsed_body['errors']).join('; ')
+            if parsed_body['error']
+              parsed_body['error'].to_s
+            elsif parsed_body['errors']
+              Array(parsed_body['errors']).join('; ')
+            end
+          rescue JSON::ParserError
+            nil
           end
-        rescue JSON::ParserError
-          nil
-        end
 
         detailed_error.present? ? "#{super} (#{detailed_error})" : super
       end

+ 0 - 1
lib/shopify_api/meta.rb

@@ -12,4 +12,3 @@ module ShopifyAPI
     end
   end
 end
-

+ 1 - 1
lib/shopify_api/metafields.rb

@@ -12,7 +12,7 @@ module ShopifyAPI
 
       metafield.prefix_options = {
         resource: self.class.collection_name,
-        resource_id: id
+        resource_id: id,
       }
       metafield.save
       metafield

+ 1 - 1
lib/shopify_api/resources/announcement.rb

@@ -2,4 +2,4 @@
 module ShopifyAPI
   class Announcement < Base
   end
-end
+end

+ 0 - 1
lib/shopify_api/resources/assigned_fulfillment_order.rb

@@ -1,7 +1,6 @@
 # frozen_string_literal: true
 module ShopifyAPI
   class AssignedFulfillmentOrder < Base
-
     def initialize(attributes = {}, persisted = false)
       ShopifyAPI::Base.version_validation!(FulfillmentOrder::MINIMUM_VERSION)
       super(attributes, persisted)

+ 1 - 1
lib/shopify_api/resources/cart.rb

@@ -2,4 +2,4 @@
 module ShopifyAPI
   class Cart < Base
   end
-end
+end

+ 19 - 5
lib/shopify_api/resources/comment.rb

@@ -1,10 +1,24 @@
 # frozen_string_literal: true
 module ShopifyAPI
   class Comment < Base
-    def remove;   load_attributes_from_response(post(:remove, {}, only_id)); end
-    def spam;     load_attributes_from_response(post(:spam, {}, only_id)); end
-    def approve;  load_attributes_from_response(post(:approve, {}, only_id)); end
-    def restore;  load_attributes_from_response(post(:restore, {}, only_id)); end
-    def not_spam; load_attributes_from_response(post(:not_spam, {}, only_id)); end
+    def remove
+      load_attributes_from_response(post(:remove, {}, only_id))
+    end
+
+    def spam
+      load_attributes_from_response(post(:spam, {}, only_id))
+    end
+
+    def approve
+      load_attributes_from_response(post(:approve, {}, only_id))
+    end
+
+    def restore
+      load_attributes_from_response(post(:restore, {}, only_id))
+    end
+
+    def not_spam
+      load_attributes_from_response(post(:not_spam, {}, only_id))
+    end
   end
 end

+ 11 - 3
lib/shopify_api/resources/fulfillment.rb

@@ -7,9 +7,17 @@ module ShopifyAPI
       @prefix_options[:order_id]
     end
 
-    def cancel; load_attributes_from_response(post(:cancel, {}, only_id)); end
-    def complete; load_attributes_from_response(post(:complete, {}, only_id)); end
-    def open; load_attributes_from_response(post(:open, {}, only_id)); end
+    def cancel
+      load_attributes_from_response(post(:cancel, {}, only_id))
+    end
+
+    def complete
+      load_attributes_from_response(post(:complete, {}, only_id))
+    end
+
+    def open
+      load_attributes_from_response(post(:open, {}, only_id))
+    end
 
     def order_id=(order_id)
       prefix_options[:order_id] = order_id

+ 16 - 16
lib/shopify_api/resources/fulfillment_order.rb

@@ -38,8 +38,8 @@ module ShopifyAPI
     def move(new_location_id:)
       body = {
         fulfillment_order: {
-          new_location_id: new_location_id
-        }
+          new_location_id: new_location_id,
+        },
       }
       keyed_fulfillment_orders = keyed_fulfillment_orders_from_response(post(:move, {}, body.to_json))
       load_keyed_fulfillment_order(keyed_fulfillment_orders, 'original_fulfillment_order')
@@ -55,8 +55,8 @@ module ShopifyAPI
     def close(message: nil)
       body = {
         fulfillment_order: {
-          message: message
-        }
+          message: message,
+        },
       }
       load_attributes_from_response(post(:close, {}, body.to_json))
     end
@@ -65,8 +65,8 @@ module ShopifyAPI
       body = {
         fulfillment_request: {
           fulfillment_order_line_items: fulfillment_order_line_items,
-          message: message
-        }
+          message: message,
+        },
       }
       keyed_fulfillment_orders = keyed_fulfillment_orders_from_response(post(:fulfillment_request, {}, body.to_json))
       load_keyed_fulfillment_order(keyed_fulfillment_orders, 'original_fulfillment_order')
@@ -76,8 +76,8 @@ module ShopifyAPI
     def accept_fulfillment_request(message: nil)
       body = {
         fulfillment_request: {
-          message: message
-        }
+          message: message,
+        },
       }
       load_attributes_from_response(post('fulfillment_request/accept', {}, body.to_json))
     end
@@ -85,8 +85,8 @@ module ShopifyAPI
     def reject_fulfillment_request(message: nil)
       body = {
         fulfillment_request: {
-          message: message
-        }
+          message: message,
+        },
       }
       load_attributes_from_response(post('fulfillment_request/reject', {}, body.to_json))
     end
@@ -94,8 +94,8 @@ module ShopifyAPI
     def request_cancellation(message: nil)
       body = {
         cancellation_request: {
-          message: message
-        }
+          message: message,
+        },
       }
       load_attributes_from_response(post(:cancellation_request, {}, body.to_json))
     end
@@ -103,8 +103,8 @@ module ShopifyAPI
     def accept_cancellation_request(message: nil)
       body = {
         cancellation_request: {
-          message: message
-        }
+          message: message,
+        },
       }
       load_attributes_from_response(post('cancellation_request/accept', {}, body.to_json))
     end
@@ -112,8 +112,8 @@ module ShopifyAPI
     def reject_cancellation_request(message: nil)
       body = {
         cancellation_request: {
-          message: message
-        }
+          message: message,
+        },
       }
       load_attributes_from_response(post('cancellation_request/reject', {}, body.to_json))
     end

+ 2 - 2
lib/shopify_api/resources/fulfillment_v2.rb

@@ -12,8 +12,8 @@ module ShopifyAPI
       body = {
         fulfillment: {
           tracking_info: tracking_info,
-          notify_customer: notify_customer
-        }
+          notify_customer: notify_customer,
+        },
       }
       load_attributes_from_response(post(:update_tracking, {}, body.to_json))
     end

+ 1 - 1
lib/shopify_api/resources/image.rb

@@ -6,7 +6,7 @@ module ShopifyAPI
     # generate a method for each possible image variant
     [:pico, :icon, :thumb, :small, :compact, :medium, :large, :grande, :original].each do |m|
       reg_exp_match = "/\\1_#{m}.\\2"
-      define_method(m) { src.gsub(/\/(.*)\.(\w{2,4})/, reg_exp_match) }
+      define_method(m) { src.gsub(%r/\/(.*)\.(\w{2,4})/, reg_exp_match) }
     end
 
     def attach_image(data, filename = nil)

+ 2 - 3
lib/shopify_api/resources/inventory_level.rb

@@ -2,7 +2,6 @@
 
 module ShopifyAPI
   class InventoryLevel < Base
-
     # The default path structure in ActiveResource for delete would result in:
     # /admin/api/<version>/inventory_levels/#{ inventory_level.id }.json?#{ params }, but since
     # InventoryLevels are a second class resource made up of a Where and a What
@@ -33,7 +32,7 @@ module ShopifyAPI
       body = {
         location_id: location_id,
         inventory_item_id: inventory_item_id,
-        available: new_available
+        available: new_available,
       }
       body[:disconnect_if_necessary] = disconnect_if_necessary unless disconnect_if_necessary.nil?
       load_attributes_from_response(
@@ -45,7 +44,7 @@ module ShopifyAPI
       body = {
         location_id: location_id,
         inventory_item_id: inventory_item_id,
-        available_adjustment: available_adjustment
+        available_adjustment: available_adjustment,
       }
       load_attributes_from_response(
         self.class.post(:adjust, {}, body.to_json)

+ 0 - 1
lib/shopify_api/resources/location.rb

@@ -1,7 +1,6 @@
 # frozen_string_literal: true
 module ShopifyAPI
   class Location < Base
-
     def inventory_levels
       ShopifyAPI::InventoryLevel.find(:all, from: "#{self.class.prefix}locations/#{id}/inventory_levels.json")
     end

+ 0 - 1
lib/shopify_api/resources/price_rule.rb

@@ -1,7 +1,6 @@
 # frozen_string_literal: true
 module ShopifyAPI
   class PriceRule < Base
-
     def discount_codes
       DiscountCode.find(:all, params: { price_rule_id: id })
     end

+ 4 - 3
lib/shopify_api/resources/product.rb

@@ -14,7 +14,7 @@ module ShopifyAPI
     # compute the price range
     def price_range
       prices = variants.collect(&:price).collect(&:to_f)
-      format =  "%0.2f"
+      format = "%0.2f"
       if prices.min != prices.max
         "#{format % prices.min} - #{format % prices.max}"
       else
@@ -46,9 +46,10 @@ module ShopifyAPI
     private
 
     def raise_deprecated_inventory_call(parameter)
-      raise(ShopifyAPI::ValidationException,
+      raise(
+        ShopifyAPI::ValidationException,
         "'#{parameter}' is deprecated - see https://help.shopify.com/en/api/guides/inventory-migration-guide",
-        )
+      )
     end
 
     def allow_inventory_params?

+ 1 - 1
lib/shopify_api/resources/recurring_application_charge.rb

@@ -27,7 +27,7 @@ module ShopifyAPI
 
     def customize(customize_recurring_app_charge_params = {})
       load_attributes_from_response(
-        put(:customize, recurring_application_charge: customize_recurring_app_charge_params )
+        put(:customize, recurring_application_charge: customize_recurring_app_charge_params)
       )
     end
   end

+ 0 - 1
lib/shopify_api/resources/smart_collection.rb

@@ -11,6 +11,5 @@ module ShopifyAPI
     def order(options = {})
       load_attributes_from_response(put(:order, options, only_id))
     end
-
   end
 end

+ 3 - 2
lib/shopify_api/resources/variant.rb

@@ -31,9 +31,10 @@ module ShopifyAPI
     private
 
     def raise_deprecated_inventory_call(parameter)
-      raise(ShopifyAPI::ValidationException,
+      raise(
+        ShopifyAPI::ValidationException,
         "'#{parameter}' is deprecated - see https://help.shopify.com/en/api/guides/inventory-migration-guide",
-        )
+      )
     end
 
     def allow_inventory_params?

+ 3 - 5
lib/shopify_api/session.rb

@@ -3,7 +3,6 @@ require 'openssl'
 require 'rack'
 
 module ShopifyAPI
-
   class ValidationException < StandardError
   end
 
@@ -16,9 +15,8 @@ module ShopifyAPI
     alias_method :url, :domain
 
     class << self
-
       def setup(params)
-        params.each { |k,value| public_send("#{k}=", value) }
+        params.each { |k, value| public_send("#{k}=", value) }
       end
 
       def temp(domain:, token:, api_version: ShopifyAPI::Base.api_version, &block)
@@ -81,7 +79,7 @@ module ShopifyAPI
 
       def encoded_params_for_signature(params)
         params = params.except(:signature, :hmac, :action, :controller)
-        params.map { |k,v| "#{URI.escape(k.to_s, '&=%')}=#{URI.escape(v.to_s, '&%')}" }.sort.join('&')
+        params.map { |k, v| "#{URI.escape(k.to_s, '&=%')}=#{URI.escape(v.to_s, '&%')}" }.sort.join('&')
       end
 
       def extract_current_session
@@ -122,7 +120,7 @@ module ShopifyAPI
         end
         token
       else
-        raise RuntimeError, response.msg
+        raise response.msg
       end
     end
 

+ 1 - 1
shopify_api.gemspec

@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
 
   s.extra_rdoc_files = [
     "LICENSE",
-    "README.md"
+    "README.md",
   ]
   s.files         = `git ls-files`.split("\n")
   s.test_files    = `git ls-files -- {test}/*`.split("\n")

+ 0 - 1
test/access_token_test.rb

@@ -2,7 +2,6 @@
 require 'test_helper'
 
 class AccessTokenTest < Test::Unit::TestCase
-
   def test_delegate_access_token
     fake(
       "access_tokens/delegate.json?delegate_access_scope%5B%5D=write_orders&" \

+ 0 - 1
test/active_resource/json_errors_test.rb

@@ -3,7 +3,6 @@ require 'test_helper'
 
 module ActiveResource
   class JsonErrorsTest < Test::Unit::TestCase
-
     def test_parsing_of_error_json_hash
       @model = ShopifyAPI::Order.new
       @model.errors.from_json({ errors: { name: ['missing'] } }.to_json)

+ 0 - 1
test/api_version_test.rb

@@ -108,7 +108,6 @@ class ApiVersionTest < Test::Unit::TestCase
       }
     )
     silence_warnings do
-
       refute_equal(
         ShopifyAPI::ApiVersion.new(handle: '2019-01'),
         ShopifyAPI::ApiVersion.latest_stable_version

+ 3 - 5
test/application_charge_test.rb

@@ -2,14 +2,13 @@
 require 'test_helper'
 
 class ApplicationChargeTest < Test::Unit::TestCase
-
   def test_application_charge_create
     fake("application_charges", method: :post, status: 201, body: load_fixture('application_charge'))
 
     charge = ShopifyAPI::ApplicationCharge.create(
-        name: "iPod Cleaning",
-        price: 5.00,
-        return_url: "http://google.com"
+      name: "iPod Cleaning",
+      price: 5.00,
+      return_url: "http://google.com"
     )
 
     assert_equal(
@@ -80,5 +79,4 @@ class ApplicationChargeTest < Test::Unit::TestCase
 
     assert(charge.last.activate)
   end
-
 end

+ 0 - 2
test/article_test.rb

@@ -2,7 +2,6 @@
 require 'test_helper'
 
 class ArticleTest < Test::Unit::TestCase
-
   def test_create_article
     fake("blogs/1008414260/articles", method: :post, body: load_fixture('article'))
     article = ShopifyAPI::Article.new(blog_id: 1008414260)
@@ -70,5 +69,4 @@ class ArticleTest < Test::Unit::TestCase
     tags = ShopifyAPI::Article.tags(popular: 1, limit: 1)
     assert_equal(3, tags.length)
   end
-
 end

+ 2 - 2
test/assigned_fulfillment_order_test.rb

@@ -45,7 +45,7 @@ class AssignedFulFillmentOrderTest < Test::Unit::TestCase
           extension: false
 
         assigned_fulfillment_orders = ShopifyAPI::AssignedFulfillmentOrder.all(
-            params: { assigned_status: 'cancellation_requested' }
+          params: { assigned_status: 'cancellation_requested' }
         )
 
         assert_equal 2, assigned_fulfillment_orders.count
@@ -64,7 +64,7 @@ class AssignedFulFillmentOrderTest < Test::Unit::TestCase
           body: @fulfillment_order_fixture, extension: false
 
         assigned_fulfillment_orders = ShopifyAPI::AssignedFulfillmentOrder.all(
-            params: { location_ids: [assigned_location_id] }
+          params: { location_ids: [assigned_location_id] }
         )
 
         assert_equal 2, assigned_fulfillment_orders.count

+ 1 - 3
test/base_test.rb

@@ -43,7 +43,6 @@ class BaseTest < Test::Unit::TestCase
   test '#clear_session should not change the api_version' do
     ShopifyAPI::Base.site = "https://zoo:lion@www.zoo.com"
 
-
     assert_equal("zoo", ShopifyAPI::Base.user)
     assert_equal("lion", ShopifyAPI::Base.password)
 
@@ -52,7 +51,7 @@ class BaseTest < Test::Unit::TestCase
     assert_nil(ShopifyAPI::Base.user)
     assert_nil(ShopifyAPI::Base.password)
     assert_nil(ShopifyAPI::Base.site)
-    assert_equal(ShopifyAPI::Base.api_version,@session1.api_version)
+    assert_equal(ShopifyAPI::Base.api_version, @session1.api_version)
   end
 
   test '#clear_session should clear site and headers from Base' do
@@ -203,7 +202,6 @@ class BaseTest < Test::Unit::TestCase
     assert_equal('The minimum supported version is 2020-01.', exception.message)
   end
 
-
   def clear_header(header)
     [ActiveResource::Base, ShopifyAPI::Base, ShopifyAPI::Product].each do |klass|
       klass.headers.delete(header)

+ 2 - 2
test/carrier_service_test.rb

@@ -6,13 +6,13 @@ class CarrierServiceTest < Test::Unit::TestCase
     fake("carrier_services", method: :post, body: load_fixture('carrier_service'))
     carrier_service = ShopifyAPI::CarrierService.new(name: "Some Postal Service")
     carrier_service.save
-    assert_equal("Some Postal Service" , carrier_service.name)
+    assert_equal("Some Postal Service", carrier_service.name)
   end
 
   test 'find should return the carrier service' do
     fake("carrier_services/123456", method: :get, body: load_fixture('carrier_service'))
     carrier_service = ShopifyAPI::CarrierService.find(123456)
-    assert_equal(123456 , carrier_service.id)
+    assert_equal(123456, carrier_service.id)
     assert_equal("Some Postal Service", carrier_service.name)
   end
 end

+ 1 - 1
test/cart_test.rb

@@ -11,4 +11,4 @@ class CartTest < Test::Unit::TestCase
     assert_equal 1, carts.first.line_items.size
     assert_equal 'test', carts.first.line_items.first.title
   end
-end
+end

+ 0 - 1
test/collection_listing_test.rb

@@ -2,7 +2,6 @@
 require 'test_helper'
 
 class CollectionListingTest < Test::Unit::TestCase
-
   def test_get_collection_listings
     fake("collection_listings", method: :get, status: 201, body: load_fixture('collection_listings'))
 

+ 18 - 18
test/collection_test.rb

@@ -7,23 +7,23 @@ class CollectionTest < Test::Unit::TestCase
     ShopifyAPI::Base.activate_session(available_version)
 
     fake(
-        'collections',
-        url: 'https://shop2.myshopify.com/admin/api/2020-01/collections/1.json',
-        method: :get,
-        status: 200,
-        body: load_fixture('collection'),
-        extension: false
+      'collections',
+      url: 'https://shop2.myshopify.com/admin/api/2020-01/collections/1.json',
+      method: :get,
+      status: 200,
+      body: load_fixture('collection'),
+      extension: false
     )
 
     collection = ShopifyAPI::Collection.find(1)
 
     fake(
-        'products',
-        url: 'https://shop2.myshopify.com/admin/api/2020-01/collections/1/products.json',
-        method: :get,
-        status: 200,
-        body: load_fixture('collection_products'),
-        extension: false
+      'products',
+      url: 'https://shop2.myshopify.com/admin/api/2020-01/collections/1/products.json',
+      method: :get,
+      status: 200,
+      body: load_fixture('collection_products'),
+      extension: false
     )
     assert_equal [632910392, 921728736], collection.products.map(&:id)
   end
@@ -33,12 +33,12 @@ class CollectionTest < Test::Unit::TestCase
     ShopifyAPI::Base.activate_session(old_version)
 
     fake(
-        'collections',
-        url: 'https://shop2.myshopify.com/admin/api/2019-10/collections/1.json',
-        method: :get,
-        status: 200,
-        body: load_fixture('collection'),
-        extension: false
+      'collections',
+      url: 'https://shop2.myshopify.com/admin/api/2019-10/collections/1.json',
+      method: :get,
+      status: 200,
+      body: load_fixture('collection'),
+      extension: false
     )
 
     collection = ShopifyAPI::Collection.find(1)

+ 1 - 0
test/customer_saved_search_test.rb

@@ -29,6 +29,7 @@ class CustomerSavedSearchTest < Test::Unit::TestCase
   end
 
   private
+
   def load_customer_saved_search
     fake('customer_saved_searches/8899730', body: load_fixture('customer_saved_search'))
     @customer_saved_search = ShopifyAPI::CustomerSavedSearch.find(8899730)

+ 0 - 1
test/customer_test.rb

@@ -49,7 +49,6 @@ class CustomerTest < Test::Unit::TestCase
     customer_invite = ActiveSupport::JSON.decode(customer_invite_fixture)
     fake('customers/207119551/send_invite', method: :post, body: customer_invite_fixture)
 
-
     customer_invite_response = @customer.send_invite(ShopifyAPI::CustomerInvite.new(customer_invite['customer_invite']))
 
     assert_equal(customer_invite, ActiveSupport::JSON.decode(WebMock.last_request.body))

+ 28 - 27
test/fulfillment_order_test.rb

@@ -68,7 +68,8 @@ class FulFillmentOrderTest < Test::Unit::TestCase
 
     context "#all" do
       should "be able to list fulfillment orders for an order" do
-        fake('orders',
+        fake(
+          'orders',
           url: "#{@url_prefix}/orders/450789469/fulfillment_orders.json",
           method: :get,
           body: load_fixture('fulfillment_orders')
@@ -126,7 +127,7 @@ class FulFillmentOrderTest < Test::Unit::TestCase
 
         location = location_for_move.location
         assert(location.is_a?(ShopifyAPI::Location))
-        assert_equal(1059367776,location.id)
+        assert_equal(1059367776, location.id)
       end
     end
 
@@ -211,8 +212,8 @@ class FulFillmentOrderTest < Test::Unit::TestCase
         closed['status'] = 'incomplete'
         request_body = {
           fulfillment_order: {
-            message: "Test close message."
-          }
+            message: "Test close message.",
+          },
         }
         fake(
           'fulfillment_orders',
@@ -241,15 +242,15 @@ class FulFillmentOrderTest < Test::Unit::TestCase
         body = {
           original_fulfillment_order: fake_original_fulfillment_order,
           submitted_fulfillment_order: fake_submitted_fulfillment_order,
-          unsubmitted_fulfillment_order: fake_unsubmitted_fulfillment_order
+          unsubmitted_fulfillment_order: fake_unsubmitted_fulfillment_order,
         }
         request_body = {
           fulfillment_request: {
             fulfillment_order_line_items: [
-              { id: 1, quantity: 1 }
+              { id: 1, quantity: 1 },
             ],
-            message: 'Fulfill this FO, please.'
-          }
+            message: 'Fulfill this FO, please.',
+          },
         }
         fake(
           'fulfillment_orders',
@@ -261,7 +262,7 @@ class FulFillmentOrderTest < Test::Unit::TestCase
         fulfillment_order = ShopifyAPI::FulfillmentOrder.find(519788021)
         params = {
           fulfillment_order_line_items: [{ id: 1, quantity: 1 }],
-          message: "Fulfill this FO, please."
+          message: "Fulfill this FO, please.",
         }
         response_fulfillment_orders = fulfillment_order.request_fulfillment(params)
 
@@ -298,10 +299,10 @@ class FulFillmentOrderTest < Test::Unit::TestCase
         request_body = {
           fulfillment_request: {
             fulfillment_order_line_items: [
-              { id: 1, quantity: 1 }
+              { id: 1, quantity: 1 },
             ],
-            message: 'Fulfill this FO, please.'
-          }
+            message: 'Fulfill this FO, please.',
+          },
         }
         fake(
           'fulfillment_orders',
@@ -313,7 +314,7 @@ class FulFillmentOrderTest < Test::Unit::TestCase
         fulfillment_order = ShopifyAPI::FulfillmentOrder.find(519788021)
         params = {
           fulfillment_order_line_items: [{ id: 1, quantity: 1 }],
-          message: "Fulfill this FO, please."
+          message: "Fulfill this FO, please.",
         }
         response_fulfillment_orders = fulfillment_order.request_fulfillment(params)
 
@@ -340,11 +341,11 @@ class FulFillmentOrderTest < Test::Unit::TestCase
         message = "LGTM. Accept this FO fulfillment request"
         request_body = {
           'fulfillment_request' => {
-            'message' => message
-          }
+            'message' => message,
+          },
         }
         fake_response = {
-          fulfillment_order: fulfillment_order.attributes.merge(status: 'in_progress', request_status: 'accepted')
+          fulfillment_order: fulfillment_order.attributes.merge(status: 'in_progress', request_status: 'accepted'),
         }
         fake(
           'fulfillment_orders',
@@ -368,11 +369,11 @@ class FulFillmentOrderTest < Test::Unit::TestCase
         message = "LBTM. Reject this FO fulfillment request"
         request_body = {
           'fulfillment_request' => {
-            'message' => message
-          }
+            'message' => message,
+          },
         }
         fake_response = {
-          fulfillment_order: fulfillment_order.attributes.merge(status: 'open', request_status: 'rejected')
+          fulfillment_order: fulfillment_order.attributes.merge(status: 'open', request_status: 'rejected'),
         }
         fake(
           'fulfillment_orders',
@@ -396,8 +397,8 @@ class FulFillmentOrderTest < Test::Unit::TestCase
         message = "Cancelling this please."
         request_body = {
           'cancellation_request' => {
-            'message' => message
-          }
+            'message' => message,
+          },
         }
         cancelling = ActiveSupport::JSON.decode(load_fixture('fulfillment_order'))
         cancelling['status'] = 'in_progress'
@@ -424,12 +425,12 @@ class FulFillmentOrderTest < Test::Unit::TestCase
         message = 'Already in-progress. Reject this FO cancellation request'
         request_body = {
           'cancellation_request' => {
-            'message' => message
-          }
+            'message' => message,
+          },
         }
         fake_response = {
           fulfillment_order: fulfillment_order.attributes.merge(status: 'cancelled',
-                                                                request_status: 'cancellation_accepted')
+                                                                request_status: 'cancellation_accepted'),
         }
         fake(
           'fulfillment_orders',
@@ -453,12 +454,12 @@ class FulFillmentOrderTest < Test::Unit::TestCase
         message = "Already in-progress. Reject this FO cancellation request"
         request_body = {
           'cancellation_request' => {
-            'message' => message
-          }
+            'message' => message,
+          },
         }
         fake_response = {
           fulfillment_order: fulfillment_order.attributes.merge(status: 'in_progress',
-                                                                request_status: 'cancellation_rejected')
+                                                                request_status: 'cancellation_rejected'),
         }
         fake(
           'fulfillment_orders',

+ 12 - 12
test/fulfillment_service_test.rb

@@ -2,17 +2,17 @@
 require 'test_helper'
 
 class FulFillmentServiceTest < Test::Unit::TestCase
-	test 'new should create fulfillment service' do
-		fake("fulfillment_services", method: :post, body: load_fixture('fulfillment_service'))
-		fulfillment_service = ShopifyAPI::FulfillmentService.new(name: "SomeService")
-		fulfillment_service.save
-		assert_equal("SomeService" , fulfillment_service.name)
-	end
+  test 'new should create fulfillment service' do
+    fake("fulfillment_services", method: :post, body: load_fixture('fulfillment_service'))
+    fulfillment_service = ShopifyAPI::FulfillmentService.new(name: "SomeService")
+    fulfillment_service.save
+    assert_equal("SomeService", fulfillment_service.name)
+  end
 
-	test 'find should return the fulfillment service' do
-		fake("fulfillment_services/123456", method: :get, body: load_fixture('fulfillment_service'))
-		fulfillment_service = ShopifyAPI::FulfillmentService.find(123456)
-		assert_equal(123456 , fulfillment_service.id)
-		assert_equal("SomeService", fulfillment_service.name)
-	end
+  test 'find should return the fulfillment service' do
+    fake("fulfillment_services/123456", method: :get, body: load_fixture('fulfillment_service'))
+    fulfillment_service = ShopifyAPI::FulfillmentService.find(123456)
+    assert_equal(123456, fulfillment_service.id)
+    assert_equal("SomeService", fulfillment_service.name)
+  end
 end

+ 16 - 16
test/fulfillment_test.rb

@@ -77,14 +77,14 @@ class FulFillmentTest < Test::Unit::TestCase
           tracking_info: {
             number: "XSDFHYR23475",
             url: "https://tracking.example.com/XSDFHYR23475",
-            company: "TFTC - the fulfillment/tracking company"
+            company: "TFTC - the fulfillment/tracking company",
           },
           line_items_by_fulfillment_order: [
             {
               fulfillment_order_id: 3,
-              fulfillment_order_line_items: [{ id: 2, quantity: 1 }]
-            }
-          ]
+              fulfillment_order_line_items: [{ id: 2, quantity: 1 }],
+            },
+          ],
         }
         request_body = { fulfillment: create_fulfillment_attributes }
         response_body = { fulfillment: create_fulfillment_attributes.merge(id: 346743624) }
@@ -109,14 +109,14 @@ class FulFillmentTest < Test::Unit::TestCase
           tracking_info: {
             number: "XSDFHYR23475",
             url: "https://tracking.example.com/XSDFHYR23475",
-            company: "TFTC - the fulfillment/tracking company"
+            company: "TFTC - the fulfillment/tracking company",
           },
           line_items_by_fulfillment_order: [
             {
               fulfillment_order_id: 3,
-              fulfillment_order_line_items: [{ id: 2, quantity: 1 }]
-            }
-          ]
+              fulfillment_order_line_items: [{ id: 2, quantity: 1 }],
+            },
+          ],
         }
         request_body = { fulfillment: create_fulfillment_attributes }
         response_body = { fulfillment: create_fulfillment_attributes.merge(id: 346743624) }
@@ -142,14 +142,14 @@ class FulFillmentTest < Test::Unit::TestCase
           tracking_info: {
             number: "XSDFHYR23475",
             url: "https://tracking.example.com/XSDFHYR23475",
-            company: "TFTC - the fulfillment/tracking company"
+            company: "TFTC - the fulfillment/tracking company",
           },
           line_items_by_fulfillment_order: [
             {
               fulfillment_order_id: 3,
-              fulfillment_order_line_items: [{ id: 2, quantity: 1 }]
-            }
-          ]
+              fulfillment_order_line_items: [{ id: 2, quantity: 1 }],
+            },
+          ],
         }
         request_body = { fulfillment: create_fulfillment_attributes }
         response_body = { fulfillment: create_fulfillment_attributes.merge(id: 346743624) }
@@ -176,8 +176,8 @@ class FulFillmentTest < Test::Unit::TestCase
           tracking_info: {
             number: "XSDFHYR23475",
             url: "https://tracking.example.com/XSDFHYR23475",
-            company: "TFTC - the fulfillment/tracking company"
-          }
+            company: "TFTC - the fulfillment/tracking company",
+          },
         }
         request_body = { fulfillment: create_fulfillment_attributes }
         response_body = { fulfillment: create_fulfillment_attributes.merge(id: 346743624) }
@@ -214,8 +214,8 @@ class FulFillmentTest < Test::Unit::TestCase
         request_body = {
           fulfillment: {
             tracking_info: tracking_info,
-            notify_customer: true
-          }
+            notify_customer: true,
+          },
         }
         url_prefix = url_prefix_for_activated_session_for('2020-01')
         fake(

+ 2 - 2
test/fulfillment_v2_test.rb

@@ -22,8 +22,8 @@ class FulfillmentV2Test < Test::Unit::TestCase
     @request_body = {
       fulfillment: {
         tracking_info: @tracking_info,
-        notify_customer: true
-      }
+        notify_customer: true,
+      },
     }
     @url_prefix = url_prefix_for_activated_session_for('2020-01')
     fake(

+ 1 - 0
test/gift_card_test.rb

@@ -16,6 +16,7 @@ class GiftCardTest < Test::Unit::TestCase
   end
 
   private
+
   def load_gift_card
     fake('gift_cards/1023670', body: load_fixture('gift_card'))
     @gift_card = ShopifyAPI::GiftCard.find(1023670)

+ 2 - 2
test/inventory_level_test.rb

@@ -20,10 +20,10 @@ class InventoryLevelTest < Test::Unit::TestCase
     inventory_levels = ShopifyAPI::InventoryLevel.find(:all, params: params)
 
     assert(
-      inventory_levels.all? { |item|
+      inventory_levels.all? do |item|
         params[:location_ids].include?(item.location_id) &&
         params[:inventory_item_ids].include?(item.inventory_item_id)
-      },
+      end,
       message: 'Response contained inventory_items or locations not requested.'
     )
   end

+ 1 - 2
test/marketing_event_test.rb

@@ -2,7 +2,6 @@
 require 'test_helper'
 
 class MarketingEventTest < Test::Unit::TestCase
-
   def test_get_marketing_events
     fake("marketing_events", method: :get, body: load_fixture('marketing_events'))
     marketing_events = ShopifyAPI::MarketingEvent.all
@@ -61,7 +60,7 @@ class MarketingEventTest < Test::Unit::TestCase
       favorites_count: nil,
       comments_count: nil,
       ad_spend: nil,
-      is_cumulative: true
+      is_cumulative: true,
     }
     marketing_event.add_engagements(engagement)
     assert("2017-04-20", engagement[:occurred_on])

+ 0 - 1
test/message_enricher_test.rb

@@ -2,7 +2,6 @@
 require 'test_helper'
 
 class MessageEnricherTest < Test::Unit::TestCase
-
   def test_enriches_initial_message_when_body_contains_error
     response = enriched_response(422, 'InitialMessage', { error: 'My Error' })
 

+ 7 - 9
test/meta_test.rb

@@ -8,42 +8,40 @@ class ApiVersionTest < Test::Unit::TestCase
         "handle": "2019-01",
         "display_name": "2019-01",
         "supported": true,
-        "latest_supported": false
+        "latest_supported": false,
       },
       {
         "handle": "2019-04",
         "latest_supported": false,
         "display_name": "2019-04",
-        "supported": true
+        "supported": true,
       },
       {
         "handle": "2019-07",
         "latest_supported": false,
         "display_name": "2019-07",
-        "supported": true
+        "supported": true,
       },
       {
         "handle": "2019-10",
         "latest_supported": false,
         "display_name": "2019-10",
-        "supported": true
+        "supported": true,
       },
       {
         "handle": "2020-01",
         "latest_supported": true,
         "display_name": "2020-01 (Latest)",
-        "supported": true
+        "supported": true,
       },
       {
         "handle": "unstable",
         "latest_supported": false,
         "display_name": "unstable",
-        "supported": false
-      }
+        "supported": false,
+      },
     ].to_json
 
-
     assert_equal versions, ShopifyAPI::Meta.admin_versions.to_json
-
   end
 end

+ 6 - 2
test/order_test.rb

@@ -7,7 +7,10 @@ class OrderTest < Test::Unit::TestCase
 
   test "create should create order" do
     fake('orders', method: :post, status: 201, body: load_fixture('order'))
-    order = ShopifyAPI::Order.create(line_items: [{ quantity:1, variant_id:39072856 }], financial_status:"authorized")
+    order = ShopifyAPI::Order.create(
+      line_items: [{ quantity: 1, variant_id: 39072856 }],
+      financial_status: "authorized"
+    )
     assert_equal(39072856, order.line_items.first.variant_id)
   end
 
@@ -23,7 +26,8 @@ class OrderTest < Test::Unit::TestCase
     ]
     fake('orders', method: :post, status: 201, body: load_fixture('order_with_properties'))
     order = ShopifyAPI::Order.create(
-      line_items: [{ quantity:1, variant_id:39072856, properties:props }], financial_status:"authorized"
+      line_items: [{ quantity: 1, variant_id: 39072856, properties: props }],
+      financial_status: "authorized"
     )
     assert_equal(39072856, order.line_items.first.variant_id)
   end

+ 2 - 3
test/pagination_test.rb

@@ -17,7 +17,7 @@ class PaginationTest < Test::Unit::TestCase
   end
 
   test "navigates using next and previous link headers with no original params" do
-    link_header ="#{@previous_link_header}, #{@next_link_header}"
+    link_header = "#{@previous_link_header}, #{@next_link_header}"
 
     fake('orders', method: :get, status: 200, api_version: @version, body: load_fixture('orders'), link: link_header)
     orders = ShopifyAPI::Order.all
@@ -230,7 +230,7 @@ class PaginationTest < Test::Unit::TestCase
     @next_link_header = "<https://this-is-my-test-shop.myshopify.com/admin/api/unstable/" \
       "orders.json?page_info=#{@next_page_info}>; rel=\"next\""
 
-    link_header ="#{@previous_link_header}, #{@next_link_header}"
+    link_header = "#{@previous_link_header}, #{@next_link_header}"
 
     fake('orders', method: :get, status: 200, api_version: version, body: load_fixture('orders'), link: link_header)
     orders = ShopifyAPI::Order.all
@@ -287,5 +287,4 @@ class PaginationTest < Test::Unit::TestCase
     next_page = orders.fetch_next_page
     assert_equal(450789469, next_page.first.id)
   end
-
 end

+ 0 - 1
test/product_listing_test.rb

@@ -2,7 +2,6 @@
 require 'test_helper'
 
 class ProductListingTest < Test::Unit::TestCase
-
   def test_get_product_listings
     fake("product_listings", method: :get, status: 201, body: load_fixture('product_listings'))
 

+ 1 - 2
test/recurring_application_charge_test.rb

@@ -2,7 +2,6 @@
 require 'test_helper'
 
 class RecurringApplicationChargeTest < Test::Unit::TestCase
-
   def test_recurring_application_charges_create
     fake(
       "recurring_application_charges", method: :post, status: 201, body: load_fixture('recurring_application_charge')
@@ -18,7 +17,7 @@ class RecurringApplicationChargeTest < Test::Unit::TestCase
       'http://apple.myshopify.com/admin/charges/654381177/confirm_recurring_application_charge?' \
         'signature=BAhpBHkQASc%3D--419fc7424f8c290ac2b21b9004ed223e35b52164',
       charge.confirmation_url
-      )
+    )
   end
 
   def test_get_recurring_application_charges

+ 0 - 1
test/refund_test.rb

@@ -2,7 +2,6 @@
 require 'test_helper'
 
 class RefundTest < Test::Unit::TestCase
-
   test '#create should create a refund' do
     fake("orders/450789469/refunds", method: :post, status: 201, body: load_fixture('refund'))
     refund = ShopifyAPI::Refund.create(

+ 2 - 2
test/resource_feedback_test.rb

@@ -1,7 +1,7 @@
 # frozen_string_literal: true
 class ResourceFeedbackTest < Test::Unit::TestCase
   def test_get_resource_feedback
-    body = { resource_feedback: [ { resource_type: 'Shop' } ] }.to_json
+    body = { resource_feedback: [{ resource_type: 'Shop' }] }.to_json
     fake('resource_feedback', method: :get, body: body)
     resource_feedback = ShopifyAPI::ResourceFeedback.find(:all)
     assert_equal('Shop', resource_feedback.first.resource_type)
@@ -15,7 +15,7 @@ class ResourceFeedbackTest < Test::Unit::TestCase
   end
 
   def test_get_resource_feedback_with_product_id
-    body = { resource_feedback: [ { resource_type: 'Product' } ] }.to_json
+    body = { resource_feedback: [{ resource_type: 'Product' }] }.to_json
     fake('products/42/resource_feedback', method: :get, body: body)
     resource_feedback = ShopifyAPI::ResourceFeedback.find(:all, params: { product_id: 42 })
     assert_equal('Product', resource_feedback.first.resource_type)

+ 3 - 4
test/session_test.rb

@@ -3,7 +3,6 @@ require 'test_helper'
 require 'timecop'
 
 class SessionTest < Test::Unit::TestCase
-
   def setup
     super
     ShopifyAPI::Session.secret = 'secret'
@@ -233,7 +232,7 @@ class SessionTest < Test::Unit::TestCase
       token: 'any-token',
       api_version: any_api_version
     )
-    scope = ["write_products","write_customers"]
+    scope = ["write_products", "write_customers"]
     permission_url = session.create_permission_url(scope, "http://my_redirect_uri.com")
     assert_equal(
       "https://localhost.myshopify.com/admin/oauth/authorize?client_id=My_test_key&" \
@@ -333,7 +332,7 @@ class SessionTest < Test::Unit::TestCase
     params = { code: 'any-code', timestamp: Time.now }
     assert(session.request_token(params.merge(hmac: generate_signature(params))))
 
-    assert_equal(({ "foo" => "example" }), session.extra)
+    assert_equal({ "foo" => "example" }, session.extra)
   end
 
   test "expires_in is automatically converted in expires_at" do
@@ -351,7 +350,7 @@ class SessionTest < Test::Unit::TestCase
       assert(session.request_token(params.merge(hmac: generate_signature(params))))
 
       expires_at = Time.now.utc + 86393
-      assert_equal(({ "expires_at" => expires_at.to_i }), session.extra)
+      assert_equal({ "expires_at" => expires_at.to_i }, session.extra)
       assert(session.expires_at.is_a?(Time))
       assert_equal(expires_at.to_i, session.expires_at.to_i)
       assert_equal(86393, session.expires_in)

+ 0 - 2
test/storefront_access_token_test.rb

@@ -2,7 +2,6 @@
 require 'test_helper'
 
 class StorefrontAccessTokenTest < Test::Unit::TestCase
-
   def test_create_storefront_access_token
     fake("storefront_access_tokens", method: :post, body: load_fixture('storefront_access_token'))
     storefront_access_token = ShopifyAPI::StorefrontAccessToken.create(title: 'Test')
@@ -28,5 +27,4 @@ class StorefrontAccessTokenTest < Test::Unit::TestCase
     assert_equal('Test 1', tokens.first.title)
     assert_equal('Test 2', tokens.last.title)
   end
-
 end

+ 0 - 1
test/tax_service_test.rb

@@ -8,6 +8,5 @@ class TaxServiceTest < Test::Unit::TestCase
       '{"tax_service":{"name":"My Tax Service","url":"https://mytaxservice.com"}}',
       WebMock.last_request.body
     )
-
   end
 end

+ 4 - 4
test/test_helper.rb

@@ -94,14 +94,14 @@ module Test
       end
 
       def fake(endpoint, options = {})
-        request_body = options.has_key?(:request_body) ? options.delete(:request_body) : nil
-        body   = options.has_key?(:body) ? options.delete(:body) : load_fixture(endpoint)
+        request_body = options.key?(:request_body) ? options.delete(:request_body) : nil
+        body = options.key?(:body) ? options.delete(:body) : load_fixture(endpoint)
         format = options.delete(:format) || :json
         method = options.delete(:method) || :get
         api_version = options.delete(:api_version) || ShopifyAPI::ApiVersion.find_version('2019-01')
-        extension = ".#{options.delete(:extension)||'json'}" unless options[:extension]==false
+        extension = ".#{options.delete(:extension) || 'json'}" unless options[:extension] == false
         status = options.delete(:status) || 200
-        url = if options.has_key?(:url)
+        url = if options.key?(:url)
           options[:url]
         else
           "https://this-is-my-test-shop.myshopify.com#{api_version.construct_api_path("#{endpoint}#{extension}")}"

+ 0 - 2
test/usage_charge_test.rb

@@ -2,7 +2,6 @@
 require 'test_helper'
 
 class UsageChargeTest < Test::Unit::TestCase
-
   def test_create_usage_charges
     fake("recurring_application_charges/654381177/usage_charges", method: :post, body: load_fixture('usage_charge'))
 
@@ -23,5 +22,4 @@ class UsageChargeTest < Test::Unit::TestCase
 
     assert_equal("1000 emails", usage_charge.description)
   end
-
 end

+ 3 - 3
test/user_test.rb

@@ -4,14 +4,14 @@ require 'test_helper'
 class UserTest < Test::Unit::TestCase
   test 'get should get a user' do
     fake 'users/799407056', method: :get, status: 200, body: load_fixture('user')
-    
+
     user = ShopifyAPI::User.find(799407056)
     assert_equal 799407056, user.id
   end
-  
+
   test 'get should get all users' do
     fake 'users', method: :get, status: 200, body: load_fixture('users')
-    
+
     users = ShopifyAPI::User.all
     assert_equal 799407056, users.first.id
   end