rapid_api 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/lib/rapid_api/action_controller/macros.rb +1 -1
- data/lib/rapid_api/action_controller/{rest_actions.rb → resource_actions.rb} +5 -5
- data/lib/rapid_api/action_controller/scope.rb +1 -1
- data/lib/rapid_api/action_controller.rb +1 -1
- data/lib/rapid_api/auth/concerns/authenticated_controller.rb +1 -1
- data/lib/rapid_api/auth/concerns/sessions_controller.rb +1 -1
- data/lib/rapid_api/serializer_adapters/ams_adapter.rb +3 -4
- data/lib/rapid_api/version.rb +1 -1
- data/lib/rapid_api.rb +4 -0
- data/test/integration/ams_ar_test.rb +4 -4
- data/test/support/schema.rb +2 -2
- data/test/test_helper.rb +3 -1
- data/test/unit/rapid_api/action_controller/filterable_params_test.rb +1 -1
- data/test/unit/rapid_api/action_controller/permitted_params_test.rb +1 -1
- data/test/unit/rapid_api/action_controller/{rest_actions_test.rb → resource_actions_test.rb} +13 -12
- data/test/unit/rapid_api/action_controller/scope_test.rb +1 -1
- data/test/unit/rapid_api/auth/concerns/sessions_controller_test.rb +3 -2
- data/test/unit/rapid_api/serializer_adapters/ams_adapter_test.rb +2 -2
- data/test/unit/rapid_api/test_configuration.rb +1 -1
- metadata +26 -26
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: a317e01d9c60b75776646b2c520414e8fab282b8
         | 
| 4 | 
            +
              data.tar.gz: c61257d9c0ff646b86dc615dca07d8002bcd3e22
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: e2f62bc1b1c41408b0099c3145465a5a433a5584889f6b18f1353455d60ac848f8536a60f42bc5e6cccfa28d343599bcd86fe8bdc4263a66196e0fb1f1520bf6
         | 
| 7 | 
            +
              data.tar.gz: 89d9835c7aaf5bfca6a5ff8ab10f37c193ec12ca4e060107216a1946ea5e6dd5029080875c251ddde36e1a9a46871ecdd89a4ae0d24bb51751473b87accf0050
         | 
    
        data/README.md
    CHANGED
    
    | @@ -2,7 +2,7 @@ | |
| 2 2 |  | 
| 3 3 | 
             
            *NOT PRODUCTION READY*
         | 
| 4 4 |  | 
| 5 | 
            -
            __A framework for rapid development of Rails APIs__-- *RapidApi* aims to reduce code maintenance and testing costs, while increasing speed of development. Because the ceremony of rendering  | 
| 5 | 
            +
            __A framework for rapid development of Rails APIs__-- *RapidApi* aims to reduce code maintenance and testing costs, while increasing speed of development. Because the ceremony of rendering resource actions is performed for you, you can focus more time on what makes your app unique.
         | 
| 6 6 |  | 
| 7 7 | 
             
            ## Installation
         | 
| 8 8 | 
             
            Include in your Gemfile:
         | 
| @@ -13,7 +13,7 @@ gem 'rapid_api', git: 'git://github.com/briandavidwetzel/rapid_api.git' | |
| 13 13 |  | 
| 14 14 | 
             
            ## Documentation
         | 
| 15 15 | 
             
            ### Rapid Actions
         | 
| 16 | 
            -
            Including `rapid_actions` in your controller will give you conventional  | 
| 16 | 
            +
            Including `rapid_actions` in your controller will give you conventional resourceful actions: `#index, #show, #create, #update, and #destroy`.
         | 
| 17 17 | 
             
            ```ruby
         | 
| 18 18 | 
             
            class BricksController < ApplicationController
         | 
| 19 19 | 
             
              rapid_actions
         | 
| @@ -110,7 +110,7 @@ class ApplicationController | |
| 110 110 | 
             
              end
         | 
| 111 111 | 
             
            end
         | 
| 112 112 | 
             
            ```
         | 
| 113 | 
            -
            `rapid_base_controller` can be added to the base class for your api controllers to provide a  | 
| 113 | 
            +
            `rapid_base_controller` can be added to the base class for your api controllers to provide a before_action that checks authentication. Note if your SessionController is derived from the same base class, then you should add `skip_before_action :authenticate!` to your SessionsController.  The `authenticate` macro should be passed a block that returns the authenticated object. *In the example, the 'Authorization' token is parsed to return the current user*. If your authenticate block returns nil, then `:unauthorized` will be rendered.
         | 
| 114 114 |  | 
| 115 115 | 
             
            Also note that the `decode_jwt_token!` can raise errors that will result in the rendering of an `:unauthorized` response.
         | 
| 116 116 |  | 
| @@ -5,7 +5,7 @@ module RapidApi | |
| 5 5 |  | 
| 6 6 | 
             
                  module ClassMethods
         | 
