apress-api 1.22.0 → 1.24.2

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 (86) hide show
  1. checksums.yaml +4 -4
  2. data/.drone.yml +72 -30
  3. data/Appraisals +9 -13
  4. data/CHANGELOG.md +24 -0
  5. data/Gemfile +1 -0
  6. data/README.md +2 -0
  7. data/Rakefile +1 -0
  8. data/app/controllers/apress/api/deprecated_versions_controller.rb +1 -0
  9. data/app/controllers/apress/api/v1/callbacks_controller.rb +1 -0
  10. data/app/controllers/apress/api/v1/tokens_controller.rb +1 -0
  11. data/app/docs/schema/api/v1/types/apress/api/link.rb +1 -0
  12. data/app/docs/schema/api/v1/types/apress/api/links.rb +1 -0
  13. data/app/docs/swagger/v1/controllers/apress/api/tokens_controller.rb +1 -0
  14. data/app/docs/swagger/v1/default_responses/bad_request.rb +1 -0
  15. data/app/docs/swagger/v1/default_responses/not_found.rb +1 -0
  16. data/app/docs/swagger/v1/default_responses/unauthenticated.rb +1 -0
  17. data/app/docs/swagger/v1/default_responses/unauthorized.rb +1 -0
  18. data/app/docs/swagger/v1/default_responses/unprocessable.rb +1 -0
  19. data/app/docs/swagger/v1/default_responses/updates_locked.rb +1 -0
  20. data/app/docs/swagger/v1/models/apress/api/client.rb +1 -0
  21. data/app/docs/swagger/v1/models/apress/api/simple_error.rb +1 -0
  22. data/app/docs/swagger/v1/models/apress/api/unproccesable_error.rb +1 -0
  23. data/app/docs/swagger/v1/models/apress/api/unprocessable_error.rb +1 -0
  24. data/app/docs/swagger/v1/root.rb +8 -6
  25. data/app/interactors/apress/api/callbacks/base_callback.rb +1 -0
  26. data/app/interactors/apress/api/delayed_fire_callback.rb +1 -0
  27. data/app/jobs/apress/api/event_handler_enqueueing_job.rb +1 -0
  28. data/app/jobs/apress/api/fire_callback_job.rb +1 -0
  29. data/app/models/apress/api/client.rb +1 -0
  30. data/app/policies/apress/api/callback_policy.rb +1 -0
  31. data/app/services/apress/api/auth_service.rb +1 -0
  32. data/app/views/apress/api/shared/_exception.json.jbuilder +1 -0
  33. data/app/views/apress/api/shared/error.json.jbuilder +1 -0
  34. data/app/views/apress/api/shared/parameter_missing_errors.json.jbuilder +1 -0
  35. data/app/views/apress/api/shared/unprocessable_errors.json.jbuilder +1 -0
  36. data/app/views/apress/api/v1/clients/_client.json.jbuilder +1 -0
  37. data/app/views/apress/api/v1/tokens/create.json.jbuilder +1 -0
  38. data/apress-api.gemspec +2 -0
  39. data/config/routes.rb +1 -0
  40. data/db/migrate/20150716000000_create_api_clients.rb +1 -0
  41. data/dip.yml +4 -3
  42. data/lib/apress-api.rb +1 -0
  43. data/lib/apress/api.rb +1 -0
  44. data/lib/apress/api/api_controller/authentification.rb +2 -1
  45. data/lib/apress/api/api_controller/base.rb +1 -0
  46. data/lib/apress/api/api_controller/compatibility.rb +1 -0
  47. data/lib/apress/api/api_controller/pagination.rb +1 -0
  48. data/lib/apress/api/api_controller/pagination_helper.rb +1 -0
  49. data/lib/apress/api/api_controller/rescue.rb +5 -0
  50. data/lib/apress/api/api_controller/responds.rb +1 -0
  51. data/lib/apress/api/callbacks/config.rb +1 -0
  52. data/lib/apress/api/callbacks/fire_callback_error.rb +1 -0
  53. data/lib/apress/api/callbacks/integration.rb +1 -0
  54. data/lib/apress/api/callbacks/repeat_callback_error.rb +1 -0
  55. data/lib/apress/api/engine.rb +13 -6
  56. data/lib/apress/api/extensions/jbuilder/jbuilder_template.rb +1 -0
  57. data/lib/apress/api/rspec.rb +1 -0
  58. data/lib/apress/api/rspec/utils.rb +1 -0
  59. data/lib/apress/api/testing/json_matcher.rb +1 -0
  60. data/lib/apress/api/version.rb +2 -1
  61. data/lib/tasks/docs.rake +1 -0
  62. data/spec/controllers/api_controller/authentification_spec.rb +3 -2
  63. data/spec/controllers/api_controller/pagination_spec.rb +1 -0
  64. data/spec/controllers/api_controller/rescue_spec.rb +1 -0
  65. data/spec/controllers/deprecated_versions_controller_spec.rb +1 -0
  66. data/spec/controllers/v1/callbacks_controller_spec.rb +1 -0
  67. data/spec/controllers/v1/tokens_controller_spec.rb +1 -0
  68. data/spec/factories/client_factory.rb +1 -0
  69. data/spec/helpers/paginating_cache_spec.rb +2 -1
  70. data/spec/interactors/apress/api/delayed_fire_callback_spec.rb +1 -0
  71. data/spec/internal/app/integrations/error_client/fire_callback.rb +1 -0
  72. data/spec/internal/app/integrations/service_client/fire_callback.rb +1 -0
  73. data/spec/internal/app/jobs/handler_job.rb +1 -0
  74. data/spec/internal/app/jobs/second_handler_job.rb +1 -0
  75. data/spec/internal/app/models/dummy_model.rb +1 -0
  76. data/spec/internal/config/environments/test.rb +1 -0
  77. data/spec/internal/config/initializers/api.rb +1 -0
  78. data/spec/internal/config/routes.rb +1 -0
  79. data/spec/internal/db/schema.rb +1 -0
  80. data/spec/jobs/apress/api/event_handler_equeueing_job_spec.rb +1 -0
  81. data/spec/jobs/apress/api/fire_callback_job_spec.rb +1 -0
  82. data/spec/lib/apress/api/callbacks/integration_spec.rb +1 -0
  83. data/spec/models/client_spec.rb +1 -0
  84. data/spec/services/auth_service_spec.rb +1 -0
  85. data/spec/spec_helper.rb +1 -0
  86. metadata +16 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0675e01e2bf8451ccf0aea116eb8210702f95f4a
