flipper-api 0.21.0.rc1 → 0.22.1
Sign up to get free protection for your applications and to get access to all the features.
- 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: 3378241cf94cd3f5922cfce943f3c728b4034b2a6b40f08a5c9ab00f01c21463
|
4
|
+
data.tar.gz: 4e0d9338fc3f605c2b3ea9917b312f8e8bbf1ffc0b80d9ecb606d5b3d5f6ec03
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f82bd31a433660f2a4c0678edb37ca32965302c3aa8cacd6a421584b3b6b8784e06be32513b72d06bf2257e13be22d2f25572b4ba115c4dc173d82254fc5cbc1
|
7
|
+
data.tar.gz: 1edfcc71162df8f5defd6ed0b741fb1550de32242a0e614388dd26f814e48c432b0253896cf764482ab5c55bead7ad7b2f1607db195435f4df9114a297d736c8
|
@@ -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.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-
|
11
|
+
date: 2021-08-23 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.1
|
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.1
|
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:
|