| 7 7 | 
             
                    def rapid_actions(options={})
         | 
| 8 | 
            -
                      include RapidApi::ActionController:: | 
| 8 | 
            +
                      include RapidApi::ActionController::ResourceActions
         | 
| 9 9 | 
             
                      self.model              = options[:model]              if options[:model]
         | 
| 10 10 | 
             
                      self.serializer         = options[:serializer]         if options[:serializer]
         | 
| 11 11 | 
             
                      self.model_adapter      = options[:model_adapter]      if options[:model_adapter]
         | 
| @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            module RapidApi
         | 
| 2 2 | 
             
              module ActionController
         | 
| 3 3 |  | 
| 4 | 
            -
                module  | 
| 4 | 
            +
                module ResourceActions
         | 
| 5 5 | 
             
                  extend ActiveSupport::Concern
         | 
| 6 6 | 
             
                  include PermittedParams
         | 
| 7 7 | 
             
                  include FilterableParams
         | 
| @@ -14,7 +14,7 @@ module RapidApi | |
| 14 14 | 
             
                  end
         | 
| 15 15 |  | 
| 16 16 | 
             
                  def index
         | 
| 17 | 
            -
                    query_result = _adapted_model.find_all filterable_params, scope
         | 
| 17 | 
            +
                    query_result = _adapted_model.find_all filterable_params.to_h, scope
         | 
| 18 18 | 
             
                    render json: _adapted_serializer.serialize_collection(query_result.data), status: response_code_for(:ok)
         | 
| 19 19 | 
             
                  end
         | 
| 20 20 |  | 
| @@ -69,7 +69,7 @@ module RapidApi | |
| 69 69 | 
             
                  end
         | 
| 70 70 |  | 
| 71 71 | 
             
                  def _member_params
         | 
| 72 | 
            -
                    _permitted_params_for(_params_key)
         | 
| 72 | 
            +
                    _permitted_params_for(_params_key).to_h
         | 
| 73 73 | 
             
                  end
         | 
| 74 74 |  | 
| 75 75 | 
             
                  def _model
         | 
| @@ -125,7 +125,7 @@ module RapidApi | |
| 125 125 | 
             
                    end
         | 
| 126 126 |  | 
| 127 127 | 
             
                    def params_key
         | 
| 128 | 
            -
                      @params_key ||= model.to_s.underscore
         | 
| 128 | 
            +
                      @params_key ||= model.to_s.underscore.split('::').last
         | 
| 129 129 | 
             
                    end
         | 
| 130 130 |  | 
| 131 131 | 
             
                    def model_adapter=(adapter)
         | 
| @@ -149,7 +149,7 @@ module RapidApi | |
| 149 149 | 
             
                    end
         | 
| 150 150 |  | 
| 151 151 | 
             
                    def _reset_params_key
         | 
| 152 | 
            -
                      @params_key = model.to_s.underscore
         | 
| 152 | 
            +
                      @params_key = model.to_s.underscore.split('::').last
         | 
| 153 153 | 
             
                    end
         | 
| 154 154 | 
             
                  end
         | 
| 155 155 | 
             
                end
         | 
| @@ -2,7 +2,7 @@ require 'rapid_api/action_controller/permitted_params' | |
| 2 2 | 
             
            require 'rapid_api/action_controller/errors'
         | 
| 3 3 | 
             
            require 'rapid_api/action_controller/scope'
         | 
| 4 4 | 
             
            require 'rapid_api/action_controller/filterable_params'
         | 
| 5 | 
            -
            require 'rapid_api/action_controller/ | 
| 5 | 
            +
            require 'rapid_api/action_controller/resource_actions'
         | 
| 6 6 | 
             
            require 'rapid_api/action_controller/macros'
         | 
| 7 7 |  | 
| 8 8 | 
             
            module RapidApi
         | 
| @@ -4,15 +4,14 @@ module RapidApi | |
| 4 4 |  | 
| 5 5 | 
             
                  def serialize(member)
         | 
| 6 6 | 
             
                    serializer = klass.new(member)
         | 
| 7 | 
            -
                    serializer.to_json
         | 
| 7 | 
            +
                    ActiveModelSerializers::Adapter.create(serializer).to_json
         | 
| 8 8 | 
             
                  end
         | 
| 9 9 |  | 
| 10 10 | 
             
                  def serialize_collection(collection)
         | 
| 11 | 
            -
                     | 
| 11 | 
            +
                    collection_serializer = ActiveModel::Serializer::CollectionSerializer.new collection, {
         | 
| 12 12 | 
             
                                         each_serializer: klass
         | 
| 13 13 | 
             
                                       }
         | 
| 14 | 
            -
                     | 
| 15 | 
            -
                    array_serializer.to_json
         | 
