Skip to content

Commit

Permalink
Add collection listing
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Scriven committed Jan 9, 2017
1 parent 44a572e commit d65ece3
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/shopify_api/resources/collection_listing.rb
@@ -0,0 +1,5 @@
module ShopifyAPI
class CollectionListing < Base
init_prefix :application
end
end
32 changes: 32 additions & 0 deletions test/collection_listing_test.rb
@@ -0,0 +1,32 @@
require 'test_helper'

class CollectionListingTest < Test::Unit::TestCase

def test_get_collection_listings
fake "applications/999/collection_listings", method: :get, status: 201, body: load_fixture('collection_listings')

collection_listings = ShopifyAPI::CollectionListing.find(:all, params: { application_id: 999 })

assert_equal 1, collection_listings.count
assert_equal 1, collection_listings.first.collection_id
assert_equal 'Home page', collection_listings.first.title
end

# def test_get_collection_listing_for_collection_id
# fake "applications/999/collection_listings/2", method: :get, status: 201, body: load_fixture('collection_listing')

# collection_listing = ShopifyAPI::CollectionListing.find(2, params: { application_id: 999 })

# assert_equal 'Synergistic Silk Chair', collection_listing.title
# end

# def test_get_collection_listing_product_ids
# fake "applications/999/collection_listings/product_ids", method: :get, status: 201, body: load_fixture('collection_listing_product_ids')

# product_ids = ShopifyAPI::CollectionListing.product_ids(params: { application_id: 999 })

# assert_equal 2, product_ids.count
# assert_equal 2, product_ids.first
# assert_equal 1, product_ids.last
# end
end
13 changes: 13 additions & 0 deletions test/fixtures/collection_listings.json
@@ -0,0 +1,13 @@
[
{
"collection_id": 1,
"updated_at": "2017-01-09T13:59:09-05:00",
"body_html": null,
"default_product_image": null,
"handle": "frontpage",
"image": null,
"title": "Home page",
"sort_order": "alpha-asc",
"published_at": "2017-01-09T13:59:09-05:00"
}
]

0 comments on commit d65ece3

Please sign in to comment.