Browse Source

Added currency endpoint to api gem

grcooper 6 years ago
parent
commit
f9a4b32641
3 changed files with 52 additions and 0 deletions
  1. 6 0
      lib/shopify_api/resources/currency.rb
  2. 21 0
      test/currency_test.rb
  3. 25 0
      test/fixtures/currencies.json

+ 6 - 0
lib/shopify_api/resources/currency.rb

@@ -0,0 +1,6 @@
+# frozen_string_literal: true
+
+module ShopifyAPI
+  class Currency < Base
+  end
+end

+ 21 - 0
test/currency_test.rb

@@ -0,0 +1,21 @@
+
+# frozen_string_literal: true
+require 'test_helper'
+class CurrencyTest < Test::Unit::TestCase
+  def setup
+    super
+    fake "currencies", method: :get, body: load_fixture('currencies')
+  end
+
+  context "Currency" do
+    should 'return a list of enabled currencies' do
+      currencies = ShopifyAPI::Currency.all
+      assert_equal 4, currencies.count
+      assert_equal %w(AUD EUR GBP HKD), currencies.map(&:currency)
+      assert_equal [true, true, true, false], currencies.map(&:enabled)
+      currencies.each do |currency|
+        assert_equal "2018-10-03T14:44:08-04:00", currency.rate_updated_at
+      end
+    end
+  end
+end

+ 25 - 0
test/fixtures/currencies.json

@@ -0,0 +1,25 @@
+{
+  "currencies": [
+    {
+        "currency": "AUD",
+        "rate_updated_at": "2018-10-03T14:44:08-04:00",
+        "enabled": true
+    },
+    {
+        "currency": "EUR",
+        "rate_updated_at": "2018-10-03T14:44:08-04:00",
+        "enabled": true
+    },
+    {
+        "currency": "GBP",
+        "rate_updated_at": "2018-10-03T14:44:08-04:00",
+        "enabled": true
+    },
+    {
+        "currency": "HKD",
+        "rate_updated_at": "2018-10-03T14:44:08-04:00",
+        "enabled": false
+    }
+  ]
+}
+