| 14 | 
            +
                    ActiveModelSerializers::Adapter.create(collection_serializer).to_json
         | 
| 16 15 | 
             
                  end
         | 
| 17 16 |  | 
| 18 17 | 
             
                end
         | 
    
        data/lib/rapid_api/version.rb
    CHANGED
    
    
    
        data/lib/rapid_api.rb
    CHANGED
    
    
| @@ -32,13 +32,13 @@ class AmsArTest < ActionController::TestCase | |
| 32 32 | 
             
                brick1 = @user1.bricks.create color: 'yellow',  weight: 10, material: 'gold'
         | 
| 33 33 | 
             
                brick2 = @user1.bricks.create color: 'red',     weight: 1,  material: 'clay'
         | 
| 34 34 | 
             
                brick3 = @user2.bricks.create color: 'magenta', weight: 0,  material: 'feathers'
         | 
| 35 | 
            -
                get :index, { user_id: @user1.id }
         | 
| 36 | 
            -
                assert_equal "{\" | 
| 35 | 
            +
                get :index, params: { user_id: @user1.id }
         | 
| 36 | 
            +
                assert_equal "{\"data\":[{\"id\":\"#{brick1.id}\",\"type\":\"bricks\",\"attributes\":{\"color\":\"yellow\",\"weight\":\"10.0\",\"material\":\"gold\"}},{\"id\":\"#{brick2.id}\",\"type\":\"bricks\",\"attributes\":{\"color\":\"red\",\"weight\":\"1.0\",\"material\":\"clay\"}}]}", response.body
         | 
| 37 37 | 
             
              end
         | 
| 38 38 |  | 
| 39 39 | 
             
              def test_show
         | 
| 40 40 | 
             
                brick = Brick.create color: 'red',    weight: 1,  material: 'clay'
         | 
| 41 | 
            -
                get :show, {id: brick.id}
         | 
| 42 | 
            -
                assert_equal "{\"brick\":{\"color\":\"red\",\"weight\":\"1.0\",\"material\":\"clay\"}}", response.body
         | 
| 41 | 
            +
                get :show, params: {id: brick.id}
         | 
| 42 | 
            +
                assert_equal "{\"data\":{\"id\":\"#{brick.id}\",\"type\":\"bricks\",\"attributes\":{\"color\":\"red\",\"weight\":\"1.0\",\"material\":\"clay\"}}}", response.body
         | 
| 43 43 | 
             
              end
         | 
| 44 44 | 
             
            end
         | 
    
        data/test/support/schema.rb
    CHANGED
    
    | @@ -1,6 +1,6 @@ | |
| 1 1 | 
             
            ActiveRecord::Schema.define do
         | 
| 2 | 
            -
              connection.drop_table :bricks if connection. | 
| 3 | 
            -
              connection.drop_table :users  if connection. | 
| 2 | 
            +
              connection.drop_table :bricks if connection.data_source_exists? :bricks
         | 
| 3 | 
            +
              connection.drop_table :users  if connection.data_source_exists? :users
         | 
| 4 4 | 
             
              create_table :bricks do |t|
         | 
| 5 5 | 
             
                t.string  :color
         | 
| 6 6 | 
             
                t.decimal :weight
         | 
    
        data/test/test_helper.rb
    CHANGED
    
    | @@ -1,8 +1,9 @@ | |
| 1 1 | 
             
            require 'bundler/setup'
         | 
| 2 | 
            -
            require ' | 
| 2 | 
            +
            require 'byebug'
         | 
| 3 3 | 
             
            require 'rails'
         | 
| 4 4 | 
             
            require 'action_controller'
         | 
| 5 5 | 
             
            require 'action_controller/test_case'
         | 
| 6 | 
            +
            require 'active_model_serializers'
         | 
| 6 7 | 
             
            require 'rapid_api'
         | 
| 7 8 | 
             
            require 'minitest/autorun'
         | 
| 8 9 |  | 
| @@ -11,6 +12,7 @@ Dir['./test/support/**/*.rb'].each {|f| require f} | |
| 11 12 | 
             
            module TestHelper
         | 
| 12 13 | 
             
              Routes = ActionDispatch::Routing::RouteSet.new
         | 
| 13 14 | 
             
              Routes.draw do
         | 
| 15 | 
            +
                # TODO: Need to deal with the deprecation of the dynamic segments
         | 
| 14 16 | 
             
                get ':controller(/:action(/:id))'
         | 
| 15 17 | 
             
                get ':controller(/:action)'
         | 
| 16 18 | 
             
              end
         | 
| @@ -21,7 +21,7 @@ module ActionController | |
| 21 21 | 
             
                end
         | 
| 22 22 |  | 
| 23 23 | 
             
                def test_filterable_params
         | 
| 24 | 
            -
                  post :filterable_bricks, { color: 'blue', material: 'steel' }
         | 
