rapid_api 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +120 -0
  3. data/lib/rapid_api/action_controller/errors.rb +75 -0
  4. data/lib/rapid_api/action_controller/filterable_params.rb +29 -0
  5. data/lib/rapid_api/action_controller/macros.rb +28 -0
  6. data/lib/rapid_api/action_controller/permitted_params.rb +38 -0
  7. data/lib/rapid_api/action_controller/rest_actions.rb +158 -0
  8. data/lib/rapid_api/action_controller/scope.rb +44 -0
  9. data/lib/rapid_api/action_controller.rb +11 -0
  10. data/lib/rapid_api/auth/concerns/authenticated_controller.rb +54 -0
  11. data/lib/rapid_api/auth/concerns/jwt_helpers.rb +33 -0
  12. data/lib/rapid_api/auth/concerns/sessions_controller.rb +49 -0
  13. data/lib/rapid_api/auth/concerns.rb +11 -0
  14. data/lib/rapid_api/auth/support/jwt.rb +28 -0
  15. data/lib/rapid_api/auth/support.rb +9 -0
  16. data/lib/rapid_api/auth.rb +8 -0
  17. data/lib/rapid_api/configuration.rb +11 -0
  18. data/lib/rapid_api/model_adapters/abstract.rb +33 -0
  19. data/lib/rapid_api/model_adapters/active_record_adapter.rb +49 -0
  20. data/lib/rapid_api/model_adapters/query_result.rb +22 -0
  21. data/lib/rapid_api/model_adapters.rb +9 -0
  22. data/lib/rapid_api/serializer_adapters/abstract.rb +22 -0
  23. data/lib/rapid_api/serializer_adapters/ams_adapter.rb +20 -0
  24. data/lib/rapid_api/serializer_adapters.rb +8 -0
  25. data/lib/rapid_api/version.rb +3 -0
  26. data/lib/rapid_api.rb +36 -0
  27. data/test/integration/ams_ar_test.rb +44 -0
  28. data/test/support/code_climate.rb +2 -0
  29. data/test/support/models.rb +24 -0
  30. data/test/support/schema.rb +14 -0
  31. data/test/support/serializers.rb +7 -0
  32. data/test/support/test_model_adapter.rb +23 -0
  33. data/test/support/test_module/test_model_adapter.rb +25 -0
  34. data/test/support/test_serializer_adapter.rb +10 -0
  35. data/test/test_helper.rb +28 -0
  36. data/test/unit/rapid_api/action_controller/errors_test.rb +53 -0
  37. data/test/unit/rapid_api/action_controller/filterable_params_test.rb +32 -0
  38. data/test/unit/rapid_api/action_controller/permitted_params_test.rb +30 -0
  39. data/test/unit/rapid_api/action_controller/rest_actions_test.rb +160 -0
  40. data/test/unit/rapid_api/action_controller/scope_test.rb +29 -0
  41. data/test/unit/rapid_api/auth/concerns/authenticated_controller_test.rb +56 -0
  42. data/test/unit/rapid_api/auth/concerns/sessions_controller_test.rb +55 -0
  43. data/test/unit/rapid_api/auth/support/jwt_test.rb +28 -0
  44. data/test/unit/rapid_api/model_adapters/abstract_test.rb +45 -0
  45. data/test/unit/rapid_api/model_adapters/active_record_adapter_test.rb +121 -0
  46. data/test/unit/rapid_api/serializer_adapters/abstract_test.rb +27 -0
  47. data/test/unit/rapid_api/serializer_adapters/ams_adapter_test.rb +31 -0
  48. data/test/unit/rapid_api/test_configuration.rb +17 -0
  49. metadata +197 -0
