flipper-api 0.21.0 → 0.23.0
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/error_response.rb +1 -1
- 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/action_spec.rb +0 -2
- data/spec/flipper/api/json_params_spec.rb +0 -2
- data/spec/flipper/api/v1/actions/actors_gate_spec.rb +19 -3
- data/spec/flipper/api/v1/actions/actors_spec.rb +0 -2
- data/spec/flipper/api/v1/actions/boolean_gate_spec.rb +0 -2
- data/spec/flipper/api/v1/actions/clear_feature_spec.rb +0 -2
- data/spec/flipper/api/v1/actions/feature_spec.rb +0 -2
- data/spec/flipper/api/v1/actions/features_spec.rb +0 -2
- data/spec/flipper/api/v1/actions/groups_gate_spec.rb +0 -2
- data/spec/flipper/api/v1/actions/percentage_of_actors_gate_spec.rb +0 -2
- data/spec/flipper/api/v1/actions/percentage_of_time_gate_spec.rb +0 -2
- data/spec/flipper/api_spec.rb +36 -2
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c88c8fcf2cad7d28ac9a1c968cb4afa798006f34aef33ee0fbf4c47da64275e8
|
4
|
+
data.tar.gz: 5395ef9526ad46564c569d2fdc0f0f58376f5a4956fdb2929c9454b6e3e4d26e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d5eb1d1990347809c8383465585ba4926bb622c600870bd382bab3341028202e372311f63fd39f18b506172913e5b3ca7a93f456bfe9438e001da67efe9c5f36
|
7
|
+
data.tar.gz: 31316d4c9e04cf706ace8290733102c313053e571c497a4eac5a9bddbb32367dc60ca9a75d6e25245604ce6b7c983b84c9e00bc1fda9219031b1749b7e2561c8
|
@@ -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
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
1
|
RSpec.describe Flipper::Api::V1::Actions::ActorsGate do
|
4
2
|
let(:app) { build_api(flipper) }
|
5
3
|
let(:actor) { Flipper::Actor.new('1') }
|
@@ -44,7 +42,7 @@ RSpec.describe Flipper::Api::V1::Actions::ActorsGate do
|
|
44
42
|
|
45
43
|
describe 'enable feature with slash in name' do
|
46
44
|
before do
|
47
|
-
flipper[
|
45
|
+
flipper["my/feature"].disable_actor(actor)
|
48
46
|
post '/features/my/feature/actors', flipper_id: actor.flipper_id
|
49
47
|
end
|
50
48
|
|
@@ -60,6 +58,24 @@ RSpec.describe Flipper::Api::V1::Actions::ActorsGate do
|
|
60
58
|
end
|
61
59
|
end
|
62
60
|
|
61
|
+
describe 'enable feature with space in name' do
|
62
|
+
before do
|
63
|
+
flipper["sp ace"].disable_actor(actor)
|
64
|
+
post '/features/sp%20ace/actors', flipper_id: actor.flipper_id
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'enables feature for actor' do
|
68
|
+
expect(last_response.status).to eq(200)
|
69
|
+
expect(flipper["sp ace"].enabled?(actor)).to be_truthy
|
70
|
+
expect(flipper["sp ace"].enabled_gate_names).to eq([:actor])
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'returns decorated feature with actor enabled' do
|
74
|
+
gate = json_response['gates'].find { |gate| gate['key'] == 'actors' }
|
75
|
+
expect(gate['value']).to eq(['1'])
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
63
79
|
describe 'enable missing flipper_id parameter' do
|
64
80
|
before do
|
65
81
|
flipper[:my_feature].enable
|
data/spec/flipper/api_spec.rb
CHANGED
@@ -1,6 +1,34 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
1
|
RSpec.describe Flipper::Api do
|
2
|
+
describe 'Initializing middleware with flipper instance' do
|
3
|
+
let(:app) { build_api(flipper) }
|
4
|
+
|
5
|
+
it 'works' do
|
6
|
+
flipper.enable :a
|
7
|
+
flipper.disable :b
|
8
|
+
|
9
|
+
get '/features'
|
10
|
+
|
11
|
+
expect(last_response.status).to be(200)
|
12
|
+
feature_names = json_response.fetch('features').map { |feature| feature.fetch('key') }
|
13
|
+
expect(feature_names).to eq(%w(a b))
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe 'Initializing middleware lazily with a block' do
|
18
|
+
let(:app) { build_api(-> { flipper }) }
|
19
|
+
|
20
|
+
it 'works' do
|
21
|
+
flipper.enable :a
|
22
|
+
flipper.disable :b
|
23
|
+
|
24
|
+
get '/features'
|
25
|
+
|
26
|
+
expect(last_response.status).to be(200)
|
27
|
+
feature_names = json_response.fetch('features').map { |feature| feature.fetch('key') }
|
28
|
+
expect(feature_names).to eq(%w(a b))
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
4
32
|
context 'when initialized with flipper instance and flipper instance in env' do
|
5
33
|
let(:app) { build_api(flipper) }
|
6
34
|
|
@@ -76,4 +104,10 @@ RSpec.describe Flipper::Api do
|
|
76
104
|
expect(json_response).to eq({})
|
77
105
|
end
|
78
106
|
end
|
107
|
+
|
108
|
+
describe 'Inspecting the built Rack app' do
|
109
|
+
it 'returns a String' do
|
110
|
+
expect(build_api(flipper).inspect).to be_a(String)
|
111
|
+
end
|
112
|
+
end
|
79
113
|
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.23.0
|
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-12-24 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.23.0
|
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.23.0
|
47
47
|
description:
|
48
48
|
email:
|
49
49
|
- nunemaker@gmail.com
|
@@ -105,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
105
105
|
- !ruby/object:Gem::Version
|
106
106
|
version: '0'
|
107
107
|
requirements: []
|
108
|
-
rubygems_version: 3.
|
108
|
+
rubygems_version: 3.1.2
|
109
109
|
signing_key:
|
110
110
|
specification_version: 4
|
111
111
|
summary: API for the Flipper gem
|