| 24 | 
            +
                  post :filterable_bricks, params: { color: 'blue', material: 'steel' }
         | 
| 25 25 | 
             
                  body = JSON.parse(@controller.response.body)
         | 
| 26 26 | 
             
                  expected = { 'color' => 'blue' }
         | 
| 27 27 | 
             
                  assert_equal expected, body
         | 
| @@ -21,7 +21,7 @@ module ActionController | |
| 21 21 | 
             
                end
         | 
| 22 22 |  | 
| 23 23 | 
             
                def test_permitted_params_for
         | 
| 24 | 
            -
                  post :permissive_bricks, {brick: {color: 'red', weight: 1}}
         | 
| 24 | 
            +
                  post :permissive_bricks, params: {brick: {color: 'red', weight: 1}}
         | 
| 25 25 | 
             
                  refute response.body.include?("\"weight\":\"1.0\""), ":attribute should not have been permitted."
         | 
| 26 26 | 
             
                  assert response.body.include?("\"color\":\"red\""), ":attribute should have been permitted."
         | 
| 27 27 | 
             
                end
         | 
    
        data/test/unit/rapid_api/action_controller/{rest_actions_test.rb → resource_actions_test.rb}
    RENAMED
    
    | @@ -2,10 +2,10 @@ require File.expand_path '../../../../test_helper.rb', __FILE__ | |
| 2 2 |  | 
| 3 3 | 
             
            module ActionController
         | 
| 4 4 |  | 
| 5 | 
            -
              class  | 
| 5 | 
            +
              class ResourceActionsTest < ActionController::TestCase
         | 
| 6 6 |  | 
| 7 7 | 
             
                class BricksController < ActionController::Base
         | 
| 8 | 
            -
                  include RapidApi::ActionController:: | 
| 8 | 
            +
                  include RapidApi::ActionController::ResourceActions
         | 
| 9 9 |  | 
| 10 10 | 
             
                  self.model_adapter      = TestModelAdapter
         | 
| 11 11 | 
             
                  self.serializer_adapter = TestSerializerAdapter
         | 
| @@ -30,6 +30,7 @@ module ActionController | |
| 30 30 | 
             
                  assert_equal Brick, BricksController.model
         | 
| 31 31 | 
             
                  BricksController.model = Foo
         | 
| 32 32 | 
             
                  assert_equal Foo, BricksController.model
         | 
| 33 | 
            +
                  BricksController.model = Brick
         | 
| 33 34 | 
             
                end
         | 
| 34 35 |  | 
| 35 36 | 
             
                def test_params_key
         | 
| @@ -55,7 +56,7 @@ module ActionController | |
| 55 56 | 
             
                  BricksController.adapted_model.expect :find_all, query_result, [{'color' => 'green'}, {color: 'blue'}]
         | 
| 56 57 | 
             
                  BricksController.adapted_serializer = Minitest::Mock.new
         | 
| 57 58 | 
             
                  BricksController.adapted_serializer.expect :serialize_collection, nil, ['data']
         | 
| 58 | 
            -
                  get :index, {color: 'green', material: 'leaves'}
         | 
| 59 | 
            +
                  get :index, params: {color: 'green', material: 'leaves'}
         | 
| 59 60 | 
             
                  assert_response :ok
         | 
| 60 61 | 
             
                  BricksController.adapted_model.verify
         | 
| 61 62 | 
             
                  BricksController.adapted_serializer.verify
         | 
| @@ -67,7 +68,7 @@ module ActionController | |
| 67 68 | 
             
                  BricksController.adapted_model.expect :find, query_result, ["1", {color: 'blue'}]
         | 
| 68 69 | 
             
                  BricksController.adapted_serializer = Minitest::Mock.new
         | 
| 69 70 | 
             
                  BricksController.adapted_serializer.expect :serialize, nil, ['data']
         | 
| 70 | 
            -
                  get :show, {id: 1}
         | 
| 71 | 
            +
                  get :show, params: {id: 1}
         | 
| 71 72 | 
             
                  assert_response :ok
         | 
| 72 73 | 
             
                  BricksController.adapted_model.verify
         | 
| 73 74 | 
             
                  BricksController.adapted_serializer.verify
         | 
| @@ -77,7 +78,7 @@ module ActionController | |
| 77 78 | 
             
                  BricksController.adapted_model = Minitest::Mock.new
         | 
| 78 79 | 
             
                  query_result = RapidApi::ModelAdapters::QueryResult.new()
         | 
| 79 80 | 
             
                  BricksController.adapted_model.expect :find, query_result, ["1", {color: 'blue'}]
         | 
| 80 | 
            -
                  get :show, {id: 1}
         | 
| 81 | 
            +
                  get :show, params: {id: 1}
         | 
| 81 82 | 
             
                  assert_response :not_found
         | 
