flipper-api 1.1.2 → 1.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0e764464bc82c688cc50886d3e024accf9efe92a9d7dbe9349f4edc8093a5992
4
- data.tar.gz: 7a50ef3fee61b475e2e34d4d1f5e0db5c608d8c10991dedf7f0a44a4e9271ea5
3
+ metadata.gz: 58d461415a5ed29c22d0a6e086d849ff542d570b71538083ddc02fcc76d31b65
4
+ data.tar.gz: c21e1075bf3cb9d3c02fa0f592da7264eaa9600b80e48ec885797687771b0b57
5
5
  SHA512:
6
- metadata.gz: e13c317157c86c5f8c9fac1afd3fa0f55b37f08c634d262203a45d55ead0dd6028a2b1724738a0f27b29e4980d08abab877bbb038c506d411ef21566287a784c
7
- data.tar.gz: db19377ccb1a49291f7231dd9163c36da537e47d83c1624abae9b40de300161da4f667904ca9f21b65eb15fdb51e977308fcb44f034cdb25de35312ccc045907
6
+ metadata.gz: 6b5ebedf60b6cc27b02e9c494e263dae117eade08b8e5879c050730812ffc58681d88839e581cd97da011a4a3dc27553bddf0dd74b44c5789a8632146a06cec5
7
+ data.tar.gz: 5b4616c11300e5c9c0879c57aa630919a82a99b0e6200befc9c61e778c582b1fe5075784ddeb75c72749431ad34f56b05c2646c35343476b7c930036c53860d9
@@ -69,7 +69,7 @@ module Flipper
69
69
  @flipper = flipper
70
70
  @request = request
71
71
  @code = 200
72
- @headers = { 'content-type' => Api::CONTENT_TYPE }
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 'content-type', Api::CONTENT_TYPE
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, { 'content-type'.freeze => CONTENT_TYPE }, ['{}'.freeze]] }
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
@@ -1,3 +1,13 @@
1
1
  module Flipper
2
- VERSION = '1.1.2'.freeze
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['content-type']).to eq('application/json')
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['content-type']).to eq('application/json')
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.2
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: 2023-12-12 00:00:00.000000000 Z
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.2
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.2
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/blob/main/Changelog.md
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.4.10
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