Sha256: e0149dfdfb437514d00222bc905c3894cd71f0d9392cc020fdd317c079539045

Contents?: true

Size: 2 KB

Versions: 5

Compression:

Stored size: 2 KB

Contents

require File.expand_path('../../../test_helper', __FILE__)
require File.expand_path('../../../fixtures/active_record', __FILE__)

class RequestTest < ActionDispatch::IntegrationTest

  def test_get
    get '/posts'
    assert_equal 200, status
  end

  def test_get_underscored_key
    JSONAPI.configuration.json_key_format = :underscored_key
    get '/iso_currencies'
    assert_equal 200, status
    assert_equal 3, json_response['iso_currencies'].size
  end

  def test_get_underscored_key_filtered
    JSONAPI.configuration.json_key_format = :underscored_key
    get '/iso_currencies?country_name=Canada'
    assert_equal 200, status
    assert_equal 1, json_response['iso_currencies'].size
    assert_equal 'Canada', json_response['iso_currencies'][0]['country_name']
  end

  def test_get_camelized_key_filtered
    JSONAPI.configuration.json_key_format = :camelized_key
    get '/iso_currencies?countryName=Canada'
    assert_equal 200, status
    assert_equal 1, json_response['isoCurrencies'].size
    assert_equal 'Canada', json_response['isoCurrencies'][0]['countryName']
  end

  def test_get_camelized_route_and_key_filtered
    get '/api/v4/isoCurrencies?countryName=Canada'
    assert_equal 200, status
    assert_equal 1, json_response['isoCurrencies'].size
    assert_equal 'Canada', json_response['isoCurrencies'][0]['countryName']
  end

  def test_get_camelized_route_and_links
    JSONAPI.configuration.json_key_format = :camelized_key
    get '/api/v4/expenseEntries/1/links/isoCurrency'
    assert_equal 200, status
    assert_equal 'USD', json_response['isoCurrency']
  end

  def test_put_single
    put '/posts/3',
        {
          'posts' => {
            'id' => '3',
            'title' => 'A great new Post',
            'links' => {
              'tags' => [3, 4]
            }
          }
        }
    assert_equal 200, status
  end

  def test_destroy_single
    delete '/posts/7'
    assert_equal 204, status
  end

  def test_destroy_multiple
    delete '/posts/8,9'
    assert_equal 204, status
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
jsonapi-resources-0.1.0 test/integration/requests/request_test.rb
jsonapi-resources-0.0.16 test/integration/requests/request_test.rb
jsonapi-resources-0.0.15 test/integration/requests/request_test.rb
jsonapi-resources-0.0.14 test/integration/requests/request_test.rb
jsonapi-resources-0.0.13 test/integration/requests/request_test.rb