| 82 83 | 
             
                  BricksController.adapted_model.verify
         | 
| 83 84 | 
             
                end
         | 
| @@ -89,7 +90,7 @@ module ActionController | |
| 89 90 | 
             
                  BricksController.adapted_model.expect :create, query_result, [params, {color: 'blue'}]
         | 
| 90 91 | 
             
                  BricksController.adapted_serializer = Minitest::Mock.new
         | 
| 91 92 | 
             
                  BricksController.adapted_serializer.expect :serialize, nil, ['data']
         | 
| 92 | 
            -
                  post :create, {brick: params}
         | 
| 93 | 
            +
                  post :create, params: {brick: params}
         | 
| 93 94 | 
             
                  assert_response :created
         | 
| 94 95 | 
             
                  BricksController.adapted_model.verify
         | 
| 95 96 | 
             
                  BricksController.adapted_serializer.verify
         | 
| @@ -100,7 +101,7 @@ module ActionController | |
| 100 101 | 
             
                  BricksController.adapted_model = Minitest::Mock.new
         | 
| 101 102 | 
             
                  query_result = RapidApi::ModelAdapters::QueryResult.new(data: 'data', errors: 'dummy error')
         | 
| 102 103 | 
             
                  BricksController.adapted_model.expect :create, query_result, [params, {color: 'blue'}]
         | 
| 103 | 
            -
                  post :create, {brick: params}
         | 
| 104 | 
            +
                  post :create, params: {brick: params}
         | 
| 104 105 | 
             
                  assert_response :unprocessable_entity
         | 
| 105 106 | 
             
                  assert_equal 'dummy error', JSON.parse(@controller.response.body)['errors']
         | 
| 106 107 | 
             
                end
         | 
| @@ -112,7 +113,7 @@ module ActionController | |
| 112 113 | 
             
                  BricksController.adapted_model.expect :update, query_result, ["1", params, {color: 'blue'}]
         | 
| 113 114 | 
             
                  BricksController.adapted_serializer = Minitest::Mock.new
         | 
| 114 115 | 
             
                  BricksController.adapted_serializer.expect :serialize, nil, ['data']
         | 
| 115 | 
            -
                  post :update, {brick: params, id: 1}
         | 
| 116 | 
            +
                  post :update, params: {brick: params, id: 1}
         | 
| 116 117 | 
             
                  assert_response :ok
         | 
| 117 118 | 
             
                  BricksController.adapted_model.verify
         | 
| 118 119 | 
             
                  BricksController.adapted_serializer.verify
         | 
| @@ -123,7 +124,7 @@ module ActionController | |
| 123 124 | 
             
                  BricksController.adapted_model = Minitest::Mock.new
         | 
| 124 125 | 
             
                  query_result = RapidApi::ModelAdapters::QueryResult.new()
         | 
| 125 126 | 
             
                  BricksController.adapted_model.expect :update, query_result, ["1", params, {color: 'blue'}]
         | 
| 126 | 
            -
                  post :update, {brick: params, id: 1}
         | 
| 127 | 
            +
                  post :update, params: {brick: params, id: 1}
         | 
| 127 128 | 
             
                  assert_response :not_found
         | 
| 128 129 | 
             
                  BricksController.adapted_model.verify
         | 
| 129 130 | 
             
                end
         | 
| @@ -133,7 +134,7 @@ module ActionController | |
| 133 134 | 
             
                  BricksController.adapted_model = Minitest::Mock.new
         | 
| 134 135 | 
             
                  query_result = RapidApi::ModelAdapters::QueryResult.new(data: 'data', errors: 'dummy error')
         | 
| 135 136 | 
             
                  BricksController.adapted_model.expect :update, query_result, ["1", params, {color: 'blue'}]
         | 
| 136 | 
            -
                  post :update, {brick: params, id: 1}
         | 
| 137 | 
            +
                  post :update, params: {brick: params, id: 1}
         | 
| 137 138 | 
             
                  assert_response :unprocessable_entity
         | 
| 138 139 | 
             
                  BricksController.adapted_model.verify
         | 
| 139 140 | 
             
                end
         | 
| @@ -142,7 +143,7 @@ module ActionController | |
| 142 143 | 
             
                  BricksController.adapted_model = Minitest::Mock.new
         | 
| 143 144 | 
             
                  query_result = RapidApi::ModelAdapters::QueryResult.new()
         | 
| 144 145 | 
             
                  BricksController.adapted_model.expect :destroy, query_result, ["1", {color: 'blue'}]
         | 
| 145 | 
            -
                  post :destroy, {id: 1}
         | 
| 146 | 
            +
                  post :destroy, params: {id: 1}
         | 
| 146 147 | 
             
                  assert_response :no_content
         | 
| 147 148 | 
             
                  BricksController.adapted_model.verify
         | 
