Переглянути джерело

Merge pull request #244 from Shopify/better_detection_of_threadsafe_activeresource

Better detection of threadsafe ActiveResource
Peter McCracken 9 роки тому
батько
коміт
3be13526fc

+ 3 - 0
.travis.yml

@@ -10,6 +10,7 @@ gemfile:
   - Gemfile_ar31
   - Gemfile_ar32
   - Gemfile_ar40threadsafe
+  - Gemfile_ar42threadsafe
 
 sudo: false
 
@@ -17,6 +18,8 @@ before_script: echo $OLD_RAKE
 
 matrix:
   include:
+    - rvm: 2.2.1
+      gemfile: Gemfile_ar50
     - rvm: 1.9.2
       gemfile: Gemfile_ar30
       env: OLD_RAKE=1

+ 4 - 0
CHANGELOG

@@ -1,3 +1,7 @@
+== Version 4.2.0
+
+* Threadsafety is now compatible with the latest ActiveResource master
+
 == Version 4.1.1
 
 * Added explicit 90 second timeout to `ShopifyAPI::Base`

+ 11 - 0
Gemfile_ar50

@@ -0,0 +1,11 @@
+source "https://rubygems.org"
+
+gemspec
+
+gem 'activeresource', git: 'git://github.com/rails/activeresource', ref: 'c3cd2b535b7c5cdc12cc6a3c1e11be6c74ffa179'
+
+gem 'minitest', "~> 5.1"
+gem 'activesupport', github: 'rails/rails'
+gem 'activemodel', github: 'rails/rails'
+gem 'arel', github: 'rails/arel'
+gem 'rails-observers', github: 'rails/rails-observers'

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

@@ -28,7 +28,7 @@ module ShopifyAPI
     end
 
     class << self
-      if ActiveResource::VERSION::MAJOR == 4 && ActiveResource::VERSION::PRE == 'threadsafe'
+      if ActiveResource::Base.respond_to?(:_headers) && ActiveResource::Base.respond_to?(:_headers_defined?)
         def headers
           if _headers_defined?
             _headers

+ 1 - 1
lib/shopify_api/version.rb

@@ -1,3 +1,3 @@
 module ShopifyAPI
-  VERSION = "4.1.1"
+  VERSION = "4.2.0"
 end

+ 1 - 1
test/base_test.rb

@@ -88,7 +88,7 @@ class BaseTest < Test::Unit::TestCase
     end
   end
 
-  if ActiveResource::VERSION::MAJOR >= 4 && ActiveResource::VERSION::PRE == "threadsafe"
+  if ActiveResource::VERSION::MAJOR >= 5 || (ActiveResource::VERSION::MAJOR >= 4 && ActiveResource::VERSION::PRE == "threadsafe")
     test "#headers set in the main thread affect spawned threads" do
       ShopifyAPI::Base.headers['X-Custom'] = "the value"
       Thread.new do

+ 1 - 1
test/recurring_application_charge_test.rb

@@ -137,7 +137,7 @@ class RecurringApplicationChargeTest < Test::Unit::TestCase
     fake "recurring_application_charges", body: '{"errors":"Not Found"}', status: 404
 
     all_application_charges = ShopifyAPI::RecurringApplicationCharge.all
-    if ActiveResource::VERSION::MAJOR >= 4 && ActiveResource::VERSION::MINOR >= 2
+    if ActiveResource::VERSION::MAJOR >= 5 || (ActiveResource::VERSION::MAJOR == 4 && ActiveResource::VERSION::MINOR >= 2)
       assert_equal [], all_application_charges
     else
       assert_equal nil, all_application_charges