flipper-api 1.1.2 → 1.2.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/action.rb +2 -2
- data/lib/flipper/api.rb +2 -1
- data/lib/flipper/version.rb +11 -1
- data/spec/flipper/api/action_spec.rb +2 -2
- data/spec/flipper/api/v1/actions/features_spec.rb +55 -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: 58d461415a5ed29c22d0a6e086d849ff542d570b71538083ddc02fcc76d31b65
|
4
|
+
data.tar.gz: c21e1075bf3cb9d3c02fa0f592da7264eaa9600b80e48ec885797687771b0b57
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b5ebedf60b6cc27b02e9c494e263dae117eade08b8e5879c050730812ffc58681d88839e581cd97da011a4a3dc27553bddf0dd74b44c5789a8632146a06cec5
|
7
|
+
data.tar.gz: 5b4616c11300e5c9c0879c57aa630919a82a99b0e6200befc9c61e778c582b1fe5075784ddeb75c72749431ad34f56b05c2646c35343476b7c930036c53860d9
|
data/lib/flipper/api/action.rb
CHANGED
@@ -69,7 +69,7 @@ module Flipper
|
|
69
69
|
@flipper = flipper
|
70
70
|
@request = request
|
71
71
|
@code = 200
|
72
|
-
@headers = {
|
72
|
+
@headers = {Rack::CONTENT_TYPE => Api::CONTENT_TYPE}
|
73
73
|
end
|
74
74
|
|
75
75
|
# Public: Runs the request method for the provided request.
|
@@ -114,7 +114,7 @@ module Flipper
|
|
114
114
|
# status - http status code
|
115
115
|
|
116
116
|
def json_response(object, status = 200)
|
117
|
-
header
|
117
|
+
header Rack::CONTENT_TYPE, Api::CONTENT_TYPE
|
118
118
|
status(status)
|
119
119
|
body = Typecast.to_json(object)
|
120
120
|
halt [@code, @headers, [body]]
|
data/lib/flipper/api.rb
CHANGED
@@ -9,10 +9,11 @@ module Flipper
|
|
9
9
|
|
10
10
|
def self.app(flipper = nil, options = {})
|
11
11
|
env_key = options.fetch(:env_key, 'flipper')
|
12
|
-
app = ->(_) { [404, {
|
12
|
+
app = ->(_) { [404, { Rack::CONTENT_TYPE => CONTENT_TYPE }, ['{}'.freeze]] }
|
13
13
|
builder = Rack::Builder.new
|
14
14
|
yield builder if block_given?
|
15
15
|
builder.use Rack::Head
|
16
|
+
builder.use Rack::Deflater
|
16
17
|
builder.use Flipper::Api::JsonParams
|
17
18
|
builder.use Flipper::Middleware::SetupEnv, flipper, env_key: env_key
|
18
19
|
builder.use Flipper::Api::Middleware, env_key: env_key
|
data/lib/flipper/version.rb
CHANGED
@@ -1,3 +1,13 @@
|
|
1
1
|
module Flipper
|
2
|
-
VERSION = '1.1
|
2
|
+
VERSION = '1.2.1'.freeze
|
3
|
+
|
4
|
+
REQUIRED_RUBY_VERSION = '2.6'.freeze
|
5
|
+
NEXT_REQUIRED_RUBY_VERSION = '3.0'.freeze
|
6
|
+
|
7
|
+
REQUIRED_RAILS_VERSION = '5.2'.freeze
|
8
|
+
NEXT_REQUIRED_RAILS_VERSION = '6.1.0'.freeze
|
9
|
+
|
10
|
+
def self.deprecated_ruby_version?
|
11
|
+
Gem::Version.new(RUBY_VERSION) < Gem::Version.new(NEXT_REQUIRED_RUBY_VERSION)
|
12
|
+
end
|
3
13
|
end
|
@@ -77,7 +77,7 @@ RSpec.describe Flipper::Api::Action do
|
|
77
77
|
status, headers, body = response
|
78
78
|
parsed_body = JSON.parse(body[0])
|
79
79
|
|
80
|
-
expect(headers[
|
80
|
+
expect(headers[Rack::CONTENT_TYPE]).to eq('application/json')
|
81
81
|
expect(parsed_body).to eql(api_not_found_response)
|
82
82
|
end
|
83
83
|
end
|
@@ -91,7 +91,7 @@ RSpec.describe Flipper::Api::Action do
|
|
91
91
|
status, headers, body = response
|
92
92
|
parsed_body = JSON.parse(body[0])
|
93
93
|
|
94
|
-
expect(headers[
|
94
|
+
expect(headers[Rack::CONTENT_TYPE]).to eq('application/json')
|
95
95
|
expect(parsed_body['code']).to eq(2)
|
96
96
|
expect(parsed_body['message']).to eq('Group not registered.')
|
97
97
|
expect(parsed_body['more_info']).to eq(api_error_code_reference_url)
|
@@ -124,6 +124,61 @@ RSpec.describe Flipper::Api::V1::Actions::Features do
|
|
124
124
|
expect(json_response).to eq(expected_response)
|
125
125
|
end
|
126
126
|
end
|
127
|
+
|
128
|
+
context 'with accept encoding header set to gzip' do
|
129
|
+
before do
|
130
|
+
flipper[:my_feature].enable
|
131
|
+
flipper[:my_feature].enable(admin)
|
132
|
+
end
|
133
|
+
|
134
|
+
it 'responds with content encoding gzip and correct attributes' do
|
135
|
+
get '/features', {}, 'HTTP_ACCEPT_ENCODING' => 'gzip'
|
136
|
+
|
137
|
+
expected_response = {
|
138
|
+
'features' => [
|
139
|
+
{
|
140
|
+
'key' => 'my_feature',
|
141
|
+
'state' => 'on',
|
142
|
+
'gates' => [
|
143
|
+
{
|
144
|
+
'key' => 'boolean',
|
145
|
+
'name' => 'boolean',
|
146
|
+
'value' => 'true',
|
147
|
+
},
|
148
|
+
{
|
149
|
+
'key' => 'expression',
|
150
|
+
'name' => 'expression',
|
151
|
+
'value' => nil,
|
152
|
+
},
|
153
|
+
{
|
154
|
+
'key' => 'actors',
|
155
|
+
'name' => 'actor',
|
156
|
+
'value' => ['10'],
|
157
|
+
},
|
158
|
+
{
|
159
|
+
'key' => 'percentage_of_actors',
|
160
|
+
'name' => 'percentage_of_actors',
|
161
|
+
'value' => nil,
|
162
|
+
},
|
163
|
+
{
|
164
|
+
'key' => 'percentage_of_time',
|
165
|
+
'name' => 'percentage_of_time',
|
166
|
+
'value' => nil,
|
167
|
+
},
|
168
|
+
{
|
169
|
+
'key' => 'groups',
|
170
|
+
'name' => 'group',
|
171
|
+
'value' => [],
|
172
|
+
},
|
173
|
+
],
|
174
|
+
},
|
175
|
+
],
|
176
|
+
}
|
177
|
+
expect(last_response["content-encoding"]).to eq('gzip')
|
178
|
+
expect(last_response.status).to eq(200)
|
179
|
+
expect(json_response).to eq(expected_response)
|
180
|
+
end
|
181
|
+
end
|
127
182
|
end
|
128
183
|
|
129
184
|
describe 'post' do
|
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: 1.1
|
4
|
+
version: 1.2.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:
|
11
|
+
date: 2024-01-15 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: 1.1
|
39
|
+
version: 1.2.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: 1.1
|
46
|
+
version: 1.2.1
|
47
47
|
description:
|
48
48
|
email: support@flippercloud.io
|
49
49
|
executables: []
|
@@ -97,7 +97,7 @@ metadata:
|
|
97
97
|
homepage_uri: https://www.flippercloud.io
|
98
98
|
source_code_uri: https://github.com/flippercloud/flipper
|
99
99
|
bug_tracker_uri: https://github.com/flippercloud/flipper/issues
|
100
|
-
changelog_uri: https://github.com/flippercloud/flipper/
|
100
|
+
changelog_uri: https://github.com/flippercloud/flipper/releases/tag/v1.2.1
|
101
101
|
post_install_message:
|
102
102
|
rdoc_options: []
|
103
103
|
require_paths:
|
@@ -113,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
113
113
|
- !ruby/object:Gem::Version
|
114
114
|
version: '0'
|
115
115
|
requirements: []
|
116
|
-
rubygems_version: 3.
|
116
|
+
rubygems_version: 3.5.3
|
117
117
|
signing_key:
|
118
118
|
specification_version: 4
|
119
119
|
summary: Feature flag API for the Flipper gem
|