Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Workaround ActiveResource 3.1+ bug for saving nested resources.

  • Loading branch information...
commit 0e67bfc6c946a2b4de454028c807aff24ff2bc9b 1 parent 8081e2e
Dylan Thacker-Smith dylanahsmith authored
6 lib/shopify_api/resources/base.rb
View
@@ -28,7 +28,11 @@ def clear_session
self.site = nil
self.headers.delete('X-Shopify-Access-Token')
end
- end
+ end
+
+ def persisted?
+ !id.nil?
+ end
private
def only_id
4 test/fixtures/product.json
View
@@ -23,6 +23,7 @@
{
"position": 1,
"price": "199.00",
+ "product_id": 632910392,
"created_at": "2011-10-20T14:05:13-04:00",
"requires_shipping": true,
"title": "Pink",
@@ -43,6 +44,7 @@
{
"position": 2,
"price": "199.00",
+ "product_id": 632910392,
"created_at": "2011-10-20T14:05:13-04:00",
"requires_shipping": true,
"title": "Red",
@@ -63,6 +65,7 @@
{
"position": 3,
"price": "199.00",
+ "product_id": 632910392,
"created_at": "2011-10-20T14:05:13-04:00",
"requires_shipping": true,
"title": "Green",
@@ -83,6 +86,7 @@
{
"position": 4,
"price": "199.00",
+ "product_id": 632910392,
"created_at": "2011-10-20T14:05:13-04:00",
"requires_shipping": true,
"title": "Black",
8 test/product_test.rb
View
@@ -27,4 +27,12 @@ def test_get_metafields_for_product
assert_equal 2, metafields.length
assert metafields.all?{|m| m.is_a?(ShopifyAPI::Metafield)}
end
+
+ def test_update_loaded_variant
+ fake "products/632910392/variants/808950810", :method => :put, :status => 200, :body => load_fixture('variant')
+
+ variant = @product.variants.first
+ variant.price = "0.50"
+ variant.save
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.