flipper 0.23.0 → 0.23.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c7754b40752e0c255308fedfb6ef7784e7e9b3cf4ba0035a289a02074e61e4e7
4
- data.tar.gz: 7e0add2ac95c2dc929a97fef218ece9fbc904c911ffe6f4ac1d3ccbc36befab9
3
+ metadata.gz: a41bf1dd43734d1d6c6b56a46ea393af74164d46aadd7671994bdcc10e4eb646
4
+ data.tar.gz: e935dc1375a66156f0d0f7ba967269d184b8babaf119333c614943643f760ed7
5
5
  SHA512:
6
- metadata.gz: 3e5b7b82f89f1cdbb93f0a07d6909aea686214e9ce6a7c1daf4661f900da5e3dfe3176ed89ffe1bb63b8317788bce1a662ad27b2e88b01bebb77856213be7f4d
7
- data.tar.gz: e8d25c0ed393a34f4f7ec93b2d2ec8707f009ba35e83ef606d4850c7031bb7e923af83c2472fd2d6d00004d6561f410156021b7892dab20883dd0c6fe2efcb15
6
+ metadata.gz: 82d249a9f90b96fcf88713890a2df5a7fa5f05927b7a1903630e276507ee709b5426b91fba46aa6ef034e15dc6b50b35781d61b56afe512a46673e4de3eb559d
7
+ data.tar.gz: c986d6fb7c1a773ab56e6b7cb35734648485562690799dff901578b2c31566f5582bb8390268228f48eda9fba6797f8b72bd7fd385e45a9a04155c14a4c8b95f
data/Changelog.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## 0.23.1
2
+
3
+ ### Additions/Changes
4
+
5
+ * Relax dalli version constraint (https://github.com/jnunemaker/flipper/pull/596)
6
+
7
+ ### Bug Fixes
8
+
9
+ * Fix railtie initialization to mount middleware after config/intializers/* (https://github.com/jnunemaker/flipper/pull/586)
10
+
1
11
  ## 0.23.0
2
12
 
3
13
  ### Additions/Changes
@@ -10,6 +10,12 @@ module Flipper
10
10
  )
11
11
  end
12
12
 
13
+ initializer "flipper.identifier" do
14
+ ActiveSupport.on_load(:active_record) do
15
+ ActiveRecord::Base.include Flipper::Identifier
16
+ end
17
+ end
18
+
13
19
  initializer "flipper.default", before: :load_config_initializers do |app|
14
20
  Flipper.configure do |config|
15
21
  config.default do
@@ -18,28 +24,23 @@ module Flipper
18
24
  end
19
25
  end
20
26
 
21
- initializer "flipper.memoizer" do |app|
22
- config = app.config.flipper
27
+ initializer "flipper.log", after: :load_config_initializers do |app|
28
+ flipper = app.config.flipper
23
29
 
24
- if config.memoize
25
- app.middleware.use Flipper::Middleware::Memoizer, {
26
- env_key: config.env_key,
27
- preload: config.preload,
28
- if: config.memoize.respond_to?(:call) ? config.memoize : nil
29
- }
30
- end
31
- end
32
-
33
- initializer "flipper.log" do |app|
34
- config = app.config.flipper
35
- if config.log && config.instrumenter == ActiveSupport::Notifications
30
+ if flipper.log && flipper.instrumenter == ActiveSupport::Notifications
36
31
  require "flipper/instrumentation/log_subscriber"
37
32
  end
38
33
  end
39
34
 
40
- initializer "flipper.identifier" do
41
- ActiveSupport.on_load(:active_record) do
42
- ActiveRecord::Base.include Flipper::Identifier
35
+ initializer "flipper.memoizer", after: :load_config_initializers do |app|
36
+ flipper = app.config.flipper
37
+
38
+ if flipper.memoize
39
+ app.middleware.use Flipper::Middleware::Memoizer, {
40
+ env_key: flipper.env_key,
41
+ preload: flipper.preload,
42
+ if: flipper.memoize.respond_to?(:call) ? flipper.memoize : nil
43
+ }
43
44
  end
44
45
  end
45
46
  end
@@ -1,3 +1,3 @@
1
1
  module Flipper
2
- VERSION = '0.23.0'.freeze
2
+ VERSION = '0.23.1'.freeze
3
3
  end
@@ -1,6 +1,5 @@
1
1
  require 'rack/test'
2
2
  require 'active_support/cache'
3
- require 'active_support/cache/dalli_store'
4
3
  require 'flipper/adapters/active_support_cache_store'
5
4
  require 'flipper/adapters/operation_logger'
6
5
 
@@ -3,11 +3,8 @@ require 'flipper/railtie'
3
3
 
4
4
  RSpec.describe Flipper::Railtie do
5
5
  let(:application) do
6
- Class.new(Rails::Application).new(
7
- railties: [Flipper::Railtie],
8
- ).tap do |app|
9
- app.config.eager_load = false
10
- app.run_load_hooks!
6
+ Class.new(Rails::Application).create(railties: [Flipper::Railtie]) do
7
+ config.eager_load = false
11
8
  end
12
9
  end
13
10
 
@@ -22,40 +19,42 @@ RSpec.describe Flipper::Railtie do
22
19
 
23
20
  describe 'initializers' do
24
21
  it 'sets defaults' do
22
+ subject # initialize
25
23
  expect(config.env_key).to eq("flipper")
26
24
  expect(config.memoize).to be(true)
27
25
  expect(config.preload).to be(true)
28
26
  end
29
27
 
30
28
  it "configures instrumentor on default instance" do
31
- subject
32
-
29
+ subject # initialize
33
30
  expect(Flipper.instance.instrumenter).to eq(ActiveSupport::Notifications)
34
31
  end
35
32
 
36
33
  it 'uses Memoizer middleware if config.memoize = true' do
34
+ initializer { config.memoize = true }
37
35
  expect(subject.middleware).to include(Flipper::Middleware::Memoizer)
38
36
  end
39
37
 
40
38
  it 'does not use Memoizer middleware if config.memoize = false' do
41
- # load but don't initialize
42
- config.memoize = false
43
-
39
+ initializer { config.memoize = false }
44
40
  expect(subject.middleware).not_to include(Flipper::Middleware::Memoizer)
45
41
  end
46
42
 
47
43
  it 'passes config to memoizer' do
48
- # load but don't initialize
49
- config.update(
50
- env_key: 'my_flipper',
51
- preload: [:stats, :search]
52
- )
53
-
54
- expect(Flipper::Middleware::Memoizer).to receive(:new).with(application.routes,
55
- env_key: 'my_flipper', preload: [:stats, :search], if: nil
56
- )
44
+ initializer do
45
+ config.update(
46
+ env_key: 'my_flipper',
47
+ preload: [:stats, :search]
48
+ )
49
+ end
57
50
 
58
- subject # initialize
51
+ expect(subject.middleware).to include(Flipper::Middleware::Memoizer)
52
+ middleware = subject.middleware.detect { |m| m.klass == Flipper::Middleware::Memoizer }
53
+ expect(middleware.args[0]).to eq({
54
+ env_key: config.env_key,
55
+ preload: config.preload,
56
+ if: nil
57
+ })
59
58
  end
60
59
 
61
60
  it "defines #flipper_id on AR::Base" do
@@ -64,4 +63,11 @@ RSpec.describe Flipper::Railtie do
64
63
  expect(ActiveRecord::Base.ancestors).to include(Flipper::Identifier)
65
64
  end
66
65
  end
66
+
67
+ # Add app initializer in the same order as config/initializers/*
68
+ def initializer(&block)
69
+ application.initializer 'spec', before: :load_config_initializers do
70
+ block.call
71
+ end
72
+ end
67
73
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flipper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.23.0
4
+ version: 0.23.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Nunemaker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-24 00:00:00.000000000 Z
11
+ date: 2022-01-19 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: