factory_bot_instrumentation 1.4.0 → 1.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 37442055c37286bda9ecc80137609a66e4170181350f1fe494e0140cf888a33c
4
- data.tar.gz: eb684ed40aad5659818346b43b22510c981fac3283ce81239ff943b3148aa72b
3
+ metadata.gz: 83e360c563829d80a36e5bc4210a6a3da30233958a03d6c121a0158b445cb502
4
+ data.tar.gz: ee121882322897358b90092c0c88e8d0d70e416bc5a44188c78e34386aaa07ea
5
5
  SHA512:
6
- metadata.gz: c24c700505db37bd0960ccf4d4f941c9117c2b0885b15fbabe871ee7b63bd5d87b259e77a94e751784f9c51edb4d08c04f22ea6338ca4d0cf913475245d6f165
7
- data.tar.gz: 20461fb181cd6e48fd3c7a32d5cfbc1f0647fb5a85095564c4cdeff3951a23b8a6047d6b60a532588f763222bb8475bac5ee8f0e27dd06d9fa6a20e40f3a07d4
6
+ metadata.gz: 4a6f7e41ffe69853ef92f6708f8540b571917b78086084f52d0c8790e3aa1222661c3bbd0dc8b70867a506a8e3d412610ebb8b364130bcfc82022052b8304cc7
7
+ data.tar.gz: 01d84146f7db621d49a04ea6542e4a6bf570676a4c5405560a4aeb56b0b92f457d72163a480b0b2c583f756adfe36ce739bb3de35875b6ed9de7229693411a5e
data/CHANGELOG.md CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  * TODO: Replace this bullet point with an actual description of a change.
4
4
 
5
+ ### 1.5.0 (7 January 2025)
6
+
7
+ * Switched from `ActionController::API` to `ActionController::Base` for the
8
+ engine's `ApplicationController` (#25)
9
+
10
+ ### 1.4.1 (6 January 2025)
11
+
12
+ * Reverted (#23) as it causes errors for unknown reasons (#24)
13
+
5
14
  ### 1.4.0 (6 January 2025)
6
15
 
7
16
  * Moved the instrumentation methods (`#instrumentation`, `#scenarios`,
data/README.md CHANGED
@@ -243,7 +243,8 @@ application. The file
243
243
  this:
244
244
 
245
245
  ```ruby
246
- class Instrumentation::AuthenticationsController < ActionController::API
246
+ class Instrumentation::AuthenticationsController \
247
+ < FactoryBot::Instrumentation::ApplicationController
247
248
  # Generate a new web app authentication URL for the given email address.
248
249
  # This endpoint creates new login URLs which are valid for 30 minutes.
249
250
  def create
@@ -271,9 +272,20 @@ routes like this:
271
272
 
272
273
  ```ruby
273
274
  Rails.application.routes.draw do
274
- unless Rails.env.production?
275
+ if ActiveModel::Type::Boolean.new.cast(ENV.fetch('INSTRUMENTATION_API',
276
+ false))
275
277
  mount FactoryBot::Instrumentation::Engine => '/instrumentation'
276
278
  end
279
+
280
+ # or with custom controllers in an namespace
281
+
282
+ if ActiveModel::Type::Boolean.new.cast(ENV.fetch('INSTRUMENTATION_API',
283
+ false))
284
+ namespace :instrumentation do
285
+ mount FactoryBot::Instrumentation::Engine => '/'
286
+ resource :authentication, only: :create
287
+ end
288
+ end
277
289
  end
278
290
  ```
279
291
 
@@ -3,12 +3,18 @@
3
3
  module FactoryBot
4
4
  module Instrumentation
5
5
  # A base engine application controller.
6
- class ApplicationController < ActionController::API
6
+ class ApplicationController < ActionController::Base
7
7
  # Extend our core functionality to support easy authentication logics
8
8
  include ActionController::HttpAuthentication::Basic::ControllerMethods
9
9
  include ActionController::HttpAuthentication::Digest::ControllerMethods
10
10
  include ActionController::HttpAuthentication::Token::ControllerMethods
11
11
 
12
+ # Rails 5.2 enabled CSRF protection by default, but this may be different
13
+ # on the host application. Therefore we cannot blindly disable it via
14
+ # +skip_forgery_protection+. We have to "enable" it for no routes, which
15
+ # eventually disables it entirely for this engine.
16
+ protect_from_forgery only: []
17
+
12
18
  # Allow the users to implement additional instrumentation-wide before
13
19
  # action logic, like authentication
14
20
  before_action do |_controller|
@@ -19,8 +25,6 @@ module FactoryBot
19
25
  end
20
26
  end
21
27
 
22
- protected
23
-
24
28
  # A simple shortcut for Basic Auth on Rails 4.2+. Just configure the
25
29
  # username and password and you're ready to check the current request.
26
30
  #
@@ -4,12 +4,6 @@ module FactoryBot
4
4
  module Instrumentation
5
5
  # The Instrumentation engine controller with frontend and API actions.
6
6
  class RootController < ApplicationController
7
- # This is required to make API controllers template renderable
8
- include ActionView::Layouts
9
-
10
- # Configure the default application layout
11
- layout 'factory_bot/instrumentation/application'
12
-
13
7
  # Show the instrumentation frontend which features the output of
14
8
  # configured dynamic seeds scenarios. The frontend allows humans to
15
9
  # generate new seed data on the fly.
@@ -53,8 +47,6 @@ module FactoryBot
53
47
  FactoryBot::Instrumentation.configuration.render_error.call(self, e)
54
48
  end
55
49
 
56
- protected
57
-
58
50
  # Parse the given parameters from the request and build
59
51
  # a valid FactoryBot options set.
60
52
  #
@@ -5,6 +5,7 @@ module FactoryBot
5
5
  # The Instrumentation engine which can be mounted.
6
6
  class Engine < ::Rails::Engine
7
7
  isolate_namespace FactoryBot::Instrumentation
8
+ engine_name 'factory_bot_instrumentation'
8
9
 
9
10
  # Fill in some dynamic settings (application related)
10
11
  initializer 'factory_bot_instrumentation.config' do |app|
@@ -4,7 +4,7 @@ module FactoryBot
4
4
  # The gem version details.
5
5
  module Instrumentation
6
6
  # The version of the +factory_bot_instrumentation+ gem
7
- VERSION = '1.4.0'
7
+ VERSION = '1.5.0'
8
8
 
9
9
  class << self
10
10
  # Returns the version of gem as a string.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: factory_bot_instrumentation
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hermann Mayer
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-01-06 00:00:00.000000000 Z
11
+ date: 2025-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: factory_bot