flipper-api 0.21.0.rc2 → 0.22.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.
- checksums.yaml +4 -4
- data/lib/flipper/api/middleware.rb +2 -1
- data/lib/flipper/api.rb +0 -3
- data/lib/flipper/version.rb +1 -1
- data/spec/flipper/api/v1/actions/actors_gate_spec.rb +19 -1
- data/spec/flipper/api_spec.rb +36 -0
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 89c314a5ec8c1fd1721816788c488e7a31c9efbe6498a31c4f9b67993d966a2e
|
4
|
+
data.tar.gz: 161de17697154d1fbecc99314867eb5b3a715fdc9b1faf4b21b3f2c4d863a042
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d19b99ad5345b04fe6d982a6ed99927931e38e79a487ccebe6114b18a86a0f3082615582aa07c13d40fc35816ffe92be7f68f91fbe8f459bce424264cf2cb294
|
7
|
+
data.tar.gz: 810cd1ff09020df6db45f1b136bbdab8bed6f14e9cdbb4ffe1ce4abd6651c78e5618c48221670f1085c25f4467542528f3dabd930d8b95c78ab2ec1600490c52
|
@@ -32,10 +32,11 @@ module Flipper
|
|
32
32
|
def call!(env)
|
33
33
|
request = Rack::Request.new(env)
|
34
34
|
action_class = @action_collection.action_for_request(request)
|
35
|
+
|
35
36
|
if action_class.nil?
|
36
37
|
@app.call(env)
|
37
38
|
else
|
38
|
-
flipper = env.fetch(@env_key)
|
39
|
+
flipper = env.fetch(@env_key) { Flipper }
|
39
40
|
action_class.run(flipper, request)
|
40
41
|
end
|
41
42
|
end
|
data/lib/flipper/api.rb
CHANGED
@@ -9,14 +9,11 @@ module Flipper
|
|
9
9
|
|
10
10
|
def self.app(flipper = nil, options = {})
|
11
11
|
env_key = options.fetch(:env_key, 'flipper')
|
12
|
-
memoizer_options = options.fetch(:memoizer_options, {})
|
13
|
-
|
14
12
|
app = ->(_) { [404, { 'Content-Type'.freeze => CONTENT_TYPE }, ['{}'.freeze]] }
|
15
13
|
builder = Rack::Builder.new
|
16
14
|
yield builder if block_given?
|
17
15
|
builder.use Flipper::Api::JsonParams
|
18
16
|
builder.use Flipper::Middleware::SetupEnv, flipper, env_key: env_key
|
19
|
-
builder.use Flipper::Middleware::Memoizer, memoizer_options.merge(env_key: env_key)
|
20
17
|
builder.use Flipper::Api::Middleware, env_key: env_key
|
21
18
|
builder.run app
|
22
19
|
klass = self
|
data/lib/flipper/version.rb
CHANGED
@@ -44,7 +44,7 @@ RSpec.describe Flipper::Api::V1::Actions::ActorsGate do
|
|
44
44
|
|
45
45
|
describe 'enable feature with slash in name' do
|
46
46
|
before do
|
47
|
-
flipper[
|
47
|
+
flipper["my/feature"].disable_actor(actor)
|
48
48
|
post '/features/my/feature/actors', flipper_id: actor.flipper_id
|
49
49
|
end
|
50
50
|
|
@@ -60,6 +60,24 @@ RSpec.describe Flipper::Api::V1::Actions::ActorsGate do
|
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
|
+
describe 'enable feature with space in name' do
|
64
|
+
before do
|
65
|
+
flipper["sp ace"].disable_actor(actor)
|
66
|
+
post '/features/sp%20ace/actors', flipper_id: actor.flipper_id
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'enables feature for actor' do
|
70
|
+
expect(last_response.status).to eq(200)
|
71
|
+
expect(flipper["sp ace"].enabled?(actor)).to be_truthy
|
72
|
+
expect(flipper["sp ace"].enabled_gate_names).to eq([:actor])
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'returns decorated feature with actor enabled' do
|
76
|
+
gate = json_response['gates'].find { |gate| gate['key'] == 'actors' }
|
77
|
+
expect(gate['value']).to eq(['1'])
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
63
81
|
describe 'enable missing flipper_id parameter' do
|
64
82
|
before do
|
65
83
|
flipper[:my_feature].enable
|
data/spec/flipper/api_spec.rb
CHANGED
@@ -1,6 +1,36 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
3
|
RSpec.describe Flipper::Api do
|
4
|
+
describe 'Initializing middleware with flipper instance' do
|
5
|
+
let(:app) { build_api(flipper) }
|
6
|
+
|
7
|
+
it 'works' do
|
8
|
+
flipper.enable :a
|
9
|
+
flipper.disable :b
|
10
|
+
|
11
|
+
get '/features'
|
12
|
+
|
13
|
+
expect(last_response.status).to be(200)
|
14
|
+
feature_names = json_response.fetch('features').map { |feature| feature.fetch('key') }
|
15
|
+
expect(feature_names).to eq(%w(a b))
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe 'Initializing middleware lazily with a block' do
|
20
|
+
let(:app) { build_api(-> { flipper }) }
|
21
|
+
|
22
|
+
it 'works' do
|
23
|
+
flipper.enable :a
|
24
|
+
flipper.disable :b
|
25
|
+
|
26
|
+
get '/features'
|
27
|
+
|
28
|
+
expect(last_response.status).to be(200)
|
29
|
+
feature_names = json_response.fetch('features').map { |feature| feature.fetch('key') }
|
30
|
+
expect(feature_names).to eq(%w(a b))
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
4
34
|
context 'when initialized with flipper instance and flipper instance in env' do
|
5
35
|
let(:app) { build_api(flipper) }
|
6
36
|
|
@@ -76,4 +106,10 @@ RSpec.describe Flipper::Api do
|
|
76
106
|
expect(json_response).to eq({})
|
77
107
|
end
|
78
108
|
end
|
109
|
+
|
110
|
+
describe 'Inspecting the built Rack app' do
|
111
|
+
it 'returns a String' do
|
112
|
+
expect(build_api(flipper).inspect).to be_a(String)
|
113
|
+
end
|
114
|
+
end
|
79
115
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flipper-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.22.2
|
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-
|
11
|
+
date: 2021-10-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -36,14 +36,14 @@ dependencies:
|
|
36
36
|
requirements:
|
37
37
|
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: 0.
|
39
|
+
version: 0.22.2
|
40
40
|
type: :runtime
|
41
41
|
prerelease: false
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: 0.
|
46
|
+
version: 0.22.2
|
47
47
|
description:
|
48
48
|
email:
|
49
49
|
- nunemaker@gmail.com
|
@@ -101,9 +101,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
101
101
|
version: '0'
|
102
102
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
103
|
requirements:
|
104
|
-
- - "
|
104
|
+
- - ">="
|
105
105
|
- !ruby/object:Gem::Version
|
106
|
-
version:
|
106
|
+
version: '0'
|
107
107
|
requirements: []
|
108
108
|
rubygems_version: 3.0.3
|
109
109
|
signing_key:
|