introspective_grape 0.6.1 → 0.7.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.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +85 -84
  3. data/.ruby-version +1 -1
  4. data/CHANGELOG.md +10 -0
  5. data/Gemfile +38 -22
  6. data/README.md +13 -20
  7. data/introspective_grape.gemspec +41 -64
  8. data/lib/introspective_grape/api.rb +469 -461
  9. data/lib/introspective_grape/camel_snake.rb +3 -3
  10. data/lib/introspective_grape/create_helpers.rb +25 -25
  11. data/lib/introspective_grape/filters.rb +5 -3
  12. data/lib/introspective_grape/route.rb +11 -0
  13. data/lib/introspective_grape/traversal.rb +56 -56
  14. data/lib/introspective_grape/validators.rb +37 -36
  15. data/lib/introspective_grape/version.rb +5 -5
  16. data/lib/introspective_grape.rb +1 -0
  17. data/spec/dummy/Gemfile +24 -23
  18. data/spec/dummy/app/api/{api_helpers.rb → authentication_helper.rb} +38 -38
  19. data/spec/dummy/app/api/dummy/chat_api.rb +1 -1
  20. data/spec/dummy/app/api/dummy/company_api.rb +1 -1
  21. data/spec/dummy/app/api/dummy/location_api.rb +1 -1
  22. data/spec/dummy/app/api/dummy/project_api.rb +2 -2
  23. data/spec/dummy/app/api/dummy/role_api.rb +1 -1
  24. data/spec/dummy/app/api/dummy/sessions.rb +2 -2
  25. data/spec/dummy/app/api/dummy/user_api.rb +1 -1
  26. data/spec/dummy/app/api/dummy_api.rb +60 -61
  27. data/spec/dummy/app/api/error_handlers.rb +6 -6
  28. data/spec/dummy/app/api/permissions_helper.rb +7 -7
  29. data/spec/dummy/app/helpers/current.rb +3 -3
  30. data/spec/dummy/app/models/abstract_adapter.rb +11 -8
  31. data/spec/dummy/app/models/chat_message.rb +34 -34
  32. data/spec/dummy/app/models/chat_user.rb +16 -16
  33. data/spec/dummy/app/models/company.rb +3 -2
  34. data/spec/dummy/app/models/location.rb +26 -26
  35. data/spec/dummy/app/models/role.rb +30 -30
  36. data/spec/dummy/app/models/team.rb +14 -14
  37. data/spec/dummy/app/models/user/chatter.rb +79 -79
  38. data/spec/dummy/app/models/user.rb +2 -0
  39. data/spec/dummy/bin/bundle +3 -3
  40. data/spec/dummy/bin/rails +4 -4
  41. data/spec/dummy/bin/setup +36 -36
  42. data/spec/dummy/bin/update +31 -31
  43. data/spec/dummy/bin/yarn +11 -11
  44. data/spec/dummy/config/application.rb +30 -30
  45. data/spec/dummy/config/boot.rb +3 -3
  46. data/spec/dummy/config/environment.rb +5 -5
  47. data/spec/dummy/config/environments/development.rb +54 -54
  48. data/spec/dummy/config/environments/production.rb +81 -81
  49. data/spec/dummy/config/environments/test.rb +47 -47
  50. data/spec/dummy/config/initializers/application_controller_renderer.rb +8 -8
  51. data/spec/dummy/config/initializers/assets.rb +14 -14
  52. data/spec/dummy/config/initializers/content_security_policy.rb +25 -25
  53. data/spec/dummy/config/initializers/cookies_serializer.rb +5 -5
  54. data/spec/dummy/config/initializers/new_framework_defaults_5_2.rb +38 -38
  55. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -14
  56. data/spec/dummy/config/locales/en.yml +33 -33
  57. data/spec/dummy/config/routes.rb +1 -1
  58. data/spec/dummy/config/storage.yml +34 -34
  59. data/spec/models/image_spec.rb +10 -10
  60. data/spec/rails_helper.rb +1 -2
  61. data/spec/requests/chat_api_spec.rb +1 -1
  62. data/spec/requests/company_api_spec.rb +1 -1
  63. data/spec/requests/location_api_spec.rb +1 -1
  64. data/spec/requests/project_api_spec.rb +185 -185
  65. data/spec/requests/role_api_spec.rb +1 -1
  66. data/spec/requests/user_api_spec.rb +221 -221
  67. data/spec/support/request_helpers.rb +22 -22
  68. metadata +9 -192
  69. data/spec/dummy/.ruby-version +0 -1
  70. data/spec/dummy/config/initializers/inflections.rb +0 -16