4
- data.tar.gz: f845d4e05146deefea5441834397d667069d3239
3
+ metadata.gz: 2a15ba51274eacfc7eb5ed70f29a74b65d392a54
4
+ data.tar.gz: 29f78fba861651c173d7b17ad3c2f1a1764e6896
5
5
  SHA512:
6
- metadata.gz: b555258e9441cf634c25eeb41a918f69fdd70fe98a109a2b509c791449937bbd2eb9296c167fc167e47cbdf4831dace20835e437d38eb2e9e1f6145955288b87
7
- data.tar.gz: 7dd2ba7675a18d8696af7f24a813493df6eb7feb40b2afbee180f890bdd26ce65c02e43b6da45a033ab0ba3fb0e7dfaffab2e5d22e0c451f1c511ebcd94cb1f1
6
+ metadata.gz: 4e6cefef7e7243fb8de4767d02f28f3d0069dc12e397cba8989ca4f86bbb50dc7fa833fbc86ec2dc6cb41efbbe4f20a3e898072d19bdd483b54a0882c309c511
7
+ data.tar.gz: 9ea70efe78bf9c39c1c12169721893bad755f6b28f34ac8788f29b731f733c1e6b8a378639d754e4cf9c439200f21dd197a0a3093ff179b93c36f60cc0a1ab1c
data/.drone.yml CHANGED
@@ -1,30 +1,72 @@
1
- build:
2
- test:
3
- image: abakpress/dind-testing
4
- privileged: true
5
- pull: true
6
- volumes:
7
- - /home/data/drone/images:/images
8
- - /home/data/drone/gems:/bundle
9
- environment:
10
- - COMPOSE_FILE_EXT=drone
11
- - RUBY_IMAGE_TAG=2.2-latest
12
- - POSTGRES_IMAGE_TAG=9.3-latest
13
- commands:
14
- - wrapdocker docker -v
15
-
16
- - fetch-images --image abakpress/ruby-app:$RUBY_IMAGE_TAG
17
-
18
- - dip provision
19
- - dip rspec
20
-
21
- release:
22
- image: abakpress/gem-publication
23
- pull: true
24
- when:
25
- event: push
26
- branch: master
27
- volumes:
28
- - /home/data/drone/rubygems:/root/.gem
29
- commands:
30
- - release-gem --public
1
+ ---
2
+ kind: pipeline
3
+ type: docker
4
+ name: build
5
+
6
+ volumes:
7
+ - name: rubygems
8
+ host:
9
+ path: /home/data/drone/rubygems
10
+ - name: bundle
11
+ host:
12
+ path: /home/data/drone/gems
13
+
14
+ spec_step_common: &spec_step_common
15
+ pull: if-not-exists
16
+ volumes:
17
+ - name: bundle
18
+ path: /bundle
19
+ commands:
20
+ - rm -fr Gemfile.lock gemfiles/
21
+ - bundle install -j 5
22
+ - bundle exec appraisal install
23
+ - bundle exec appraisal bundle exec rspec
24
+
25
+ steps:
26
+ - name: postgres
27
+ image: abakpress/postgres-db:9.6-latest
28
+ pull: if-not-exists
29
+ environment:
30
+ POSTGRES_DB: docker
31
+ detach: true
32
+
33
+ - name: build on ruby2.2
34
+ image: abakpress/ruby-app:2.2-latest
35
+ environment:
36
+ TEST_DB_HOST: postgres
37
+ TEST_DB_NAME: docker
38
+ TEST_DB_USERNAME: postgres
39
+ BUNDLE_PATH: /bundle/2.2
40
+ <<: *spec_step_common
41
+
42
+ - name: build on ruby2.3
43
+ image: abakpress/ruby-app:2.3-latest
44
+ environment:
45
+ TEST_DB_HOST: postgres
46
+ TEST_DB_NAME: docker
47
+ TEST_DB_USERNAME: postgres
48
+ BUNDLE_PATH: /bundle/2.3
49
+ <<: *spec_step_common
50
+
51
+ - name: build on ruby2.4
52
+ image: abakpress/ruby-app:2.4-latest
53
+ environment:
54
+ TEST_DB_HOST: postgres
55
+ TEST_DB_NAME: docker
56
+ TEST_DB_USERNAME: postgres
57
+ BUNDLE_PATH: /bundle/2.4
58
+ <<: *spec_step_common
59
+
60
+ - name: release
61
+ image: abakpress/gem-publication:latest
62
+ pull: if-not-exists
63
+ when:
64
+ event: push
65
+ branch: master
66
+ status: success
67
+ volumes:
68
+ - name: rubygems
69
+ path: /root/.gem
70
+ commands:
71
+ - release-gem --public
72
+
data/Appraisals CHANGED
@@ -1,18 +1,14 @@
1
- appraise "rails3.2" do
2
- gem "rails", "~> 3.2.0", require: false
3
- gem "strong_parameters", ">= 0.2", require: false
1
+ # frozen_string_literal: true
2
+ if RUBY_VERSION < '2.4'
3
+ appraise "rails4.0" do
4
+ gem "rails", "~> 4.0.0", require: false
5
+ end
4
6
  end