| 148 149 | 
             
                end
         | 
| @@ -151,7 +152,7 @@ module ActionController | |
| 151 152 | 
             
                  BricksController.adapted_model = Minitest::Mock.new
         | 
| 152 153 | 
             
                  query_result = RapidApi::ModelAdapters::QueryResult.new(errors: 'dummy error')
         | 
| 153 154 | 
             
                  BricksController.adapted_model.expect :destroy, query_result, ["1", {color: 'blue'}]
         | 
| 154 | 
            -
                  post :destroy, {id: 1}
         | 
| 155 | 
            +
                  post :destroy, params: {id: 1}
         | 
| 155 156 | 
             
                  assert_response :unprocessable_entity
         | 
| 156 157 | 
             
                  BricksController.adapted_model.verify
         | 
| 157 158 | 
             
                end
         | 
| @@ -19,7 +19,7 @@ module ActionController | |
| 19 19 | 
             
                tests TestScopesController
         | 
| 20 20 |  | 
| 21 21 | 
             
                def test_scope_by
         | 
| 22 | 
            -
                  get :scoped_bricks, { user_id: 1, org_id: 2 }
         | 
| 22 | 
            +
                  get :scoped_bricks, params: { user_id: 1, org_id: 2 }
         | 
| 23 23 | 
             
                  body = JSON.parse(@controller.response.body)
         | 
| 24 24 | 
             
                  assert_equal '1', body['user_id']
         | 
| 25 25 | 
             
                  assert_equal '2', body['org_id']
         | 
| @@ -3,6 +3,7 @@ require File.expand_path '../../../../../test_helper.rb', __FILE__ | |
| 3 3 | 
             
            class SessionsControllerTest < ActionController::TestCase
         | 
| 4 4 |  | 
| 5 5 | 
             
              class TestSessionsController < ActionController::Base
         | 
| 6 | 
            +
                include RapidApi::Auth::Concerns::AuthenticatedController
         | 
| 6 7 | 
             
                include RapidApi::Auth::Concerns::SessionsController
         | 
| 7 8 |  | 
| 8 9 | 
             
                authenticates_with :username, :password do |params|
         | 
| @@ -35,7 +36,7 @@ class SessionsControllerTest < ActionController::TestCase | |
| 35 36 |  | 
| 36 37 | 
             
              def test_authenticate
         | 
| 37 38 | 
             
                params = {'username' => 'bob_the_builder', 'password' => 'password'}
         | 
| 38 | 
            -
                post :authenticate, params
         | 
| 39 | 
            +
                post :authenticate, params: params
         | 
| 39 40 | 
             
                body = JSON.parse(@controller.response.body)
         | 
| 40 41 | 
             
                assert_response :ok
         | 
| 41 42 | 
             
                decoded_token = RapidApi::Auth::Support::JWT.decode(body["token"])
         | 
| @@ -46,7 +47,7 @@ class SessionsControllerTest < ActionController::TestCase | |
| 46 47 |  | 
| 47 48 | 
             
              def test_invalid_credentials
         | 
| 48 49 | 
             
                params = {'username' => 'bob_the_builder', 'password' => 'wrong_password'}
         | 
| 49 | 
            -
                post :authenticate, params
         | 
| 50 | 
            +
                post :authenticate, params: params
         | 
| 50 51 | 
             
                body = JSON.parse(@controller.response.body)
         | 
| 51 52 | 
             
                assert_response :unauthorized
         | 
| 52 53 | 
             
                assert_equal body["errors"].first, 'Invalid credentials'
         | 
| @@ -15,7 +15,7 @@ module RapidApi | |
| 15 15 | 
             
                  def test_serialize
         | 
| 16 16 | 
             
                    brick = Brick.create color: 'yellow', weight: 10, material: 'gold'
         | 
| 17 17 | 
             
                    serialized_brick = @adapter.serialize brick
         | 
| 18 | 
            -
                    assert_equal "{\"brick\":{\"color\":\"yellow\",\"weight\":\"10.0\",\"material\":\"gold\"}}", serialized_brick
         | 
| 18 | 
            +
                    assert_equal "{\"data\":{\"id\":\"#{brick.id}\",\"type\":\"bricks\",\"attributes\":{\"color\":\"yellow\",\"weight\":\"10.0\",\"material\":\"gold\"}}}", serialized_brick
         | 
| 19 19 | 
             
                  end
         | 
| 20 20 |  | 
| 21 21 | 
             
                  def test_serialize_collection
         | 
| @@ -23,7 +23,7 @@ module RapidApi | |
| 23 23 | 
             
                    brick1 = Brick.create color: 'yellow', weight: 10, material: 'gold'
         | 
| 24 24 | 
             
                    brick2 = Brick.create color: 'red',    weight: 1,  material: 'clay'
         | 