@@ -1,38 +1,38 @@
1
- # Be sure to restart your server when you modify this file.
2
- #
3
- # This file contains migration options to ease your Rails 5.2 upgrade.
4
- #
5
- # Once upgraded flip defaults one by one to migrate to the new default.
6
- #
7
- # Read the Guide for Upgrading Ruby on Rails for more info on each option.
8
-
9
- # Make Active Record use stable #cache_key alongside new #cache_version method.
10
- # This is needed for recyclable cache keys.
11
- # Rails.application.config.active_record.cache_versioning = true
12
-
13
- # Use AES-256-GCM authenticated encryption for encrypted cookies.
14
- # Also, embed cookie expiry in signed or encrypted cookies for increased security.
15
- #
16
- # This option is not backwards compatible with earlier Rails versions.
17
- # It's best enabled when your entire app is migrated and stable on 5.2.
18
- #
19
- # Existing cookies will be converted on read then written with the new scheme.
20
- # Rails.application.config.action_dispatch.use_authenticated_cookie_encryption = true
21
-
22
- # Use AES-256-GCM authenticated encryption as default cipher for encrypting messages
23
- # instead of AES-256-CBC, when use_authenticated_message_encryption is set to true.
24
- # Rails.application.config.active_support.use_authenticated_message_encryption = true
25
-
26
- # Add default protection from forgery to ActionController::Base instead of in
27
- # ApplicationController.
28
- # Rails.application.config.action_controller.default_protect_from_forgery = true
29
-
30
- # Store boolean values are in sqlite3 databases as 1 and 0 instead of 't' and
31
- # 'f' after migrating old data.
32
- # Rails.application.config.active_record.sqlite3.represent_boolean_as_integer = true
33
-
34
- # Use SHA-1 instead of MD5 to generate non-sensitive digests, such as the ETag header.
35
- # Rails.application.config.active_support.use_sha1_digests = true
36
-
37
- # Make `form_with` generate id attributes for any generated HTML tags.
38
- # Rails.application.config.action_view.form_with_generates_ids = true
1
+ # Be sure to restart your server when you modify this file.
2
+ #
3
+ # This file contains migration options to ease your Rails 5.2 upgrade.
4
+ #
5
+ # Once upgraded flip defaults one by one to migrate to the new default.
6
+ #
7
+ # Read the Guide for Upgrading Ruby on Rails for more info on each option.
8
+
9
+ # Make Active Record use stable #cache_key alongside new #cache_version method.
10
+ # This is needed for recyclable cache keys.
11
+ # Rails.application.config.active_record.cache_versioning = true
12
+
13
+ # Use AES-256-GCM authenticated encryption for encrypted cookies.
14
+ # Also, embed cookie expiry in signed or encrypted cookies for increased security.
15
+ #
16
+ # This option is not backwards compatible with earlier Rails versions.
17
+ # It's best enabled when your entire app is migrated and stable on 5.2.
18
+ #
19
+ # Existing cookies will be converted on read then written with the new scheme.
20
+ # Rails.application.config.action_dispatch.use_authenticated_cookie_encryption = true
21
+
22
+ # Use AES-256-GCM authenticated encryption as default cipher for encrypting messages
23
+ # instead of AES-256-CBC, when use_authenticated_message_encryption is set to true.
24
+ # Rails.application.config.active_support.use_authenticated_message_encryption = true
25
+
26
+ # Add default protection from forgery to ActionController::Base instead of in
27
+ # ApplicationController.
28
+ # Rails.application.config.action_controller.default_protect_from_forgery = true
29
+
30
+ # Store boolean values are in sqlite3 databases as 1 and 0 instead of 't' and
31
+ # 'f' after migrating old data.
32
+ # Rails.application.config.active_record.sqlite3.represent_boolean_as_integer = true
33
+
34
+ # Use SHA-1 instead of MD5 to generate non-sensitive digests, such as the ETag header.
35
+ # Rails.application.config.active_support.use_sha1_digests = true
36
+
37
+ # Make `form_with` generate id attributes for any generated HTML tags.
38
+ # Rails.application.config.action_view.form_with_generates_ids = true
@@ -1,14 +1,14 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # This file contains settings for ActionController::ParamsWrapper which
4
- # is enabled by default.
5
-
6
- # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7
- ActiveSupport.on_load(:action_controller) do
8
- wrap_parameters format: [:json]
9
- end
10
-
11
- # To enable root element in JSON for ActiveRecord objects.
12
- # ActiveSupport.on_load(:active_record) do
13
- # self.include_root_in_json = true
14
- # end
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # This file contains settings for ActionController::ParamsWrapper which
4
+ # is enabled by default.
5
+
6
+ # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7
+ ActiveSupport.on_load(:action_controller) do
8
+ wrap_parameters format: [:json]
9
+ end
10
+
11
+ # To enable root element in JSON for ActiveRecord objects.
12
+ # ActiveSupport.on_load(:active_record) do
13
+ # self.include_root_in_json = true
14
+ # end
@@ -1,33 +1,33 @@
1
- # Files in the config/locales directory are used for internationalization
2
- # and are automatically loaded by Rails. If you want to use locales other
3
- # than English, add the necessary files in this directory.
4
- #
5
- # To use the locales, use `I18n.t`:
6
- #
7
- # I18n.t 'hello'
8
- #
9
- # In views, this is aliased to just `t`:
10
- #
11
- # <%= t('hello') %>
12
- #
13
- # To use a different locale, set it with `I18n.locale`:
14
- #
15
- # I18n.locale = :es
16
- #
17
- # This would use the information in config/locales/es.yml.
18
- #
19
- # The following keys must be escaped otherwise they will not be retrieved by
20
- # the default I18n backend:
21
- #
22
- # true, false, on, off, yes, no
23
- #
24
- # Instead, surround them with single quotes.
25
- #
26
- # en:
27
- # 'true': 'foo'
28
- #
29
- # To learn more, please read the Rails Internationalization guide
30
- # available at http://guides.rubyonrails.org/i18n.html.
31
-
32
- en:
33
- hello: "Hello world"
1
+ # Files in the config/locales directory are used for internationalization
2
+ # and are automatically loaded by Rails. If you want to use locales other
3
+ # than English, add the necessary files in this directory.
4
+ #
5
+ # To use the locales, use `I18n.t`:
6
+ #
7
+ # I18n.t 'hello'
8
+ #
9
+ # In views, this is aliased to just `t`:
10
+ #
11
+ # <%= t('hello') %>
12
+ #
13
+ # To use a different locale, set it with `I18n.locale`:
14
+ #
15
+ # I18n.locale = :es
16
+ #
17
+ # This would use the information in config/locales/es.yml.
18
+ #
19
+ # The following keys must be escaped otherwise they will not be retrieved by
20
+ # the default I18n backend:
21
+ #
22
+ # true, false, on, off, yes, no
23
+ #
24
+ # Instead, surround them with single quotes.
25
+ #
26
+ # en:
27
+ # 'true': 'foo'
28
+ #
29
+ # To learn more, please read the Rails Internationalization guide
30
+ # available at http://guides.rubyonrails.org/i18n.html.
31
+
32
+ en:
33
+ hello: "Hello world"
@@ -4,5 +4,5 @@ Rails.application.routes.draw do
4
4
  # You can have the root of your site routed with "root"