5
7
 
6
- appraise "rails4.0" do
7
- gem "rails", "~> 4.0.0", require: false
8
- end
9
-
10
- appraise "rails4.1" do
11
- gem "rails", "~> 4.1.0", require: false
12
- end
13
-
14
- appraise "rails4.2" do
15
- gem "rails", "~> 4.2.0", require: false
8
+ if RUBY_VERSION < '2.5'
9
+ appraise "rails4.2" do
10
+ gem "rails", "~> 4.2.0", require: false
11
+ end
16
12
  end
17
13
 
18
14
  appraise "rails5.0" do
data/CHANGELOG.md CHANGED
@@ -1,3 +1,27 @@
1
+ # v1.24.2
2
+
3
+ * 2021-07-22 [79fba01](../../commit/79fba01) - __(Andrew N. Shalaev)__ fix: try to mount missed volume
4
+ * 2021-07-16 [37a8921](../../commit/37a8921) - __(Andrew N. Shalaev)__ Release v1.24.2
5
+ * 2021-07-16 [c261182](../../commit/c261182) - __(Andrew N. Shalaev)__ feature: freeze string literals
6
+ * 2021-07-16 [2e9f3f3](../../commit/2e9f3f3) - __(Andrew N. Shalaev)__ feature: add ruby2.4 support
7
+ https://jira.railsc.ru/browse/BPC-19154
8
+
9
+ * 2019-09-20 [f397049](../../commit/f397049) - __(Andrew N. Shalaev)__ Release v1.24.1
10
+ * 2019-09-20 [929480d](../../commit/929480d) - __(Andrew N. Shalaev)__ feature: add bage with version for link to rubygems.org
11
+
12
+ # v1.24.0
13
+
14
+ * 2019-09-19 [d2ec039](../../commit/d2ec039) - __(Andrew N. Shalaev)__ fix: send 401 Unathorized instead 403
15
+ https://jira.railsc.ru/browse/BPC-15268
16
+
17
+ # v1.23.0
18
+
19
+ * 2018-10-01 [d0e5a8e](../../commit/d0e5a8e) - __(Artem Napolskih)__ feat: adds ability to configure root page
20
+
21
+ # v1.22.1
22
+
23
+ * 2018-08-30 [1328469](../../commit/1328469) - __(Ilya Zhidkov)__ fix(gemspec): add min version for addressable
24
+
1
25
  # v1.22.0
