flipper-cloud 0.20.0.beta1 → 0.20.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/flipper/cloud/configuration.rb +6 -1
- data/lib/flipper/version.rb +1 -1
- data/spec/flipper/cloud/configuration_spec.rb +2 -2
- data/spec/flipper/cloud/dsl_spec.rb +43 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad733b77b848c6b7b0f1acbe1b9b6c95f87a71e0075dee518c3cfea654b46742
|
4
|
+
data.tar.gz: f030f6785ccd8482c660fd9f3e9ece0a81c4b5f455b8c8559ab39b6dc025d29e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 747bc35cfd3642780198a4219cf3b8d91b63aa008efaf445900763b1a8fc61229c4dae9da8affe2b0e607ee86bb1774b6a37abd1ab338c8766dca52baf5ba436
|
7
|
+
data.tar.gz: 3d4d1e9b03701f21719e132bcf11cc8d0b9f1d134fea56a14d19df95b9ea6c472eff0fc6daf87d4a9888741b950e3ba21d611b174959c6d707d83a316c77668d
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require "flipper/adapters/http"
|
2
2
|
require "flipper/adapters/memory"
|
3
|
+
require "flipper/adapters/dual_write"
|
3
4
|
require "flipper/adapters/sync"
|
4
5
|
|
5
6
|
module Flipper
|
@@ -129,7 +130,11 @@ module Flipper
|
|
129
130
|
private
|
130
131
|
|
131
132
|
def app_adapter
|
132
|
-
sync_method == :webhook ?
|
133
|
+
sync_method == :webhook ? dual_write_adapter : sync_adapter
|
134
|
+
end
|
135
|
+
|
136
|
+
def dual_write_adapter
|
137
|
+
Flipper::Adapters::DualWrite.new(local_adapter, http_adapter)
|
133
138
|
end
|
134
139
|
|
135
140
|
def sync_adapter
|
data/lib/flipper/version.rb
CHANGED
@@ -143,7 +143,7 @@ RSpec.describe Flipper::Cloud::Configuration do
|
|
143
143
|
}))
|
144
144
|
|
145
145
|
expect(instance.sync_method).to eq(:webhook)
|
146
|
-
expect(instance.adapter).to be_instance_of(Flipper::Adapters::
|
146
|
+
expect(instance.adapter).to be_instance_of(Flipper::Adapters::DualWrite)
|
147
147
|
end
|
148
148
|
|
149
149
|
it "raises ArgumentError for invalid sync_method" do
|
@@ -171,7 +171,7 @@ RSpec.describe Flipper::Cloud::Configuration do
|
|
171
171
|
}))
|
172
172
|
|
173
173
|
expect(instance.sync_method).to eq(:webhook)
|
174
|
-
expect(instance.adapter).to be_instance_of(Flipper::Adapters::
|
174
|
+
expect(instance.adapter).to be_instance_of(Flipper::Adapters::DualWrite)
|
175
175
|
end
|
176
176
|
|
177
177
|
it "can set sync_secret" do
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'helper'
|
2
2
|
require 'flipper/cloud/configuration'
|
3
3
|
require 'flipper/cloud/dsl'
|
4
|
+
require 'flipper/adapters/operation_logger'
|
4
5
|
require 'flipper/adapters/instrumented'
|
5
6
|
|
6
7
|
RSpec.describe Flipper::Cloud::DSL do
|
@@ -41,4 +42,46 @@ RSpec.describe Flipper::Cloud::DSL do
|
|
41
42
|
dsl = described_class.new(cloud_configuration)
|
42
43
|
expect(dsl.sync_secret).to eq("tasty")
|
43
44
|
end
|
45
|
+
|
46
|
+
context "when sync_method is webhook" do
|
47
|
+
let(:local_adapter) do
|
48
|
+
Flipper::Adapters::OperationLogger.new Flipper::Adapters::Memory.new
|
49
|
+
end
|
50
|
+
|
51
|
+
let(:cloud_configuration) do
|
52
|
+
cloud_configuration = Flipper::Cloud::Configuration.new({
|
53
|
+
token: "asdf",
|
54
|
+
sync_secret: "tasty",
|
55
|
+
sync_method: :webhook,
|
56
|
+
local_adapter: local_adapter
|
57
|
+
})
|
58
|
+
end
|
59
|
+
|
60
|
+
subject do
|
61
|
+
described_class.new(cloud_configuration)
|
62
|
+
end
|
63
|
+
|
64
|
+
it "sends reads to local adapter" do
|
65
|
+
subject.features
|
66
|
+
subject.enabled?(:foo)
|
67
|
+
expect(local_adapter.count(:features)).to be(1)
|
68
|
+
expect(local_adapter.count(:get)).to be(1)
|
69
|
+
end
|
70
|
+
|
71
|
+
it "sends writes to cloud and local" do
|
72
|
+
add_stub = stub_request(:post, "https://www.flippercloud.io/adapter/features").
|
73
|
+
with({headers: {'Flipper-Cloud-Token'=>'asdf'}}).
|
74
|
+
to_return(status: 200, body: '{}', headers: {})
|
75
|
+
enable_stub = stub_request(:post, "https://www.flippercloud.io/adapter/features/foo/boolean").
|
76
|
+
with(headers: {'Flipper-Cloud-Token'=>'asdf'}).
|
77
|
+
to_return(status: 200, body: '{}', headers: {})
|
78
|
+
|
79
|
+
subject.enable(:foo)
|
80
|
+
|
81
|
+
expect(local_adapter.count(:add)).to be(1)
|
82
|
+
expect(local_adapter.count(:enable)).to be(1)
|
83
|
+
expect(add_stub).to have_been_requested
|
84
|
+
expect(enable_stub).to have_been_requested
|
85
|
+
end
|
86
|
+
end
|
44
87
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flipper-cloud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.20.0.
|
4
|
+
version: 0.20.0.beta2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Nunemaker
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-12-
|
11
|
+
date: 2020-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: flipper
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.20.0.
|
19
|
+
version: 0.20.0.beta2
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.20.0.
|
26
|
+
version: 0.20.0.beta2
|
27
27
|
description:
|
28
28
|
email:
|
29
29
|
- nunemaker@gmail.com
|