5
5
  root 'home#index'
6
6
 
7
- mount DummyAPI => '/api'
7
+ mount DummyApi => '/api'
8
8
  end
@@ -1,34 +1,34 @@
1
- test:
2
- service: Disk
3
- root: <%= Rails.root.join("tmp/storage") %>
4
-
5
- local:
6
- service: Disk
7
- root: <%= Rails.root.join("storage") %>
8
-
9
- # Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key)
10
- # amazon:
11
- # service: S3
12
- # access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
13
- # secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
14
- # region: us-east-1
15
- # bucket: your_own_bucket
16
-
17
- # Remember not to checkin your GCS keyfile to a repository
18
- # google:
19
- # service: GCS
20
- # project: your_project
21
- # credentials: <%= Rails.root.join("path/to/gcs.keyfile") %>
22
- # bucket: your_own_bucket
23
-
24
- # Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key)
25
- # microsoft:
26
- # service: AzureStorage
27
- # storage_account_name: your_account_name
28
- # storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %>
29
- # container: your_container_name
30
-
31
- # mirror:
32
- # service: Mirror
33
- # primary: local
34
- # mirrors: [ amazon, google, microsoft ]
1
+ test:
2
+ service: Disk
3
+ root: <%= Rails.root.join("tmp/storage") %>
4
+
5
+ local:
6
+ service: Disk
7
+ root: <%= Rails.root.join("storage") %>
8
+
9
+ # Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key)
10
+ # amazon:
11
+ # service: S3
12
+ # access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
13
+ # secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
14
+ # region: us-east-1
15
+ # bucket: your_own_bucket
16
+
17
+ # Remember not to checkin your GCS keyfile to a repository
18
+ # google:
19
+ # service: GCS
20
+ # project: your_project
21
+ # credentials: <%= Rails.root.join("path/to/gcs.keyfile") %>
22
+ # bucket: your_own_bucket
23
+
24
+ # Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key)
25
+ # microsoft:
26
+ # service: AzureStorage
27
+ # storage_account_name: your_account_name
28
+ # storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %>
29
+ # container: your_container_name
30
+
31
+ # mirror:
32
+ # service: Mirror
33
+ # primary: local
34
+ # mirrors: [ amazon, google, microsoft ]
@@ -1,10 +1,10 @@
1
- require 'rails_helper'
2
- require 'paperclip/matchers'
3
-
4
- RSpec.describe Image, type: :model do
5
- include Paperclip::Shoulda::Matchers
6
-
7
- it { should have_attached_file(:file) }
8
- it { should validate_attachment_content_type(:file).allowing('image/png', 'image/gif', 'image/jpeg') }
9
- it { should validate_attachment_size(:file).less_than(2.megabytes) }
10
- end
1
+ require 'rails_helper'
2
+ require 'paperclip/matchers'
3
+
4
+ RSpec.describe Image, type: :model do
5
+ include Paperclip::Shoulda::Matchers
6
+
7
+ it { should have_attached_file(:file) }
8
+ it { should validate_attachment_content_type(:file).allowing('image/png', 'image/gif', 'image/jpeg') }
9
+ it { should validate_attachment_size(:file).less_than(2.megabytes) }
10
+ end
data/spec/rails_helper.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  require 'coveralls'
2
- Coveralls.wear!('rails')
3
2
  ENV["RAILS_ENV"] = 'test'