2
26
 
3
27
  * 2018-08-22 [7bb90fa](../../commit/7bb90fa) - __(Artem Napolskih)__ chore: Add automatic publication
data/Gemfile CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  source "https://gems.railsc.ru"
2
3
  source "https://rubygems.org"
3
4
 
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Apress::Api
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/apress-api.svg)](https://badge.fury.io/rb/apress-api)
4
+
3
5
  Базовый контроллер АПИ с авторизацией HMAC
4
6
 
5
7
  ## Installation
data/Rakefile CHANGED
@@ -1,2 +1,3 @@
1
+ # frozen_string_literal: true
1
2
  require "bundler/gem_tasks"
2
3
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Apress
2
3
  module Api
3
4
  class DeprecatedVersionsController < ApiController::Base
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Apress
2
3
  module Api
3
4
  module V1
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Apress
2
3
  module Api
3
4
  module V1
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Schema
2
3
  module Api
3
4
  module V1
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Schema
2
3
  module Api
3
4
  module V1
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Swagger
2
3
  module V1
3
4
  module Controllers
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Swagger
2
3
  module V1
3
4
  module DefaultResponses
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Swagger
2
3
  module V1
3
4
  module DefaultResponses
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Swagger
2
3
  module V1
3
4
  module DefaultResponses
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Swagger
2
3
  module V1
3
4
  module DefaultResponses
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Swagger
2
3
  module V1
3
4
  module DefaultResponses
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Swagger
2
3
  module V1
3
4
  module DefaultResponses
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Swagger
2
3
  module V1
3
4
  module Models
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Swagger
2
3
  module V1
3
4
  module Models
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require_relative 'unprocessable_error'
2
3
 
3
4
  module Swagger
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Swagger
2
3
  module V1
3
4
  module Models
@@ -1,19 +1,21 @@
1
+ # frozen_string_literal: true
1
2
  module Swagger
2
3
  module V1
3
4
  class Root < ::Apress::Documentation::Swagger::Schema
4
5
  swagger_root do
5
6
  key :swagger, '2.0'
6
7
  info do
7
- key :version, '1.0.0'
8
- key :title, 'Apress API'
9
- key :description, 'Apress API'
10
- key :termsOfService, 'None'
8
+ key :version, Rails.application.config.api[:version]
9
+ key :title, Rails.application.config.api[:title]
10
+ key :description, Rails.application.config.api[:description]
11
+ key :termsOfService, Rails.application.config.api[:terms_of_service]
12
+
11
13
  contact do
12
- key :name, 'Abak-Press Team'
14
+ key :name, Rails.application.config.api[:contact_name]
13
15
  end
14
16
  end
15
17
 
16
- key :basePath, '/api/v1'
18
+ key :basePath, Rails.application.config.api[:base_path]
17
19
  key :produces, ['application/json']
18
20
 
19
21
  security_definition :APIAuth do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Apress
2
3
  module Api
3
4
  module Callbacks
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Apress
2
3
  module Api
3
4
  class DelayedFireCallback
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Apress
2
3
  module Api
3
4
  class EventHandlerEnqueueingJob
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Apress
2
3
  module Api
3
4
  class FireCallbackJob
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Apress
2
3
  module Api
3
4
  class Client < ActiveRecord::Base
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Apress
2
3
  module Api
3
4
  class CallbackPolicy
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Apress
2
3
  module Api
3
4
  class AuthService
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  json.error do
2
3
  json.message exception.message
3
4
  json.backtrace exception.backtrace
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  json.status @status
2
3
 
3
4
  if @exception && show_errors?
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  json.status @status
2
3
 
3
4
  json.errors do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  json.status @status
2
3
 
3
4
  json.errors do
@@ -1,2 +1,3 @@
1
+ # frozen_string_literal: true
1
2
  json.(client, :id, :access_id, :secret_token_expire_at, :refresh_token_expire_at, :user_agent,
2
3
  :updated_at, :created_at)
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  json.client do
2
3
  json.partial! partial: "apress/api/v1/clients/client", locals: {client: @client}
3
4
  json.(@client, :secret_token, :refresh_token)
data/apress-api.gemspec CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  lib = File.expand_path('../lib', __FILE__)
2
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
4
  require 'apress/api/version'
@@ -26,6 +27,7 @@ Gem::Specification.new do |spec|
26
27
  spec.add_runtime_dependency 'swagger-core', '>= 0.3.0'
27
28
  spec.add_runtime_dependency 'interactor'
28
29
  spec.add_runtime_dependency 'pundit'
30
+ spec.add_runtime_dependency 'addressable', '>= 2.4.0'
29
31
 
30
32
  spec.add_runtime_dependency 'resque-integration'
31
33
  spec.add_runtime_dependency 'apress-documentation', '>= 0.2.0'
data/config/routes.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  Rails.application.routes.draw do
2
3
  current_api_routes = lambda do
3
4
  resources :clients, only: [] do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  if Rails::VERSION::MAJOR > 4
2
3
  MIGRATION_CLASS = ActiveRecord::Migration[4.2]
3
4
  else
data/dip.yml CHANGED
@@ -1,8 +1,8 @@
1
1
  version: '1'
2
2
 
3
3
  environment:
4
- DOCKER_RUBY_VERSION: 2.2
5
- RUBY_IMAGE_TAG: 2.2-latest
4
+ DOCKER_RUBY_VERSION: 2.3
5
+ RUBY_IMAGE_TAG: 2.3-latest
6
6
  POSTGRES_IMAGE_TAG: 9.6-0.7.0
7
7
  COMPOSE_FILE_EXT: development
8
8
  RAILS_ENV: test
@@ -39,10 +39,11 @@ interaction:
39
39
 
40
40
  clean:
41
41
  service: app
42
- command: rm -f Gemfile.lock gemfiles/*.gemfile.*
42
+ command: rm -rf Gemfile.lock gemfiles/
43
43
 
44
44
  provision:
45
45
  - docker volume create --name bundler_data
46
+ - dip bundle config --local https://gems.railsc.ru/ ${APRESS_GEMS_CREDENTIALS}
46
47
  - dip clean
47
48
  - dip bundle install
48
49
  - dip appraisal install
data/lib/apress-api.rb CHANGED
@@ -1 +1,2 @@
1
+ # frozen_string_literal: true
1
2
  require 'apress/api'
data/lib/apress/api.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'rails'
2
3
  require "active_support"
3
4
  require "active_support/lazy_load_patch" if ActiveSupport::VERSION::MAJOR == 3 && ActiveSupport::VERSION::MINOR == 1
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Apress
2
3
  module Api
3
4
  module ApiController
@@ -25,7 +26,7 @@ module Apress
25
26
  end
26
27
 
27
28
  def authenticate
28
- forbidden unless @current_api_client
29
+ unauthorized unless @current_api_client
29
30
  end
30
31
  end
31
32
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Apress
2
3
  module Api
3
4
  module ApiController
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Apress
2
3
  module Api
3
4
  module ApiController
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'addressable/uri'
2
3
  require 'apress/api/api_controller/pagination_helper'
3
4
  module Apress
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Apress
2
3
  module Api
3
4
  module ApiController
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Apress
2
3
  module Api
3
4
  module ApiController
@@ -41,6 +42,10 @@ module Apress
41
42
  render_error(400, exception)
42
43
  end
43
44
 
45
+ def unauthorized(exception = nil)
46
+ render_error(401, exception)
47
+ end
48
+
44
49
  def unprocessable(exception_or_errors)
45
50
  @status = 422
46
51
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Apress
2
3
  module Api
3
4
  module ApiController
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'singleton'
2
3
 
3
4
  module Apress
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Apress
2
3
  module Api
3
4
  module Callbacks
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Apress
2
3
  module Api
3
4
  module Callbacks
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Apress
2
3
  module Api
3
4
  module Callbacks
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'rails/engine'
2
3
 
3
4
  module Apress
@@ -8,15 +9,21 @@ module Apress
8
9
 
9
10
  Apress::Documentation.add_load_path(config.root.join('app/docs'))
10
11
 
12
+ config.api = {
13
+ secret_token_ttl: 1.hour,
14
+ refresh_token_ttl: 1.week,
15
+ v1_doc_path: 'docs/swagger/v1.json',
16
+ version: '1.0.0',
17
+ title: 'Apress API',
18
+ description: 'Apress API',
19
+ terms_of_service: 'None',
20
+ contact_name: 'Abak-Press Team',
21
+ base_path: '/api/v1'
22
+ }
23
+
11
24
  initializer "apress-api", before: :load_init_rb do |app|
12
25
  app.config.paths["db/migrate"].concat(config.paths["db/migrate"].expanded)
13
26
 
14
- app.config.api = {
15
- secret_token_ttl: 1.hour,
16
- refresh_token_ttl: 1.week,
17
- v1_doc_path: 'docs/swagger/v1.json'
18
- }
19
-
20
27
  ::MultiJson.use :oj
21
28
 
22
29
  require 'jbuilder/jbuilder_template'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Apress
2
3
  module Api
3
4
  module Extensions
@@ -1,4 +1,5 @@
1
1
  # coding: utf-8
2
+ # frozen_string_literal: true
2
3
  require 'rspec/core'
3
4
  require 'rspec/expectations'
4
5
  require 'swagger'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'json'
2
3
 
3
4
  module Apress
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'json-schema'
2
3
  require 'rspec/expectations'
3
4
 
@@ -1,5 +1,6 @@
1
+ # frozen_string_literal: true
1
2
  module Apress
2
3
  module Api
3
- VERSION = '1.22.0'.freeze
4
+ VERSION = '1.24.2'
4
5
  end
5
6
  end
data/lib/tasks/docs.rake CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  namespace :docs do
2
3
  desc 'Generate api documentation'
3
4
  task generate: :environment do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require "spec_helper"
2
3
 
3
4
  describe Apress::Api::ApiController::Base, type: :controller do
@@ -28,9 +29,9 @@ describe Apress::Api::ApiController::Base, type: :controller do
28
29
  context "when auth failed" do
29
30
  let(:auth_service) { double("auth_service", call: false, client: nil) }
30
31
 
31
- it "returns 403" do
32
+ it "returns 401" do
32
33
  get :index
33
- expect(response.status).to eq 403
34
+ expect(response.status).to eq 401
34
35
  expect(controller.current_api_client).to be nil
35
36
  end
36
37
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require "spec_helper"
2
3
 
3
4
  def form_params(p)
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require "spec_helper"
2
3
 
3
4
  describe Apress::Api::ApiController::Base, type: :controller do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require "spec_helper"
2
3
 
3
4
  describe Apress::Api::DeprecatedVersionsController, type: :controller do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require "spec_helper"
2
3
 
3
4
  def form_params(p)
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require "spec_helper"
2
3
 
3
4
  def form_params(p)
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  FactoryGirl.define do
2
3
  factory 'api/client', class: Apress::Api::Client do
3
4
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
  SIMPLE_TEST = <<-JBUILDER
3
4
  json.paginating_cache! @collection, nil, skip_digest: true do
@@ -24,7 +25,7 @@ def jbuild(source_key, collection)
24
25
  end
25
26
 
26
27
  def view_prefix
27
- if Rails::VERSION::MAJOR > 4
28
+ if Rails::VERSION::MAJOR == 5 && Rails::VERSION::MINOR >= 2
28
29
  'jbuilder/views'
29
30
  else
30
31
  'jbuilder'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Apress::Api::DelayedFireCallback, type: :interactor do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ErrorClient
2
3
  class FireCallback < Apress::Api::Callbacks::BaseCallback
3
4
  class RepeatError < StandardError
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ServiceClient
2
3
  class FireCallback < Apress::Api::Callbacks::BaseCallback
3
4
  def call
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  class HandlerJob
2
3
  def self.perform
3
4
  "Do work"
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  class SecondHandlerJob
2
3
  def self.perform
3
4
  "Do work"
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  class DummyModel < ActiveRecord::Base
2
3
  include Apress::Api::Callbacks::Integration
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  HOST = 'www.example.org'
2
3
  ASSETS_HOST = 'www.example.org'
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  Apress::Api::Callbacks::Config.add_client('service_access_id')
2
3
 
3
4
  Apress::Api::Callbacks::Config.add_service(service: 'service', event: 'some_event')
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  Rails.application.routes.draw do
2
3
  #
3
4
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  ActiveRecord::Schema.define do
2
3
  create_table :dummy_models do |t|
3
4
  t.string :name
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Apress::Api::EventHandlerEnqueueingJob, type: :job do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Apress::Api::FireCallbackJob, type: :job do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Apress::Api::Callbacks::Integration, type: :mixin do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require "spec_helper"
2
3
 
3
4
  describe Apress::Api::Client do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require "spec_helper"
2
3
  require "rack/request"
3
4
  require "rack/mock"
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require "bundler/setup"
2
3
  require 'pry-byebug'
3
4
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apress-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.22.0
4
+ version: 1.24.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - merkushin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-08-28 00:00:00.000000000 Z
11
+ date: 2021-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -156,6 +156,20 @@ dependencies:
156
156
  - - ">="
157
157
  - !ruby/object:Gem::Version
158
158
  version: '0'
159
+ - !ruby/object:Gem::Dependency
160
+ name: addressable
161
+ requirement: !ruby/object:Gem::Requirement
162
+ requirements:
163
+ - - ">="
164
+ - !ruby/object:Gem::Version
165
+ version: 2.4.0
166
+ type: :runtime
167
+ prerelease: false
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ requirements:
170
+ - - ">="
171
+ - !ruby/object:Gem::Version
172
+ version: 2.4.0
159
173
  - !ruby/object:Gem::Dependency
160
174
  name: resque-integration
161
175
  requirement: !ruby/object:Gem::Requirement