@@ -0,0 +1,160 @@
1
+ require File.expand_path '../../../../test_helper.rb', __FILE__
2
+
3
+ module ActionController
4
+
5
+ class RestActionsTest < ActionController::TestCase
6
+
7
+ class BricksController < ActionController::Base
8
+ include RapidApi::ActionController::RestActions
9
+
10
+ self.model_adapter = TestModelAdapter
11
+ self.serializer_adapter = TestSerializerAdapter
12
+
13
+ permit_params :color, :weight, :material
14
+ filterable_params :color
15
+
16
+ scope_by :color do |controller|
17
+ 'blue'
18
+ end
19
+ end
20
+
21
+ Foo = Class.new(Brick)
22
+
23
+ tests BricksController
24
+
25
+ def test_model_class_name
26
+ assert_equal BricksController.model_class_name, "Brick"
27
+ end
28
+
29
+ def test_model
30
+ assert_equal Brick, BricksController.model
31
+ BricksController.model = Foo
32
+ assert_equal Foo, BricksController.model
33
+ end
34
+
35
+ def test_params_key
36
+ BricksController.model = Brick
37
+ assert_equal 'brick', BricksController.params_key
38
+ BricksController.params_key = 'foo'
39
+ assert_equal 'foo', BricksController.params_key
40
+ BricksController.params_key = 'brick'
41
+ end
42
+
43
+ def test_model_adapter
44
+ assert_equal TestModelAdapter, BricksController.model_adapter
45
+ end
46
+
47
+ def test_adapted_serializer
48
+ BricksController.serializer_adapter = TestSerializerAdapter
49
+ assert_equal TestSerializerAdapter, BricksController.serializer_adapter
50
+ end
51
+
52
+ def test_index
53
+ BricksController.adapted_model = Minitest::Mock.new
54
+ query_result = RapidApi::ModelAdapters::QueryResult.new(data: 'data')
55
+ BricksController.adapted_model.expect :find_all, query_result, [{'color' => 'green'}, {color: 'blue'}]
56
+ BricksController.adapted_serializer = Minitest::Mock.new
57
+ BricksController.adapted_serializer.expect :serialize_collection, nil, ['data']
58
+ get :index, {color: 'green', material: 'leaves'}
59
+ assert_response :ok
60
+ BricksController.adapted_model.verify
61
+ BricksController.adapted_serializer.verify
62
+ end
63
+
64
+ def test_show
65
+ BricksController.adapted_model = Minitest::Mock.new
66
+ query_result = RapidApi::ModelAdapters::QueryResult.new(data: 'data')
67
+ BricksController.adapted_model.expect :find, query_result, ["1", {color: 'blue'}]
68
+ BricksController.adapted_serializer = Minitest::Mock.new
69
+ BricksController.adapted_serializer.expect :serialize, nil, ['data']
70
+ get :show, {id: 1}
71
+ assert_response :ok
72
+ BricksController.adapted_model.verify
73
+ BricksController.adapted_serializer.verify
74
+ end
75
+
76
+ def test_show_not_found
77
+ BricksController.adapted_model = Minitest::Mock.new
78
+ query_result = RapidApi::ModelAdapters::QueryResult.new()
79
+ BricksController.adapted_model.expect :find, query_result, ["1", {color: 'blue'}]
80
+ get :show, {id: 1}
81
+ assert_response :not_found
82
+ BricksController.adapted_model.verify
83
+ end
84
+
85
+ def test_create
86
+ params = {'color' => 'red', 'weight' => '10', 'material' => 'clay'}
87
+ BricksController.adapted_model = Minitest::Mock.new
88
+ query_result = RapidApi::ModelAdapters::QueryResult.new(data: 'data')
89
+ BricksController.adapted_model.expect :create, query_result, [params, {color: 'blue'}]
90
+ BricksController.adapted_serializer = Minitest::Mock.new
91
+ BricksController.adapted_serializer.expect :serialize, nil, ['data']
92
+ post :create, {brick: params}
93
+ assert_response :created
94
+ BricksController.adapted_model.verify
95
+ BricksController.adapted_serializer.verify
96
+ end
97
+
98
+ def test_create_errors
99
+ params = {'color' => 'red', 'weight' => '10', 'material' => 'clay'}
100
+ BricksController.adapted_model = Minitest::Mock.new
101
+ query_result = RapidApi::ModelAdapters::QueryResult.new(data: 'data', errors: 'dummy error')
102
+ BricksController.adapted_model.expect :create, query_result, [params, {color: 'blue'}]
103
+ post :create, {brick: params}
104
+ assert_response :unprocessable_entity
105
+ assert_equal 'dummy error', JSON.parse(@controller.response.body)['errors']
106
+ end
107
+
108
+ def test_update
109
+ params = {'color' => 'red', 'weight' => '10', 'material' => 'clay'}
110
+ BricksController.adapted_model = Minitest::Mock.new
111
+ query_result = RapidApi::ModelAdapters::QueryResult.new(data: 'data')
112
+ BricksController.adapted_model.expect :update, query_result, ["1", params, {color: 'blue'}]
113
+ BricksController.adapted_serializer = Minitest::Mock.new
114
+ BricksController.adapted_serializer.expect :serialize, nil, ['data']
115
+ post :update, {brick: params, id: 1}
116
+ assert_response :ok
117
+ BricksController.adapted_model.verify
118
+ BricksController.adapted_serializer.verify
119
+ end
120
+
121
+ def test_update_not_found
122
+ params = {'color' => 'red', 'weight' => '10', 'material' => 'clay'}
123
+ BricksController.adapted_model = Minitest::Mock.new
124
+ query_result = RapidApi::ModelAdapters::QueryResult.new()
125
+ BricksController.adapted_model.expect :update, query_result, ["1", params, {color: 'blue'}]
126
+ post :update, {brick: params, id: 1}
127
+ assert_response :not_found
128
+ BricksController.adapted_model.verify
129
+ end
130
+
131
+ def test_update_errors
132
+ params = {'color' => 'red', 'weight' => '10', 'material' => 'clay'}
133
+ BricksController.adapted_model = Minitest::Mock.new
134
+ query_result = RapidApi::ModelAdapters::QueryResult.new(data: 'data', errors: 'dummy error')
135
+ BricksController.adapted_model.expect :update, query_result, ["1", params, {color: 'blue'}]
136
+ post :update, {brick: params, id: 1}
137
+ assert_response :unprocessable_entity
138
+ BricksController.adapted_model.verify
139
+ end
140
+
141
+ def test_destroy
142
+ BricksController.adapted_model = Minitest::Mock.new
143
+ query_result = RapidApi::ModelAdapters::QueryResult.new()
144
+ BricksController.adapted_model.expect :destroy, query_result, ["1", {color: 'blue'}]
145
+ post :destroy, {id: 1}
146
+ assert_response :no_content
147
+ BricksController.adapted_model.verify
148
+ end
149
+
150
+ def test_destroy_errors
151
+ BricksController.adapted_model = Minitest::Mock.new
152
+ query_result = RapidApi::ModelAdapters::QueryResult.new(errors: 'dummy error')
153
+ BricksController.adapted_model.expect :destroy, query_result, ["1", {color: 'blue'}]
154
+ post :destroy, {id: 1}
155
+ assert_response :unprocessable_entity
156
+ BricksController.adapted_model.verify
157
+ end
158
+ end
159
+
160
+ end
@@ -0,0 +1,29 @@
1
+ require File.expand_path '../../../../test_helper.rb', __FILE__
2
+
3
+ module ActionController
4
+
5
+ class ScopeTest < ActionController::TestCase
6
+
7
+ class TestScopesController < ActionController::Base
8
+ include RapidApi::ActionController::Scope
9
+
10
+ scope_by :user_id, :org_id do |controller|
11
+ [controller.params['user_id'], controller.params['org_id']]
12
+ end
13
+
14
+ def scoped_bricks
15
+ render json: scope.to_json, status: :ok
16
+ end
17
+ end
18
+
19
+ tests TestScopesController
20
+
21
+ def test_scope_by
22
+ get :scoped_bricks, { user_id: 1, org_id: 2 }
23
+ body = JSON.parse(@controller.response.body)
24
+ assert_equal '1', body['user_id']
25
+ assert_equal '2', body['org_id']
26
+ end
27
+ end
28
+
29
+ end
@@ -0,0 +1,56 @@
1
+ require File.expand_path '../../../../../test_helper.rb', __FILE__
2
+
3
+ class AuthenticatedControllerTest < ActionController::TestCase
4
+
5
+ class TestAuthenticatedController < ActionController::Base
6
+ include RapidApi::ActionController::Errors
7
+ include RapidApi::Auth::Concerns::AuthenticatedController
8
+
9
+ rapid_actions model: Brick, serializer: BrickSerializer
10
+
11
+ permit_params :color, :weight, :material
12
+
13
+ authenticate do |controller|
14
+ token = controller.decode_jwt_token!(controller.request.headers.env['Authorization'])
15
+ user_id = token[0].try :[], 'user_id'
16
+ if user_id.present?
17
+ User.find user_id
18
+ else
19
+ nil
20
+ end
21
+ end
22
+ end
23
+
24
+ TestChildAuthenticatedController = Class.new TestAuthenticatedController
25
+
26
+ tests TestAuthenticatedController
27
+
28
+ def setup
29
+ super
30
+ DatabaseCleaner.start
31
+ end
32
+
33
+ def teardown
34
+ DatabaseCleaner.clean
35
+ end
36
+
37
+ def test_authenticated
38
+ @user = User.create
39
+ token = RapidApi::Auth::Support::JWT.encode({ user_id: @user.id })
40
+ @request.env['Authorization'] = token
41
+ get :index
42
+ assert_response :ok
43
+ assert_equal @controller.authenticated.id, @user.id
44
+ end
45
+
46
+ def test_not_authenticated_without_user
47
+ User.delete_all
48
+ get :index
49
+ assert_response :unauthorized
50
+ end
51
+
52
+ def test_child_controller
53
+ assert_equal TestAuthenticatedController.authenticate_proc, TestChildAuthenticatedController.authenticate_proc
54
+ end
55
+
56
+ end
@@ -0,0 +1,55 @@
1
+ require File.expand_path '../../../../../test_helper.rb', __FILE__
2
+
3
+ class SessionsControllerTest < ActionController::TestCase
4
+
5
+ class TestSessionsController < ActionController::Base
6
+ include RapidApi::Auth::Concerns::SessionsController
7
+
8
+ authenticates_with :username, :password do |params|
9
+ User.where(username: params[:username], password: params[:password]).first
10
+ end
11
+
12
+ responds_with do |authenticated|
13
+ {
14
+ token: jwt_encode({ secret: 'foo' }),
15
+ user: {
16
+ id: authenticated.id,
17
+ username: authenticated.username
18
+ }
19
+ }
20
+ end
21
+ end
22
+
23
+ tests TestSessionsController
24
+
25
+ def setup
26
+ super
27
+ DatabaseCleaner.start
28
+
29
+ @user = User.create username: 'bob_the_builder', password: 'password'
30
+ end
31
+
32
+ def teardown
33
+ DatabaseCleaner.clean
34
+ end
35
+
36
+ def test_authenticate
37
+ params = {'username' => 'bob_the_builder', 'password' => 'password'}
38
+ post :authenticate, params
39
+ body = JSON.parse(@controller.response.body)
40
+ assert_response :ok
41
+ decoded_token = RapidApi::Auth::Support::JWT.decode(body["token"])
42
+ assert_equal decoded_token[0]['secret'], 'foo'
43
+ assert_equal body["user"]["id"], @user.id
44
+ assert_equal body["user"]["username"], @user.username
45
+ end
46
+
47
+ def test_invalid_credentials
48
+ params = {'username' => 'bob_the_builder', 'password' => 'wrong_password'}
49
+ post :authenticate, params
50
+ body = JSON.parse(@controller.response.body)
51
+ assert_response :unauthorized
52
+ assert_equal body["errors"].first, 'Invalid credentials'
53
+ end
54
+
55
+ end
@@ -0,0 +1,28 @@
1
+ require File.expand_path '../../../../../test_helper.rb', __FILE__
2
+
3
+ class JwtTest < Minitest::Test
4
+
5
+ def setup
6
+ super
7
+ @subject = RapidApi::Auth::Support::JWT
8
+ end
9
+
10
+ def teardown
11
+ super
12
+ end
13
+
14
+ def test_encode
15
+ payload = { user_id: 1 }
16
+ refute_equal @subject.encode(payload), nil
17
+ end
18
+
19
+ def test_decode
20
+ payload = { user_id: 1, secret: 'secret' }
21
+ token = @subject.encode(payload)
22
+
23
+ decoded_token = @subject.decode(token)
24
+ assert_equal decoded_token[0]['secret'], 'secret'
25
+ assert_equal decoded_token[1]['alg'], 'none'
26
+ end
27
+
28
+ end
@@ -0,0 +1,45 @@
1
+ require File.expand_path '../../../../test_helper.rb', __FILE__
2
+
3
+ module RapidApi
4
+ module ModelAdapters
5
+ class AbstractModelAdapterTest < Minitest::Test
6
+ def setup
7
+ @adapter = RapidApi::ModelAdapters::Abstract.new(nil)
8
+ end
9
+
10
+ def teardown
11
+
12
+ end
13
+
14
+ def test_find
15
+ assert_raises NotImplementedError do
16
+ @adapter.find(nil, nil)
17
+ end
18
+ end
19
+
20
+ def test_find_all
21
+ assert_raises NotImplementedError do
22
+ @adapter.find_all(nil, nil)
23
+ end
24
+ end
25
+
26
+ def test_create
27
+ assert_raises NotImplementedError do
28
+ @adapter.create(nil, nil)
29
+ end
30
+ end
31
+
32
+ def test_update
33
+ assert_raises NotImplementedError do
34
+ @adapter.update(nil, nil)
35
+ end
36
+ end
37
+
38
+ def test_destroy
39
+ assert_raises NotImplementedError do
40
+ @adapter.destroy(nil, nil)
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,121 @@
1
+ require File.expand_path '../../../../test_helper.rb', __FILE__
2
+
3
+ module RapidApi
4
+ module ModelAdapters
5
+ class ActiveRecordAdapterTest < Minitest::Test
6
+
7
+ def setup
8
+ DatabaseCleaner.start
9
+ @adapter = RapidApi::ModelAdapters::ActiveRecordAdapter.new(Brick)
10
+ end
11
+
12
+ def teardown
13
+ DatabaseCleaner.clean
14
+ end
15
+
16
+ def test_adapted_klass
17
+ assert_equal Brick, @adapter.klass
18
+ end
19
+
20
+ def test_find
21
+ brick = Brick.create color: 'red1'
22
+ query_result = @adapter.find(brick.id)
23
+ assert_equal brick, query_result.data
24
+ end
25
+
26
+ def test_find_all
27
+ Brick.delete_all
28
+ brick1 = Brick.create color: 'blue'
29
+ brick2 = Brick.create color: 'green'
30
+ query_result = @adapter.find_all
31
+ assert_equal [brick1.id, brick2.id], query_result.data.map(&:id)
32
+ end
33
+
34
+ def test_create
35
+ params = {color: 'red2', weight: 1, material: 'clay'}
36
+ query_result = @adapter.create params
37
+ assert_equal 'red2', query_result.data.color
38
+ assert_equal 1, query_result.data.weight
39
+ assert_equal 'clay', query_result.data.material
40
+ refute_equal nil, query_result.data.id
41
+ end
42
+
43
+ def test_create_errors
44
+ params = {color: 'red3', weight: 1, material: 'clay'}
45
+ @adapter.create params
46
+ query_result = @adapter.create params
47
+ assert_equal true, query_result.has_errors?
48
+ end
49
+
50
+ def test_update
51
+ params = {color: 'red4', weight: 1, material: 'clay'}
52
+ update_params = {color: 'yellow1', weight: 10, material: 'gold'}
53
+ brick = Brick.create params
54
+ query_result = @adapter.update(brick.id, update_params)
55
+ assert_equal 'yellow1', query_result.data.color
56
+ assert_equal 10, query_result.data.weight
57
+ assert_equal 'gold', query_result.data.material
58
+ assert_equal brick.id, query_result.data.id
59
+ end
60
+
61
+ def test_update_errors
62
+ params = {color: 'red5', weight: 1, material: 'clay'}
63
+ update_params = {color: 'yellow2', weight: 10, material: 'gold'}
64
+ brick = Brick.create params
65
+ Brick.create update_params
66
+ query_result = @adapter.update(brick.id, update_params)
67
+ assert_equal true, query_result.has_errors?
68
+ end
69
+
70
+ def test_destroy
71
+ params = {color: 'red6', weight: 1, material: 'clay'}
72
+ brick = Brick.create params
73
+ @adapter.destroy brick.id
74
+ assert Brick.where(id: brick.id).empty?
75
+ end
76
+
77
+ def test_destroy_errors
78
+ params = {color: 'prevent_destroy', weight: 1, material: 'clay'}
79
+ brick = Brick.create params
80
+ query_result = @adapter.destroy brick.id
81
+ assert_equal true, query_result.has_errors?
82
+ end
83
+
84
+ def test_find_with_scope
85
+ brick = Brick.create color: 'magenta'
86
+ query_result = @adapter.find(brick.id, {color: 'orange'})
87
+ assert_equal nil, query_result.data
88
+ query_result = @adapter.find(brick.id, {color: 'magenta'})
89
+ assert_equal brick, query_result.data
90
+ end
91
+
92
+ def test_find_all_with_scope
93
+ Brick.delete_all
94
+ brick1 = Brick.create color: 'blue'
95
+ brick2 = Brick.create color: 'green'
96
+ params = {color: 'green'}
97
+ scope = {color: 'blue'}
98
+ query_result = @adapter.find_all params, scope
99
+ assert_equal [brick1.id], query_result.data.map(&:id)
100
+ end
101
+
102
+ def test_create_with_scope
103
+ params = {color: 'lavender', weight: 1, material: 'clay'}
104
+ query_result = @adapter.create params, {weight: 2, material: 'flowers'}
105
+ assert_equal 'lavender', query_result.data.color
106
+ assert_equal 2, query_result.data.weight
107
+ assert_equal 'flowers', query_result.data.material
108
+ refute_equal nil, query_result.data.id
109
+ end
110
+
111
+ def test_find_all_with_params
112
+ Brick.delete_all
113
+ brick1 = Brick.create color: 'blue'
114
+ brick2 = Brick.create color: 'green'
115
+ params = {color: 'green'}
116
+ query_result = @adapter.find_all params
117
+ assert_equal [brick2.id], query_result.data.map(&:id)
118
+ end
119
+ end
120
+ end
121
+ end
@@ -0,0 +1,27 @@
1
+ require File.expand_path '../../../../test_helper.rb', __FILE__
2
+
3
+ module RapidApi
4
+ module SerializerAdapters
5
+ class AbstractAdapterTest < Minitest::Test
6
+ def setup
7
+ @adapter = RapidApi::SerializerAdapters::Abstract.new(nil, nil)
8
+ end
9
+
10
+ def teardown
11
+
12
+ end
13
+
14
+ def test_serialize
15
+ assert_raises NotImplementedError do
16
+ @adapter.serialize(nil)
17
+ end
18
+ end
19
+
20
+ def test_serialize_collection
21
+ assert_raises NotImplementedError do
22
+ @adapter.serialize_collection(nil)
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,31 @@
1
+ require File.expand_path '../../../../test_helper.rb', __FILE__
2
+
3
+ module RapidApi
4
+ module SerializerAdapters
5
+ class AmsAdapterTest < Minitest::Test
6
+
7
+ def setup
8
+ @adapter = RapidApi::SerializerAdapters::AmsAdapter.new(BrickSerializer, "brick")
9
+ end
10
+
11
+ def test_klass
12
+ assert_equal BrickSerializer, @adapter.klass
13
+ end
14
+
15
+ def test_serialize
16
+ brick = Brick.create color: 'yellow', weight: 10, material: 'gold'
17
+ serialized_brick = @adapter.serialize brick
18
+ assert_equal "{\"brick\":{\"color\":\"yellow\",\"weight\":\"10.0\",\"material\":\"gold\"}}", serialized_brick
19
+ end
20
+
21
+ def test_serialize_collection
22
+ Brick.destroy_all
23
+ brick1 = Brick.create color: 'yellow', weight: 10, material: 'gold'
24
+ brick2 = Brick.create color: 'red', weight: 1, material: 'clay'
25
+ serialized_brick_array = @adapter.serialize_collection Brick.all
26
+ assert_equal "{\"bricks\":[{\"color\":\"yellow\",\"weight\":\"10.0\",\"material\":\"gold\"},{\"color\":\"red\",\"weight\":\"1.0\",\"material\":\"clay\"}]}", serialized_brick_array
27
+ end
28
+
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,17 @@
1
+ require File.expand_path '../../test_helper.rb', __FILE__
2
+
3
+ class ConfigurationTest < Minitest::Test
4
+
5
+ DefaultModelAdapter = Class.new(RapidApi::ModelAdapters::Abstract)
6
+ RapidApi.config.model_adapter = DefaultModelAdapter
7
+
8
+ class BricksController < ActionController::Base
9
+ include RapidApi::ActionController::RestActions
10
+
11
+ permit_params :color
12
+ end
13
+
14
+ def test_default_model_adapter
15
+ assert_equal DefaultModelAdapter, BricksController.model_adapter
16
+ end
17
+ end