flipper-ui 1.4.1 → 1.5.0.rc1
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 +4 -4
- data/lib/flipper/ui/action.rb +46 -35
- data/lib/flipper/ui/actions/actors_gate.rb +17 -3
- data/lib/flipper/ui/actions/cloud_migrate.rb +1 -0
- data/lib/flipper/ui/actions/features.rb +5 -1
- data/lib/flipper/ui/actions/groups_gate.rb +6 -1
- data/lib/flipper/ui/actions/import.rb +21 -2
- data/lib/flipper/ui/actions/percentage_of_actors_gate.rb +2 -0
- data/lib/flipper/ui/actions/percentage_of_time_gate.rb +2 -0
- data/lib/flipper/ui/configuration.rb +12 -1
- data/lib/flipper/ui/decorators/feature.rb +6 -12
- data/lib/flipper/ui/error.rb +2 -2
- data/lib/flipper/ui/middleware.rb +10 -0
- data/lib/flipper/ui/public/images/logo.png +0 -0
- data/lib/flipper/ui/util.rb +5 -4
- data/lib/flipper/ui/views/feature.erb +8 -0
- data/lib/flipper/ui/views/layout.erb +15 -7
- data/lib/flipper/ui/views/settings.erb +23 -18
- data/lib/flipper/ui.rb +4 -1
- data/lib/flipper/version.rb +1 -1
- metadata +5 -32
- data/examples/ui/authorization.ru +0 -48
- data/examples/ui/basic.ru +0 -71
- data/examples/ui/prefixed.ru +0 -21
- data/examples/ui/read_only.ru +0 -43
- data/flipper-ui.gemspec +0 -29
- data/lib/flipper/ui/decorators/gate.rb +0 -37
- data/lib/flipper/ui/public/js/jquery-3.6.0.slim.js +0 -8782
- data/spec/flipper/ui/action_spec.rb +0 -76
- data/spec/flipper/ui/actions/actors_gate_spec.rb +0 -201
- data/spec/flipper/ui/actions/add_feature_spec.rb +0 -57
- data/spec/flipper/ui/actions/boolean_gate_spec.rb +0 -139
- data/spec/flipper/ui/actions/cloud_migrate_spec.rb +0 -54
- data/spec/flipper/ui/actions/export_spec.rb +0 -51
- data/spec/flipper/ui/actions/feature_spec.rb +0 -254
- data/spec/flipper/ui/actions/features_spec.rb +0 -233
- data/spec/flipper/ui/actions/file_spec.rb +0 -21
- data/spec/flipper/ui/actions/groups_gate_spec.rb +0 -144
- data/spec/flipper/ui/actions/home_spec.rb +0 -14
- data/spec/flipper/ui/actions/import_spec.rb +0 -41
- data/spec/flipper/ui/actions/percentage_of_actors_gate_spec.rb +0 -65
- data/spec/flipper/ui/actions/percentage_of_time_gate_spec.rb +0 -65
- data/spec/flipper/ui/actions/settings_spec.rb +0 -35
- data/spec/flipper/ui/configuration_spec.rb +0 -218
- data/spec/flipper/ui/decorators/feature_spec.rb +0 -59
- data/spec/flipper/ui/decorators/gate_spec.rb +0 -45
- data/spec/flipper/ui/util_spec.rb +0 -17
- data/spec/flipper/ui_spec.rb +0 -197
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
RSpec.describe Flipper::UI::Actions::Import do
|
|
2
|
-
let(:token) do
|
|
3
|
-
if Rack::Protection::AuthenticityToken.respond_to?(:random_token)
|
|
4
|
-
Rack::Protection::AuthenticityToken.random_token
|
|
5
|
-
else
|
|
6
|
-
'a'
|
|
7
|
-
end
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
let(:session) do
|
|
11
|
-
{ :csrf => token, 'csrf' => token, '_csrf_token' => token }
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
describe "POST /settings/import" do
|
|
15
|
-
before do
|
|
16
|
-
flipper.enable :plausible
|
|
17
|
-
flipper.disable :google_analytics
|
|
18
|
-
path = FlipperRoot.join("spec", "fixtures", "flipper_pstore_1679087600.json")
|
|
19
|
-
|
|
20
|
-
post '/settings/import',
|
|
21
|
-
{
|
|
22
|
-
'authenticity_token' => token,
|
|
23
|
-
'file' => Rack::Test::UploadedFile.new(path, "application/json"),
|
|
24
|
-
},
|
|
25
|
-
'rack.session' => session
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
it 'imports the file export' do
|
|
29
|
-
expect(flipper[:search].actors_value).to eq(Set.new(['john', 'another', 'testing']))
|
|
30
|
-
expect(flipper[:search].groups_value).to eq(Set.new(['admins']))
|
|
31
|
-
expect(flipper[:google_analytics_tag].percentage_of_actors_value).to eq(100)
|
|
32
|
-
expect(flipper[:new_pricing].boolean_value).to eq(true)
|
|
33
|
-
expect(flipper[:nope].boolean_value).to eq(false)
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
it 'responds with redirect to settings' do
|
|
37
|
-
expect(last_response.status).to be(302)
|
|
38
|
-
expect(last_response.headers['location']).to eq('/features')
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
RSpec.describe Flipper::UI::Actions::PercentageOfActorsGate do
|
|
2
|
-
let(:token) do
|
|
3
|
-
if Rack::Protection::AuthenticityToken.respond_to?(:random_token)
|
|
4
|
-
Rack::Protection::AuthenticityToken.random_token
|
|
5
|
-
else
|
|
6
|
-
'a'
|
|
7
|
-
end
|
|
8
|
-
end
|
|
9
|
-
let(:session) do
|
|
10
|
-
{ :csrf => token, 'csrf' => token, '_csrf_token' => token }
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
describe 'POST /features/:feature/percentage_of_actors' do
|
|
14
|
-
context 'with valid value' do
|
|
15
|
-
before do
|
|
16
|
-
post 'features/search/percentage_of_actors',
|
|
17
|
-
{ 'value' => '24', 'authenticity_token' => token },
|
|
18
|
-
'rack.session' => session
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
it 'enables the feature' do
|
|
22
|
-
expect(flipper[:search].percentage_of_actors_value).to be(24)
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
it 'redirects back to feature' do
|
|
26
|
-
expect(last_response.status).to be(302)
|
|
27
|
-
expect(last_response.headers['location']).to eq('/features/search')
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
context 'with space in feature name' do
|
|
32
|
-
before do
|
|
33
|
-
post 'features/sp+ace/percentage_of_actors',
|
|
34
|
-
{ 'value' => '24', 'authenticity_token' => token },
|
|
35
|
-
'rack.session' => session
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
it 'enables the feature' do
|
|
39
|
-
expect(flipper["sp ace"].percentage_of_actors_value).to be(24)
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
it 'redirects back to feature' do
|
|
43
|
-
expect(last_response.status).to be(302)
|
|
44
|
-
expect(last_response.headers['location']).to eq('/features/sp+ace')
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
context 'with invalid value' do
|
|
49
|
-
before do
|
|
50
|
-
post 'features/search/percentage_of_actors',
|
|
51
|
-
{ 'value' => '555', 'authenticity_token' => token },
|
|
52
|
-
'rack.session' => session
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
it 'does not change value' do
|
|
56
|
-
expect(flipper[:search].percentage_of_actors_value).to be(0)
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
it 'redirects back to feature' do
|
|
60
|
-
expect(last_response.status).to be(302)
|
|
61
|
-
expect(last_response.headers['location']).to eq('/features/search?error=Invalid+percentage+of+actors+value%3A+value+must+be+a+positive+number+less+than+or+equal+to+100%2C+but+was+555')
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
end
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
RSpec.describe Flipper::UI::Actions::PercentageOfTimeGate do
|
|
2
|
-
let(:token) do
|
|
3
|
-
if Rack::Protection::AuthenticityToken.respond_to?(:random_token)
|
|
4
|
-
Rack::Protection::AuthenticityToken.random_token
|
|
5
|
-
else
|
|
6
|
-
'a'
|
|
7
|
-
end
|
|
8
|
-
end
|
|
9
|
-
let(:session) do
|
|
10
|
-
{ :csrf => token, 'csrf' => token, '_csrf_token' => token }
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
describe 'POST /features/:feature/percentage_of_time' do
|
|
14
|
-
context 'with valid value' do
|
|
15
|
-
before do
|
|
16
|
-
post 'features/search/percentage_of_time',
|
|
17
|
-
{ 'value' => '24', 'authenticity_token' => token },
|
|
18
|
-
'rack.session' => session
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
it 'enables the feature' do
|
|
22
|
-
expect(flipper[:search].percentage_of_time_value).to be(24)
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
it 'redirects back to feature' do
|
|
26
|
-
expect(last_response.status).to be(302)
|
|
27
|
-
expect(last_response.headers['location']).to eq('/features/search')
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
context 'with space in feature name' do
|
|
32
|
-
before do
|
|
33
|
-
post 'features/sp+ace/percentage_of_time',
|
|
34
|
-
{ 'value' => '24', 'authenticity_token' => token },
|
|
35
|
-
'rack.session' => session
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
it 'enables the feature' do
|
|
39
|
-
expect(flipper["sp ace"].percentage_of_time_value).to be(24)
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
it 'redirects back to feature' do
|
|
43
|
-
expect(last_response.status).to be(302)
|
|
44
|
-
expect(last_response.headers['location']).to eq('/features/sp+ace')
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
context 'with invalid value' do
|
|
49
|
-
before do
|
|
50
|
-
post 'features/search/percentage_of_time',
|
|
51
|
-
{ 'value' => '555', 'authenticity_token' => token },
|
|
52
|
-
'rack.session' => session
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
it 'does not change value' do
|
|
56
|
-
expect(flipper[:search].percentage_of_time_value).to be(0)
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
it 'redirects back to feature' do
|
|
60
|
-
expect(last_response.status).to be(302)
|
|
61
|
-
expect(last_response.headers['location']).to eq('/features/search?error=Invalid+percentage+of+time+value%3A+value+must+be+a+positive+number+less+than+or+equal+to+100%2C+but+was+555')
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
end
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
RSpec.describe Flipper::UI::Actions::Settings do
|
|
2
|
-
let(:token) do
|
|
3
|
-
if Rack::Protection::AuthenticityToken.respond_to?(:random_token)
|
|
4
|
-
Rack::Protection::AuthenticityToken.random_token
|
|
5
|
-
else
|
|
6
|
-
'a'
|
|
7
|
-
end
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
let(:session) do
|
|
11
|
-
{ :csrf => token, 'csrf' => token, '_csrf_token' => token }
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
describe 'GET /settings' do
|
|
15
|
-
before do
|
|
16
|
-
get '/settings'
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
it 'responds with success' do
|
|
20
|
-
expect(last_response.status).to be(200)
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
it 'renders template' do
|
|
24
|
-
expect(last_response.body).to include('Download')
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
it 'includes migrate to Flipper Cloud card' do
|
|
28
|
-
expect(last_response.body).to include('Migrate to Flipper Cloud')
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
it 'shows feature count' do
|
|
32
|
-
expect(last_response.body).to include('features ready to migrate')
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
end
|
|
@@ -1,218 +0,0 @@
|
|
|
1
|
-
RSpec.describe Flipper::UI::Configuration do
|
|
2
|
-
let(:configuration) { described_class.new }
|
|
3
|
-
|
|
4
|
-
describe "#delete" do
|
|
5
|
-
it "has default text" do
|
|
6
|
-
expect(configuration.delete.title).to eq("Danger Zone")
|
|
7
|
-
expect(configuration.delete.description).to eq("Deleting a feature removes it from the list of features and disables it for everyone.")
|
|
8
|
-
end
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
describe "#banner_text" do
|
|
12
|
-
it "has no default" do
|
|
13
|
-
expect(configuration.banner_text).to eq(nil)
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
it "can be updated" do
|
|
17
|
-
configuration.banner_text = 'Production Environment'
|
|
18
|
-
expect(configuration.banner_text).to eq('Production Environment')
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
describe "#banner_class" do
|
|
23
|
-
it "has default color" do
|
|
24
|
-
expect(configuration.banner_class).to eq('danger')
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
it "can be updated" do
|
|
28
|
-
configuration.banner_class = 'info'
|
|
29
|
-
expect(configuration.banner_class).to eq('info')
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
it "raises if set to invalid value" do
|
|
33
|
-
expect { configuration.banner_class = :invalid_class }
|
|
34
|
-
.to raise_error(Flipper::InvalidConfigurationValue)
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
describe "#application_href" do
|
|
39
|
-
it "has default value" do
|
|
40
|
-
expect(configuration.application_href).to eq(nil)
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
it "can be updated" do
|
|
44
|
-
configuration.application_href = 'http://www.myapp.com'
|
|
45
|
-
expect(configuration.application_href).to eq('http://www.myapp.com')
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
it 'aliases application_breadcrumb_href to application_href' do
|
|
49
|
-
configuration.application_breadcrumb_href = "/myapp"
|
|
50
|
-
expect(configuration.application_href).to eq("/myapp")
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
describe "#feature_creation_enabled" do
|
|
55
|
-
it "has default value" do
|
|
56
|
-
expect(configuration.feature_creation_enabled).to eq(true)
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
it "can be updated" do
|
|
60
|
-
configuration.feature_creation_enabled = false
|
|
61
|
-
expect(configuration.feature_creation_enabled).to eq(false)
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
describe "#cloud_recommendation" do
|
|
66
|
-
it "has default value" do
|
|
67
|
-
expect(configuration.cloud_recommendation).to eq(true)
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
it "can be updated" do
|
|
71
|
-
configuration.cloud_recommendation = false
|
|
72
|
-
expect(configuration.cloud_recommendation).to eq(false)
|
|
73
|
-
end
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
describe "#feature_removal_enabled" do
|
|
77
|
-
it "has default value" do
|
|
78
|
-
expect(configuration.feature_removal_enabled).to eq(true)
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
it "can be updated" do
|
|
82
|
-
configuration.feature_removal_enabled = false
|
|
83
|
-
expect(configuration.feature_removal_enabled).to eq(false)
|
|
84
|
-
end
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
describe "#fun" do
|
|
88
|
-
it "has default value" do
|
|
89
|
-
expect(configuration.fun).to eq(true)
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
it "can be updated" do
|
|
93
|
-
configuration.fun = false
|
|
94
|
-
expect(configuration.fun).to eq(false)
|
|
95
|
-
end
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
describe "#descriptions_source" do
|
|
99
|
-
it "has default value" do
|
|
100
|
-
expect(configuration.descriptions_source.call(%w[foo bar])).to eq({})
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
context "descriptions source is provided" do
|
|
104
|
-
it "can be updated" do
|
|
105
|
-
configuration.descriptions_source = lambda do |_keys|
|
|
106
|
-
YAML.load_file(FlipperRoot.join('spec/support/descriptions.yml'))
|
|
107
|
-
end
|
|
108
|
-
keys = %w[some_awesome_feature foo]
|
|
109
|
-
result = configuration.descriptions_source.call(keys)
|
|
110
|
-
expected = {
|
|
111
|
-
"some_awesome_feature" => "Awesome feature description",
|
|
112
|
-
}
|
|
113
|
-
expect(result).to eq(expected)
|
|
114
|
-
end
|
|
115
|
-
end
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
describe "#actor_names_source" do
|
|
119
|
-
it "has default value" do
|
|
120
|
-
expect(configuration.actor_names_source.call(%w[foo bar])).to eq({})
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
context "actor names source is provided" do
|
|
124
|
-
it "can be updated" do
|
|
125
|
-
configuration.actor_names_source = lambda do |_keys|
|
|
126
|
-
YAML.load_file(FlipperRoot.join('spec/support/actor_names.yml'))
|
|
127
|
-
end
|
|
128
|
-
keys = %w[actor_1 foo]
|
|
129
|
-
result = configuration.actor_names_source.call(keys)
|
|
130
|
-
expected = {
|
|
131
|
-
"actor_name_1" => "Actor #1",
|
|
132
|
-
}
|
|
133
|
-
expect(result).to eq(expected)
|
|
134
|
-
end
|
|
135
|
-
end
|
|
136
|
-
end
|
|
137
|
-
|
|
138
|
-
describe "#confirm_fully_enable" do
|
|
139
|
-
it "has default value" do
|
|
140
|
-
expect(configuration.confirm_fully_enable).to eq(false)
|
|
141
|
-
end
|
|
142
|
-
|
|
143
|
-
it "can be updated" do
|
|
144
|
-
configuration.confirm_fully_enable = true
|
|
145
|
-
expect(configuration.confirm_fully_enable).to eq(true)
|
|
146
|
-
end
|
|
147
|
-
end
|
|
148
|
-
|
|
149
|
-
describe "#disable_fully_enable" do
|
|
150
|
-
it "defaults to nil" do
|
|
151
|
-
expect(configuration.disable_fully_enable).to be_nil
|
|
152
|
-
end
|
|
153
|
-
|
|
154
|
-
it "can be set to true" do
|
|
155
|
-
configuration.disable_fully_enable = true
|
|
156
|
-
expect(configuration.disable_fully_enable).to eq(true)
|
|
157
|
-
end
|
|
158
|
-
|
|
159
|
-
it "can be set to false" do
|
|
160
|
-
configuration.disable_fully_enable = false
|
|
161
|
-
expect(configuration.disable_fully_enable).to eq(false)
|
|
162
|
-
end
|
|
163
|
-
|
|
164
|
-
it "can be set to a custom message" do
|
|
165
|
-
configuration.disable_fully_enable = "Use deploy pipeline instead."
|
|
166
|
-
expect(configuration.disable_fully_enable).to eq("Use deploy pipeline instead.")
|
|
167
|
-
end
|
|
168
|
-
end
|
|
169
|
-
|
|
170
|
-
describe "#disable_fully_enable_message" do
|
|
171
|
-
it "returns default message when set to true" do
|
|
172
|
-
configuration.disable_fully_enable = true
|
|
173
|
-
expect(configuration.disable_fully_enable_message).to eq("Fully enabling features via the UI is disabled.")
|
|
174
|
-
end
|
|
175
|
-
|
|
176
|
-
it "returns custom message when set to a string" do
|
|
177
|
-
configuration.disable_fully_enable = "Use deploy pipeline instead."
|
|
178
|
-
expect(configuration.disable_fully_enable_message).to eq("Use deploy pipeline instead.")
|
|
179
|
-
end
|
|
180
|
-
end
|
|
181
|
-
|
|
182
|
-
describe "#show_feature_description_in_list" do
|
|
183
|
-
it "has default value" do
|
|
184
|
-
expect(configuration.show_feature_description_in_list).to eq(false)
|
|
185
|
-
end
|
|
186
|
-
|
|
187
|
-
it "can be updated" do
|
|
188
|
-
configuration.show_feature_description_in_list = true
|
|
189
|
-
expect(configuration.show_feature_description_in_list).to eq(true)
|
|
190
|
-
end
|
|
191
|
-
end
|
|
192
|
-
|
|
193
|
-
describe "#show_feature_description_in_list?" do
|
|
194
|
-
subject { configuration.show_feature_description_in_list? }
|
|
195
|
-
|
|
196
|
-
context 'when using_descriptions? is false and show_feature_description_in_list is false' do
|
|
197
|
-
it { is_expected.to eq(false) }
|
|
198
|
-
end
|
|
199
|
-
|
|
200
|
-
context 'when using_descriptions? is false and show_feature_description_in_list is true' do
|
|
201
|
-
before { configuration.show_feature_description_in_list = true }
|
|
202
|
-
it { is_expected.to eq(false) }
|
|
203
|
-
end
|
|
204
|
-
|
|
205
|
-
context 'when using_descriptions? is true and show_feature_description_in_list is false' do
|
|
206
|
-
before { allow(configuration).to receive(:using_descriptions?).and_return(true) }
|
|
207
|
-
it { is_expected.to eq(false) }
|
|
208
|
-
end
|
|
209
|
-
|
|
210
|
-
context 'when using_descriptions? is true and show_feature_description_in_list is true' do
|
|
211
|
-
before do
|
|
212
|
-
allow(configuration).to receive(:using_descriptions?).and_return(true)
|
|
213
|
-
configuration.show_feature_description_in_list = true
|
|
214
|
-
end
|
|
215
|
-
it { is_expected.to eq(true) }
|
|
216
|
-
end
|
|
217
|
-
end
|
|
218
|
-
end
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
RSpec.describe Flipper::UI::Decorators::Feature do
|
|
2
|
-
let(:source) { {} }
|
|
3
|
-
let(:adapter) { Flipper::Adapters::Memory.new(source) }
|
|
4
|
-
let(:flipper) { build_flipper }
|
|
5
|
-
let(:feature) { flipper[:some_awesome_feature] }
|
|
6
|
-
|
|
7
|
-
subject do
|
|
8
|
-
described_class.new(feature)
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
describe '#initialize' do
|
|
12
|
-
it 'sets the feature' do
|
|
13
|
-
expect(subject.feature).to be(feature)
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
describe '#pretty_name' do
|
|
18
|
-
it 'capitalizes each word separated by underscores' do
|
|
19
|
-
expect(subject.pretty_name).to eq('Some Awesome Feature')
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
describe '#<=>' do
|
|
24
|
-
let(:on) do
|
|
25
|
-
flipper.enable(:on_a)
|
|
26
|
-
described_class.new(flipper[:on_a])
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
let(:on_b) do
|
|
30
|
-
flipper.enable(:on_b)
|
|
31
|
-
described_class.new(flipper[:on_b])
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
let(:conditional) do
|
|
35
|
-
flipper.enable_percentage_of_time :conditional_a, 5
|
|
36
|
-
described_class.new(flipper[:conditional_a])
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
let(:off) do
|
|
40
|
-
described_class.new(flipper[:off_a])
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
it 'sorts :on before :conditional' do
|
|
44
|
-
expect((on <=> conditional)).to be(-1)
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
it 'sorts :on before :off' do
|
|
48
|
-
expect((on <=> off)).to be(-1)
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
it 'sorts :conditional before :off' do
|
|
52
|
-
expect((conditional <=> off)).to be(-1)
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
it 'sorts on key for identical states' do
|
|
56
|
-
expect((on <=> on_b)).to be(-1)
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
end
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
require 'flipper/ui/decorators/gate'
|
|
2
|
-
|
|
3
|
-
RSpec.describe Flipper::UI::Decorators::Gate do
|
|
4
|
-
let(:source) { {} }
|
|
5
|
-
let(:adapter) { Flipper::Adapters::Memory.new(source) }
|
|
6
|
-
let(:flipper) { build_flipper }
|
|
7
|
-
let(:feature) { flipper[:some_awesome_feature] }
|
|
8
|
-
let(:gate) { feature.gate(:boolean) }
|
|
9
|
-
|
|
10
|
-
subject do
|
|
11
|
-
described_class.new(gate, false)
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
describe '#initialize' do
|
|
15
|
-
it 'sets gate' do
|
|
16
|
-
expect(subject.gate).to be(gate)
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
it 'sets value' do
|
|
20
|
-
expect(subject.value).to eq(false)
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
describe '#as_json' do
|
|
25
|
-
before do
|
|
26
|
-
@result = subject.as_json
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
it 'returns Hash' do
|
|
30
|
-
expect(@result).to be_instance_of(Hash)
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
it 'includes key' do
|
|
34
|
-
expect(@result['key']).to eq('boolean')
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
it 'includes pretty name' do
|
|
38
|
-
expect(@result['name']).to eq('boolean')
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
it 'includes value' do
|
|
42
|
-
expect(@result['value']).to be(false)
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
end
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
require 'flipper/ui/util'
|
|
2
|
-
|
|
3
|
-
RSpec.describe Flipper::UI::Util do
|
|
4
|
-
describe '#blank?' do
|
|
5
|
-
context 'with a string' do
|
|
6
|
-
it 'returns true if blank' do
|
|
7
|
-
expect(described_class.blank?(nil)).to be(true)
|
|
8
|
-
expect(described_class.blank?('')).to be(true)
|
|
9
|
-
expect(described_class.blank?(' ')).to be(true)
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
it 'returns false if not blank' do
|
|
13
|
-
expect(described_class.blank?('nope')).to be(false)
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|