Sha256: 992109cf4305e0e14244fd938c506c10731eac64facadc382d2ce49fea295ac0

Contents?: true

Size: 1.63 KB

Versions: 34

Compression:

Stored size: 1.63 KB

Contents

class ResourceFeedbackTest < Test::Unit::TestCase
  def test_get_resource_feedback
    body = { resource_feedback: [ { resource_type: 'Shop' } ] }.to_json
    fake 'resource_feedback', method: :get, body: body
    resource_feedback = ShopifyAPI::ResourceFeedback.find(:all)
    assert_equal 'Shop', resource_feedback.first.resource_type
  end

  def test_save_with_resource_feedback_endpoint
    body = { resource_feedback: {} }.to_json
    fake 'resource_feedback', method: :post, body: body
    ShopifyAPI::ResourceFeedback.new.save
    assert_request_body body
  end

  def test_get_resource_feedback_with_product_id
    body = { resource_feedback: [ { resource_type: 'Product' } ] }.to_json
    fake 'products/42/resource_feedback', method: :get, body: body
    resource_feedback = ShopifyAPI::ResourceFeedback.find(:all, params: { product_id: 42 })
    assert_equal 'Product', resource_feedback.first.resource_type
  end

  def test_save_with_product_id_resource_feedback_endpoint
    body = { resource_feedback: {} }.to_json
    fake 'products/42/resource_feedback', method: :post, body: body
    ShopifyAPI::ResourceFeedback.new(product_id: 42).save
    assert_request_body body
  end

  def test_save_raises_exception_when_already_persisted
    body = { resource_feedback: {} }.to_json
    fake 'resource_feedback', method: :post, body: body
    resource_feedback = ShopifyAPI::ResourceFeedback.new
    resource_feedback.save
    assert_request_body body

    ShopifyAPI::ResourceFeedback.any_instance.expects(:persisted?).returns(true)
    assert_raises ShopifyAPI::ResourceFeedback::ExistingFeedbackSaved do
      resource_feedback.save
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
shopify_api-9.2.0 test/resource_feedback_test.rb
shopify_api-9.1.0 test/resource_feedback_test.rb
shopify_api-9.0.4 test/resource_feedback_test.rb
shopify_api-9.0.3 test/resource_feedback_test.rb
shopify_api-9.0.2 test/resource_feedback_test.rb
shopify_api-9.0.1 test/resource_feedback_test.rb
shopify_api-9.0.0 test/resource_feedback_test.rb
shopify_api-8.1.0 test/resource_feedback_test.rb
shopify_api-8.0.0 test/resource_feedback_test.rb
shopify_api-7.1.0 test/resource_feedback_test.rb
shopify_api-7.0.2 test/resource_feedback_test.rb
shopify_api-7.0.1 test/resource_feedback_test.rb
shopify_api-7.0.0 test/resource_feedback_test.rb
shopify_api-6.0.0 test/resource_feedback_test.rb
shopify_api-5.2.4 test/resource_feedback_test.rb
shopify_api-5.2.3 test/resource_feedback_test.rb
shopify_api-5.2.2 test/resource_feedback_test.rb
shopify_api-5.2.1 test/resource_feedback_test.rb
shopify_api-5.2.0 test/resource_feedback_test.rb
shopify_api-5.1.0 test/resource_feedback_test.rb