| 25 25 | 
             
                    serialized_brick_array = @adapter.serialize_collection Brick.all
         | 
| 26 | 
            -
                    assert_equal "{\" | 
| 26 | 
            +
                    assert_equal "{\"data\":[{\"id\":\"#{brick1.id}\",\"type\":\"bricks\",\"attributes\":{\"color\":\"yellow\",\"weight\":\"10.0\",\"material\":\"gold\"}},{\"id\":\"#{brick2.id}\",\"type\":\"bricks\",\"attributes\":{\"color\":\"red\",\"weight\":\"1.0\",\"material\":\"clay\"}}]}", serialized_brick_array
         | 
| 27 27 | 
             
                  end
         | 
| 28 28 |  | 
| 29 29 | 
             
                end
         | 
| @@ -6,7 +6,7 @@ class ConfigurationTest < Minitest::Test | |
| 6 6 | 
             
              RapidApi.config.model_adapter = DefaultModelAdapter
         | 
| 7 7 |  | 
| 8 8 | 
             
              class BricksController < ActionController::Base
         | 
| 9 | 
            -
                include RapidApi::ActionController:: | 
| 9 | 
            +
                include RapidApi::ActionController::ResourceActions
         | 
| 10 10 |  | 
| 11 11 | 
             
                permit_params :color
         | 
| 12 12 | 
             
              end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,29 +1,29 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: rapid_api
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0. | 
| 4 | 
            +
              version: 0.2.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - briandavidwetzel
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date:  | 
| 11 | 
            +
            date: 2016-07-15 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: actionpack
         | 
| 15 15 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 16 16 | 
             
                requirements:
         | 
| 17 | 
            -
                - - " | 
| 17 | 
            +
                - - "~>"
         | 
| 18 18 | 
             
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            -
                    version: ' | 
| 19 | 
            +
                    version: '5.0'
         | 
| 20 20 | 
             
              type: :runtime
         | 
| 21 21 | 
             
              prerelease: false
         | 
| 22 22 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 23 23 | 
             
                requirements:
         | 
| 24 | 
            -
                - - " | 
| 24 | 
            +
                - - "~>"
         | 
| 25 25 | 
             
                  - !ruby/object:Gem::Version
         | 
| 26 | 
            -
                    version: ' | 
| 26 | 
            +
                    version: '5.0'
         | 
| 27 27 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 28 28 | 
             
              name: jwt
         | 
| 29 29 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -56,16 +56,16 @@ dependencies: | |
| 56 56 | 
             
              name: rails
         | 
| 57 57 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 58 58 | 
             
                requirements:
         | 
| 59 | 
            -
                - - " | 
| 59 | 
            +
                - - "~>"
         | 
| 60 60 | 
             
                  - !ruby/object:Gem::Version
         | 
| 61 | 
            -
                    version: ' | 
| 61 | 
            +
                    version: '5.0'
         | 
| 62 62 | 
             
              type: :development
         | 
| 63 63 | 
             
              prerelease: false
         | 
| 64 64 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 65 65 | 
             
                requirements:
         | 
| 66 | 
            -
                - - " | 
| 66 | 
            +
                - - "~>"
         | 
| 67 67 | 
             
                  - !ruby/object:Gem::Version
         | 
| 68 | 
            -
                    version: ' | 
| 68 | 
            +
                    version: '5.0'
         | 
| 69 69 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 70 70 | 
             
              name: rake
         | 
| 71 71 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -86,14 +86,14 @@ dependencies: | |
| 86 86 | 
             
                requirements:
         | 
| 87 87 | 
             
                - - "~>"
         | 
| 88 88 | 
             
                  - !ruby/object:Gem::Version
         | 
| 89 | 
            -
                    version:  | 
| 89 | 
            +
                    version: 0.10.0
         | 
| 90 90 | 
             
              type: :development
         | 
| 91 91 | 
             
              prerelease: false
         | 
| 92 92 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 93 93 | 
             
                requirements:
         | 
| 94 94 | 
             
                - - "~>"
         | 
| 95 95 | 
             
                  - !ruby/object:Gem::Version
         | 
| 96 | 
            -
                    version:  | 
| 96 | 
            +
                    version: 0.10.0
         | 
| 97 97 | 
             
            description: 
         | 
| 98 98 | 
             
            email:
         | 
| 99 99 | 
             
            - briandavidwetzel@gmail.com
         | 
| @@ -108,7 +108,7 @@ files: | |
| 108 108 | 
             
            - lib/rapid_api/action_controller/filterable_params.rb
         | 
| 109 109 | 
             
            - lib/rapid_api/action_controller/macros.rb
         | 
| 110 110 | 
             
            - lib/rapid_api/action_controller/permitted_params.rb
         | 
| 111 | 
            -
            - lib/rapid_api/action_controller/ | 
