Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require File.dirname(__FILE__) + '/../test_api_helper'
- class CustomCollectionApiTest < Test::Unit::TestCase
- include ApiDocumentationSuite
- documentation('CustomCollection') do |controller|
- controller.action :index do |doc|
- doc.description "Get a list of Custom Collections"
- doc.example 'List all collections' do
- collections = ShopifyAPI::CustomCollection.find(:all)
- assert_equal 1, collections.size
- # Regenerate test case:
- #freeze('collections', collections)
- assert_equal 1, collections.size
- assert_equal ["body", "body_html", "handle", "id", "published_at", "title", "updated_at"], collections[0].attributes.keys.sort
- assert_equal "The best selling ipod ever", collections[0].body
- assert_equal "<p>The best selling ipod ever</p>", collections[0].body_html
- assert_equal "ipods", collections[0].handle
- assert_equal Time.parse('Sat Feb 02 00:00:00 UTC 2008'), collections[0].published_at
- assert_equal "IPods", collections[0].title
- end
- end
- controller.action :show do |doc|
- doc.description "Get a list of Custom Collections"
- doc.example 'Get a specific collection' do
- collection = ShopifyAPI::CustomCollection.find( collections(:ipods).id )
- # Regenerate test case:
- #freeze('collection', collection)
- assert_equal ["body", "body_html", "handle", "id", "published_at", "title", "updated_at"], collection.attributes.keys.sort
- assert_equal 'The best selling ipod ever', collection.body
- assert_equal "<p>The best selling ipod ever</p>", collection.body_html
- assert_equal "ipods", collection.handle
- assert_equal Time.parse('Sat Feb 02 00:00:00 UTC 2008'), collection.published_at
- assert_equal "IPods", collection.title
- end
- end
- controller.action :create do |doc|
- doc.description "Create a new custom collection"
- doc.example 'Create a collection with title Macbooks' do
- assert_difference 'Collection.count', +1 do
- collection = ShopifyAPI::CustomCollection.new( :title => 'Macbooks' )
- assert collection.save
- assert collection.valid?
- assert_equal 'Macbooks', collection.title
- end
- end
- end
- controller.action :update do |doc|
- doc.description 'Update a existing custom collection'
- doc.example "Change the description of the IPod collection" do
- collection = ShopifyAPI::CustomCollection.find( collections(:ipods).id )
- collection.body = '5000 songs in your pocket'
- assert collection.save
- collections(:featured).reload
- # Regenerate test case:
- #freeze('collection', collection)
- assert_equal ["body", "body_html", "handle", "id", "published_at", "title", "updated_at"], collection.attributes.keys.sort
- assert_equal "5000 songs in your pocket", collection.body
- assert_equal "<p>5000 songs in your pocket</p>", collection.body_html
- assert_equal "ipods", collection.handle
- assert_equal Time.parse('Sat Feb 02 00:00:00 UTC 2008'), collection.published_at
- assert_equal "IPods", collection.title
- end
- end
- controller.action :destroy do |doc|
- doc.example "Remove ipod custom collection" do
- assert_difference 'Collection.count', -1 do
- ShopifyAPI::CustomCollection.find( collections(:ipods).id ).destroy
- end
- end
- end
- end
- end
Add Comment
Please, Sign In to add comment