4
3
  require File.expand_path("../dummy/config/environment", __FILE__)
5
4
  require 'rspec/rails'
@@ -8,7 +7,7 @@ require 'support/request_helpers'
8
7
  require 'support/pundit_helpers'
9
8
  Dir[Rails.root.join("../support/**/*.rb")].each { |f| require f }
10
9
 
11
- #load "#{Rails.root}/db/schema.rb"
10
+ load "#{Rails.root}/db/schema.rb"
12
11
  RSpec.configure do |config|
13
12
  config.include Devise::TestHelpers, type: :controller
14
13
  config.use_transactional_fixtures = true
@@ -1,5 +1,5 @@
1
1
  require "rails_helper"
2
- describe Dummy::ChatAPI, type: :request do
2
+ describe Dummy::ChatApi, type: :request do
3
3
 
4
4
  before :all do
5
5
  User.destroy_all
@@ -1,6 +1,6 @@
1
1
  require 'rails_helper'
2
2
 
3
- describe Dummy::CompanyAPI, type: :request do
3
+ describe Dummy::CompanyApi, type: :request do
4
4
  context :default_values do
5
5
  it "should respect default values" do
6
6
  get '/api/v1/companies/special/list'
@@ -1,6 +1,6 @@
1
1
  require 'rails_helper'
2
2
 
3
- describe Dummy::LocationAPI, type: :request do
3
+ describe Dummy::LocationApi, type: :request do
4
4
  include LocationHelper
5
5
 
6
6
  let(:location) { Location.find_by_name("TEST") }