| 111 | 
            +
            - lib/rapid_api/action_controller/resource_actions.rb
         | 
| 112 112 | 
             
            - lib/rapid_api/action_controller/scope.rb
         | 
| 113 113 | 
             
            - lib/rapid_api/auth.rb
         | 
| 114 114 | 
             
            - lib/rapid_api/auth/concerns.rb
         | 
| @@ -138,7 +138,7 @@ files: | |
| 138 138 | 
             
            - test/unit/rapid_api/action_controller/errors_test.rb
         | 
| 139 139 | 
             
            - test/unit/rapid_api/action_controller/filterable_params_test.rb
         | 
| 140 140 | 
             
            - test/unit/rapid_api/action_controller/permitted_params_test.rb
         | 
| 141 | 
            -
            - test/unit/rapid_api/action_controller/ | 
| 141 | 
            +
            - test/unit/rapid_api/action_controller/resource_actions_test.rb
         | 
| 142 142 | 
             
            - test/unit/rapid_api/action_controller/scope_test.rb
         | 
| 143 143 | 
             
            - test/unit/rapid_api/auth/concerns/authenticated_controller_test.rb
         | 
| 144 144 | 
             
            - test/unit/rapid_api/auth/concerns/sessions_controller_test.rb
         | 
| @@ -168,30 +168,30 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 168 168 | 
             
                  version: '0'
         | 
| 169 169 | 
             
            requirements: []
         | 
| 170 170 | 
             
            rubyforge_project: 
         | 
| 171 | 
            -
            rubygems_version: 2. | 
| 171 | 
            +
            rubygems_version: 2.6.6
         | 
| 172 172 | 
             
            signing_key: 
         | 
| 173 173 | 
             
            specification_version: 4
         | 
| 174 174 | 
             
            summary: A framework for rapid development of Rails APIs.
         | 
| 175 175 | 
             
            test_files:
         | 
| 176 | 
            -
            - test/ | 
| 176 | 
            +
            - test/support/test_serializer_adapter.rb
         | 
| 177 177 | 
             
            - test/support/code_climate.rb
         | 
| 178 178 | 
             
            - test/support/models.rb
         | 
| 179 | 
            -
            - test/support/schema.rb
         | 
| 180 | 
            -
            - test/support/serializers.rb
         | 
| 181 | 
            -
            - test/support/test_model_adapter.rb
         | 
| 182 179 | 
             
            - test/support/test_module/test_model_adapter.rb
         | 
| 183 | 
            -
            - test/support/ | 
| 180 | 
            +
            - test/support/test_model_adapter.rb
         | 
| 181 | 
            +
            - test/support/serializers.rb
         | 
| 182 | 
            +
            - test/support/schema.rb
         | 
| 183 | 
            +
            - test/integration/ams_ar_test.rb
         | 
| 184 184 | 
             
            - test/test_helper.rb
         | 
| 185 | 
            +
            - test/unit/rapid_api/test_configuration.rb
         | 
| 185 186 | 
             
            - test/unit/rapid_api/action_controller/errors_test.rb
         | 
| 186 187 | 
             
            - test/unit/rapid_api/action_controller/filterable_params_test.rb
         | 
| 187 | 
            -
            - test/unit/rapid_api/action_controller/ | 
| 188 | 
            -
            - test/unit/rapid_api/action_controller/rest_actions_test.rb
         | 
| 188 | 
            +
            - test/unit/rapid_api/action_controller/resource_actions_test.rb
         | 
| 189 189 | 
             
            - test/unit/rapid_api/action_controller/scope_test.rb
         | 
| 190 | 
            -
            - test/unit/rapid_api/ | 
| 190 | 
            +
            - test/unit/rapid_api/action_controller/permitted_params_test.rb
         | 
| 191 | 
            +
            - test/unit/rapid_api/serializer_adapters/ams_adapter_test.rb
         | 
| 192 | 
            +
            - test/unit/rapid_api/serializer_adapters/abstract_test.rb
         | 
| 191 193 | 
             
            - test/unit/rapid_api/auth/concerns/sessions_controller_test.rb
         | 
| 194 | 
            +
            - test/unit/rapid_api/auth/concerns/authenticated_controller_test.rb
         | 
| 192 195 | 
             
            - test/unit/rapid_api/auth/support/jwt_test.rb
         | 
| 193 196 | 
             
            - test/unit/rapid_api/model_adapters/abstract_test.rb
         | 
| 194 197 | 
             
            - test/unit/rapid_api/model_adapters/active_record_adapter_test.rb
         | 
| 195 | 
            -
            - test/unit/rapid_api/serializer_adapters/abstract_test.rb
         | 
| 196 | 
            -
            - test/unit/rapid_api/serializer_adapters/ams_adapter_test.rb
         | 
| 197 | 
            -
            - test/unit/rapid_api/test_configuration.rb
         |