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,254 +0,0 @@
|
|
|
1
|
-
RSpec.describe Flipper::UI::Actions::Feature 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 'DELETE /features/:feature' do
|
|
14
|
-
before do
|
|
15
|
-
flipper.enable :search
|
|
16
|
-
delete '/features/search',
|
|
17
|
-
{ 'authenticity_token' => token },
|
|
18
|
-
'rack.session' => session
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
it 'removes feature' do
|
|
22
|
-
expect(flipper.features.map(&:key)).not_to include('search')
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
it 'redirects to features' do
|
|
26
|
-
expect(last_response.status).to be(302)
|
|
27
|
-
expect(last_response.headers['location']).to eq('/features')
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
context "with space in feature name" do
|
|
31
|
-
before do
|
|
32
|
-
flipper.enable "sp ace"
|
|
33
|
-
delete '/features/sp%20ace',
|
|
34
|
-
{ 'authenticity_token' => token },
|
|
35
|
-
'rack.session' => session
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
it 'removes feature' do
|
|
39
|
-
expect(flipper.features.map(&:key)).not_to include('sp ace')
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
it 'redirects to features' do
|
|
43
|
-
expect(last_response.status).to be(302)
|
|
44
|
-
expect(last_response.headers['location']).to eq('/features')
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
context 'when feature_removal_enabled is set to false' do
|
|
49
|
-
around do |example|
|
|
50
|
-
begin
|
|
51
|
-
@original_feature_removal_enabled = Flipper::UI.configuration.feature_removal_enabled
|
|
52
|
-
Flipper::UI.configuration.feature_removal_enabled = false
|
|
53
|
-
example.run
|
|
54
|
-
ensure
|
|
55
|
-
Flipper::UI.configuration.feature_removal_enabled = @original_feature_removal_enabled
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
it 'returns with 403 status' do
|
|
60
|
-
expect(last_response.status).to be(403)
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
it 'renders feature removal disabled template' do
|
|
64
|
-
expect(last_response.body).to include('Feature removal from the UI is disabled')
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
describe 'POST /features/:feature with _method=DELETE' do
|
|
70
|
-
before do
|
|
71
|
-
flipper.enable :search
|
|
72
|
-
post '/features/search',
|
|
73
|
-
{ '_method' => 'DELETE', 'authenticity_token' => token },
|
|
74
|
-
'rack.session' => session
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
it 'removes feature' do
|
|
78
|
-
expect(flipper.features.map(&:key)).not_to include('search')
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
it 'redirects to features' do
|
|
82
|
-
expect(last_response.status).to be(302)
|
|
83
|
-
expect(last_response.headers['location']).to eq('/features')
|
|
84
|
-
end
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
describe 'GET /features/:feature' do
|
|
88
|
-
before do
|
|
89
|
-
Flipper::UI.configure do |config|
|
|
90
|
-
config.descriptions_source = lambda { |_keys|
|
|
91
|
-
{
|
|
92
|
-
"stats" => "Most awesome stats",
|
|
93
|
-
"search" => "Most in-depth search",
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
get '/features/search'
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
it 'responds with success' do
|
|
102
|
-
expect(last_response.status).to be(200)
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
it 'renders template' do
|
|
106
|
-
expect(last_response.body).to include('search')
|
|
107
|
-
expect(last_response.body).to include('Enable')
|
|
108
|
-
expect(last_response.body).to include('Disable')
|
|
109
|
-
expect(last_response.body).to include('No actors enabled')
|
|
110
|
-
expect(last_response.body).to include('No groups enabled')
|
|
111
|
-
expect(last_response.body).to include('Enabled for 0% of time')
|
|
112
|
-
expect(last_response.body).to include('Enabled for 0% of actors')
|
|
113
|
-
expect(last_response.body).to include('Most in-depth search')
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
context "when in read-only mode" do
|
|
117
|
-
before do
|
|
118
|
-
allow(flipper).to receive(:read_only?) { true }
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
before { get '/features' }
|
|
122
|
-
|
|
123
|
-
it 'renders template with no buttons or ways to modify a feature' do
|
|
124
|
-
expect(last_response.body).not_to include("Fully Enable")
|
|
125
|
-
end
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
context "when disable_fully_enable is true" do
|
|
129
|
-
before { Flipper::UI.configuration.disable_fully_enable = true }
|
|
130
|
-
after { Flipper::UI.configuration.disable_fully_enable = nil }
|
|
131
|
-
|
|
132
|
-
it 'renders the Fully Enable button as disabled' do
|
|
133
|
-
get '/features/search'
|
|
134
|
-
expect(last_response.body).to include('Fully Enable')
|
|
135
|
-
expect(last_response.body).to match(/disabled\s*>/)
|
|
136
|
-
end
|
|
137
|
-
|
|
138
|
-
it 'shows the default disabled tooltip' do
|
|
139
|
-
get '/features/search'
|
|
140
|
-
expect(last_response.body).to include('Fully enabling features via the UI is disabled.')
|
|
141
|
-
end
|
|
142
|
-
end
|
|
143
|
-
|
|
144
|
-
context "when disable_fully_enable is a custom message" do
|
|
145
|
-
before { Flipper::UI.configuration.disable_fully_enable = "Use deploy pipeline instead." }
|
|
146
|
-
after { Flipper::UI.configuration.disable_fully_enable = nil }
|
|
147
|
-
|
|
148
|
-
it 'shows custom disabled tooltip' do
|
|
149
|
-
get '/features/search'
|
|
150
|
-
expect(last_response.body).to include('Use deploy pipeline instead.')
|
|
151
|
-
end
|
|
152
|
-
end
|
|
153
|
-
|
|
154
|
-
context 'custom actor names' do
|
|
155
|
-
before do
|
|
156
|
-
actor = Flipper::Actor.new('some_actor_name')
|
|
157
|
-
flipper['search'].enable_actor(actor)
|
|
158
|
-
|
|
159
|
-
Flipper::UI.configure do |config|
|
|
160
|
-
config.actor_names_source = lambda { |_keys|
|
|
161
|
-
{
|
|
162
|
-
"some_actor_name" => "Some Actor Name",
|
|
163
|
-
"some_other_actor_name" => "Some Other Actor Name",
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
end
|
|
167
|
-
end
|
|
168
|
-
|
|
169
|
-
it 'renders template with custom actor names' do
|
|
170
|
-
get '/features/search'
|
|
171
|
-
expect(last_response.body).to include('Some Actor Name (some_actor_name)')
|
|
172
|
-
expect(last_response.body).not_to include('Some Other Actor Name')
|
|
173
|
-
end
|
|
174
|
-
|
|
175
|
-
it 'allows basic html' do
|
|
176
|
-
Flipper::UI.configure do |config|
|
|
177
|
-
config.actor_names_source = lambda { |_keys|
|
|
178
|
-
{ "some_actor_name" => '<a href="/users/some_actor_name">Some Actor Name</a>', }
|
|
179
|
-
}
|
|
180
|
-
end
|
|
181
|
-
|
|
182
|
-
get '/features/search'
|
|
183
|
-
expect(last_response.body).to include('<a href="/users/some_actor_name" rel="nofollow">Some Actor Name</a>')
|
|
184
|
-
end
|
|
185
|
-
|
|
186
|
-
it 'sanitizes dangerous markup' do
|
|
187
|
-
Flipper::UI.configure do |config|
|
|
188
|
-
config.actor_names_source = lambda { |_keys|
|
|
189
|
-
{ "some_actor_name" => '<a href="javascript:alert(\'hello\')">Some Actor Name</a>', }
|
|
190
|
-
}
|
|
191
|
-
end
|
|
192
|
-
|
|
193
|
-
get '/features/search'
|
|
194
|
-
expect(last_response.body).not_to include('javascript:alert')
|
|
195
|
-
end
|
|
196
|
-
end
|
|
197
|
-
end
|
|
198
|
-
|
|
199
|
-
describe 'GET /features/:feature with _features in feature name' do
|
|
200
|
-
before do
|
|
201
|
-
get '/features/search_features'
|
|
202
|
-
end
|
|
203
|
-
|
|
204
|
-
it 'responds with success' do
|
|
205
|
-
expect(last_response.status).to be(200)
|
|
206
|
-
end
|
|
207
|
-
|
|
208
|
-
it 'renders template' do
|
|
209
|
-
expect(last_response.body).to include('search_features')
|
|
210
|
-
end
|
|
211
|
-
end
|
|
212
|
-
|
|
213
|
-
describe 'GET /features/:feature with slash in feature name' do
|
|
214
|
-
before do
|
|
215
|
-
get '/features/a/b'
|
|
216
|
-
end
|
|
217
|
-
|
|
218
|
-
it 'responds with success' do
|
|
219
|
-
expect(last_response.status).to be(200)
|
|
220
|
-
end
|
|
221
|
-
|
|
222
|
-
it 'renders template' do
|
|
223
|
-
expect(last_response.body).to include('a/b')
|
|
224
|
-
end
|
|
225
|
-
end
|
|
226
|
-
|
|
227
|
-
describe 'GET /features/:feature with dot dot slash repeated in feature name' do
|
|
228
|
-
before do
|
|
229
|
-
get '/features/..%2F..%2F..%2F..%2Fblah'
|
|
230
|
-
end
|
|
231
|
-
|
|
232
|
-
it 'responds with success' do
|
|
233
|
-
expect(last_response.status).to be(200)
|
|
234
|
-
end
|
|
235
|
-
|
|
236
|
-
it 'renders template' do
|
|
237
|
-
expect(last_response.body).to include('../../../../blah')
|
|
238
|
-
end
|
|
239
|
-
end
|
|
240
|
-
|
|
241
|
-
describe 'GET /features/:feature with question mark in feature name' do
|
|
242
|
-
before do
|
|
243
|
-
get '/features/can_do_stuff%3F'
|
|
244
|
-
end
|
|
245
|
-
|
|
246
|
-
it 'responds with success' do
|
|
247
|
-
expect(last_response.status).to be(200)
|
|
248
|
-
end
|
|
249
|
-
|
|
250
|
-
it 'renders template with question mark in feature name' do
|
|
251
|
-
expect(last_response.body).to include('can_do_stuff?')
|
|
252
|
-
end
|
|
253
|
-
end
|
|
254
|
-
end
|
|
@@ -1,233 +0,0 @@
|
|
|
1
|
-
RSpec.describe Flipper::UI::Actions::Features 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 'GET /features' do
|
|
14
|
-
context "when there are some features" do
|
|
15
|
-
before do
|
|
16
|
-
flipper[:stats].enable
|
|
17
|
-
flipper[:search].enable
|
|
18
|
-
get '/features'
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
it 'responds with success' do
|
|
22
|
-
expect(last_response.status).to be(200)
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
it 'renders template' do
|
|
26
|
-
expect(last_response.body).to include('stats')
|
|
27
|
-
expect(last_response.body).to include('search')
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
it "escapes keys that are junky" do
|
|
32
|
-
flipper.add("../../../../blah")
|
|
33
|
-
flipper.add("this that")
|
|
34
|
-
flipper.add("foo/bar")
|
|
35
|
-
flipper.add("can_do_stuff?")
|
|
36
|
-
get '/features'
|
|
37
|
-
expect(last_response.body).to include("..%2F..%2F..%2F..%2Fblah")
|
|
38
|
-
expect(last_response.body).to include("this+that")
|
|
39
|
-
expect(last_response.body).to include("foo%2Fbar")
|
|
40
|
-
expect(last_response.body).to include("can_do_stuff%3F")
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
context "when there are no features to list" do
|
|
44
|
-
before do
|
|
45
|
-
@original_fun_enabled = Flipper::UI.configuration.fun
|
|
46
|
-
Flipper::UI.configuration.fun = fun_mode
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
after do
|
|
50
|
-
Flipper::UI.configuration.fun = @original_fun_enabled
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
context "when fun mode is enabled" do
|
|
54
|
-
let(:fun_mode) { true }
|
|
55
|
-
before { get '/features' }
|
|
56
|
-
|
|
57
|
-
it 'responds with success' do
|
|
58
|
-
expect(last_response.status).to be(200)
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
it 'renders template' do
|
|
62
|
-
expect(last_response.body).to include('And I\'ll flip your features.')
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
context "when fun mode is disabled" do
|
|
67
|
-
let(:fun_mode) { false }
|
|
68
|
-
before { get '/features' }
|
|
69
|
-
|
|
70
|
-
it 'responds with success' do
|
|
71
|
-
expect(last_response.status).to be(200)
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
it 'renders template' do
|
|
75
|
-
expect(last_response.body).to include('You have not added any features to configure yet.')
|
|
76
|
-
end
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
context "when in read-only mode" do
|
|
81
|
-
before { allow(flipper).to receive(:read_only?) { true } }
|
|
82
|
-
|
|
83
|
-
before { get '/features' }
|
|
84
|
-
|
|
85
|
-
it 'responds with success' do
|
|
86
|
-
expect(last_response.status).to be(200)
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
it 'renders template with no button' do
|
|
90
|
-
expect(last_response.body).not_to include('<a class="btn btn-primary btn-sm" href="/features/new">Add Feature</a>')
|
|
91
|
-
end
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
context 'when descriptions have links' do
|
|
95
|
-
before do
|
|
96
|
-
Flipper::UI.configuration.show_feature_description_in_list = true
|
|
97
|
-
Flipper::UI.configuration.descriptions_source = lambda { |_keys|
|
|
98
|
-
{ 'test_feature' => 'Check <a href="https://example.com">this link</a> for more info' }
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
flipper[:test_feature].enable
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
it 'strips anchor tags from descriptions to avoid nested links' do
|
|
105
|
-
get '/features'
|
|
106
|
-
|
|
107
|
-
expect(last_response.status).to eq(200)
|
|
108
|
-
expect(last_response.body).to include('Check this link for more info')
|
|
109
|
-
expect(last_response.body).not_to include('<a href="https://example.com">this link</a>')
|
|
110
|
-
end
|
|
111
|
-
end
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
describe 'POST /features' do
|
|
115
|
-
let(:feature_name) { 'notifications_next' }
|
|
116
|
-
|
|
117
|
-
before do
|
|
118
|
-
@original_feature_creation_enabled = Flipper::UI.configuration.feature_creation_enabled
|
|
119
|
-
Flipper::UI.configuration.feature_creation_enabled = feature_creation_enabled
|
|
120
|
-
post '/features',
|
|
121
|
-
{ 'value' => feature_name, 'authenticity_token' => token },
|
|
122
|
-
'rack.session' => session
|
|
123
|
-
end
|
|
124
|
-
|
|
125
|
-
after do
|
|
126
|
-
Flipper::UI.configuration.feature_creation_enabled = @original_feature_creation_enabled
|
|
127
|
-
end
|
|
128
|
-
|
|
129
|
-
context 'feature_creation_enabled set to true' do
|
|
130
|
-
let(:feature_creation_enabled) { true }
|
|
131
|
-
|
|
132
|
-
it 'adds feature' do
|
|
133
|
-
expect(flipper.features.map(&:key)).to include('notifications_next')
|
|
134
|
-
end
|
|
135
|
-
|
|
136
|
-
it 'redirects to feature' do
|
|
137
|
-
expect(last_response.status).to be(302)
|
|
138
|
-
expect(last_response.headers['location']).to eq('/features/notifications_next')
|
|
139
|
-
end
|
|
140
|
-
|
|
141
|
-
context 'feature name has whitespace at beginning and end' do
|
|
142
|
-
let(:feature_name) { ' notifications_next ' }
|
|
143
|
-
|
|
144
|
-
it 'adds feature without whitespace' do
|
|
145
|
-
expect(flipper.features.map(&:key)).to include('notifications_next')
|
|
146
|
-
end
|
|
147
|
-
end
|
|
148
|
-
|
|
149
|
-
context 'feature name contains space' do
|
|
150
|
-
let(:feature_name) { 'notifications next' }
|
|
151
|
-
|
|
152
|
-
it 'adds feature with space' do
|
|
153
|
-
expect(flipper.features.map(&:key)).to include('notifications next')
|
|
154
|
-
end
|
|
155
|
-
|
|
156
|
-
it 'redirects to feature' do
|
|
157
|
-
expect(last_response.status).to be(302)
|
|
158
|
-
expect(last_response.headers['location']).to eq('/features/notifications+next')
|
|
159
|
-
end
|
|
160
|
-
end
|
|
161
|
-
|
|
162
|
-
context 'feature name contains ../' do
|
|
163
|
-
let(:feature_name) { '../../../foo' }
|
|
164
|
-
|
|
165
|
-
it 'adds feature with space' do
|
|
166
|
-
expect(flipper.features.map(&:key)).to include(feature_name)
|
|
167
|
-
end
|
|
168
|
-
|
|
169
|
-
it 'redirects to feature' do
|
|
170
|
-
expect(last_response.status).to be(302)
|
|
171
|
-
expect(last_response.headers['location']).to eq('/features/..%2F..%2F..%2Ffoo')
|
|
172
|
-
end
|
|
173
|
-
end
|
|
174
|
-
|
|
175
|
-
context 'feature name contains question mark' do
|
|
176
|
-
let(:feature_name) { 'can_do_stuff?' }
|
|
177
|
-
|
|
178
|
-
it 'adds feature with question mark' do
|
|
179
|
-
expect(flipper.features.map(&:key)).to include('can_do_stuff?')
|
|
180
|
-
end
|
|
181
|
-
|
|
182
|
-
it 'redirects to feature with encoded question mark' do
|
|
183
|
-
expect(last_response.status).to be(302)
|
|
184
|
-
expect(last_response.headers['location']).to eq('/features/can_do_stuff%3F')
|
|
185
|
-
end
|
|
186
|
-
end
|
|
187
|
-
|
|
188
|
-
context 'for an invalid feature name' do
|
|
189
|
-
context 'empty feature name' do
|
|
190
|
-
let(:feature_name) { '' }
|
|
191
|
-
|
|
192
|
-
it 'does not add feature' do
|
|
193
|
-
expect(flipper.features.map(&:key)).to eq([])
|
|
194
|
-
end
|
|
195
|
-
|
|
196
|
-
it 'redirects back to feature' do
|
|
197
|
-
expect(last_response.status).to be(302)
|
|
198
|
-
expect(last_response.headers['location']).to eq('/features/new?error=%22%22+is+not+a+valid+feature+name.')
|
|
199
|
-
end
|
|
200
|
-
end
|
|
201
|
-
|
|
202
|
-
context 'nil feature name' do
|
|
203
|
-
let(:feature_name) { nil }
|
|
204
|
-
|
|
205
|
-
it 'does not add feature' do
|
|
206
|
-
expect(flipper.features.map(&:key)).to eq([])
|
|
207
|
-
end
|
|
208
|
-
|
|
209
|
-
it 'redirects back to feature' do
|
|
210
|
-
expect(last_response.status).to be(302)
|
|
211
|
-
expect(last_response.headers['location']).to eq('/features/new?error=%22%22+is+not+a+valid+feature+name.')
|
|
212
|
-
end
|
|
213
|
-
end
|
|
214
|
-
end
|
|
215
|
-
end
|
|
216
|
-
|
|
217
|
-
context 'feature_creation_enabled set to false' do
|
|
218
|
-
let(:feature_creation_enabled) { false }
|
|
219
|
-
|
|
220
|
-
it 'does not add feature' do
|
|
221
|
-
expect(flipper.features.map(&:key)).not_to include('notifications_next')
|
|
222
|
-
end
|
|
223
|
-
|
|
224
|
-
it 'returns 403' do
|
|
225
|
-
expect(last_response.status).to be(403)
|
|
226
|
-
end
|
|
227
|
-
|
|
228
|
-
it 'renders feature creation disabled template' do
|
|
229
|
-
expect(last_response.body).to include('Feature creation is disabled.')
|
|
230
|
-
end
|
|
231
|
-
end
|
|
232
|
-
end
|
|
233
|
-
end
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
RSpec.describe Flipper::UI::Actions::File do
|
|
2
|
-
describe 'GET /images/logo.png' do
|
|
3
|
-
before do
|
|
4
|
-
get '/images/logo.png'
|
|
5
|
-
end
|
|
6
|
-
|
|
7
|
-
it 'responds with 200' do
|
|
8
|
-
expect(last_response.status).to be(200)
|
|
9
|
-
end
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
describe 'GET /css/application.css' do
|
|
13
|
-
before do
|
|
14
|
-
get '/css/application.css'
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
it 'responds with 200' do
|
|
18
|
-
expect(last_response.status).to be(200)
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
RSpec.describe Flipper::UI::Actions::GroupsGate 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 /features/:feature/groups' do
|
|
15
|
-
before do
|
|
16
|
-
Flipper.register(:admins, &:admin?)
|
|
17
|
-
get 'features/search/groups'
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
after do
|
|
21
|
-
Flipper.unregister_groups
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
it 'responds with success' do
|
|
25
|
-
expect(last_response.status).to be(200)
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
it 'renders add new group form' do
|
|
29
|
-
form = '<form action="/features/search/groups" method="post" class="row">'
|
|
30
|
-
expect(last_response.body).to include(form)
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
describe 'POST /features/:feature/groups' do
|
|
35
|
-
let(:group_name) { 'admins' }
|
|
36
|
-
|
|
37
|
-
before do
|
|
38
|
-
Flipper.register(:admins, &:admin?)
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
after do
|
|
42
|
-
Flipper.unregister_groups
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
context 'enabling a group' do
|
|
46
|
-
before do
|
|
47
|
-
post 'features/search/groups',
|
|
48
|
-
{ 'value' => group_name, 'operation' => 'enable', 'authenticity_token' => token },
|
|
49
|
-
'rack.session' => session
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
it 'adds item to members' do
|
|
53
|
-
expect(flipper[:search].groups_value).to include('admins')
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
it 'redirects back to feature' do
|
|
57
|
-
expect(last_response.status).to be(302)
|
|
58
|
-
expect(last_response.headers['location']).to eq('/features/search')
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
context 'feature name contains space' do
|
|
62
|
-
before do
|
|
63
|
-
post 'features/sp+ace/groups',
|
|
64
|
-
{ 'value' => group_name, 'operation' => 'enable', 'authenticity_token' => token },
|
|
65
|
-
'rack.session' => session
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
it 'adds item to members' do
|
|
69
|
-
expect(flipper["sp ace"].groups_value).to include('admins')
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
it 'redirects back to feature' do
|
|
73
|
-
expect(last_response.status).to be(302)
|
|
74
|
-
expect(last_response.headers['location']).to eq('/features/sp+ace')
|
|
75
|
-
end
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
context 'group name contains whitespace' do
|
|
79
|
-
let(:group_name) { ' admins ' }
|
|
80
|
-
|
|
81
|
-
it 'adds item without whitespace' do
|
|
82
|
-
expect(flipper[:search].groups_value).to include('admins')
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
context 'for an unregistered group' do
|
|
87
|
-
context 'unknown group name' do
|
|
88
|
-
let(:group_name) { 'not_here' }
|
|
89
|
-
|
|
90
|
-
it 'redirects back to feature' do
|
|
91
|
-
expect(last_response.status).to be(302)
|
|
92
|
-
expect(last_response.headers['location']).to eq('/features/search/groups?error=The+group+named+%22not_here%22+has+not+been+registered.')
|
|
93
|
-
end
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
context 'empty group name' do
|
|
97
|
-
let(:group_name) { '' }
|
|
98
|
-
|
|
99
|
-
it 'redirects back to feature' do
|
|
100
|
-
expect(last_response.status).to be(302)
|
|
101
|
-
expect(last_response.headers['location']).to eq('/features/search/groups?error=The+group+named+%22%22+has+not+been+registered.')
|
|
102
|
-
end
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
context 'nil group name' do
|
|
106
|
-
let(:group_name) { nil }
|
|
107
|
-
|
|
108
|
-
it 'redirects back to feature' do
|
|
109
|
-
expect(last_response.status).to be(302)
|
|
110
|
-
expect(last_response.headers['location']).to eq('/features/search/groups?error=The+group+named+%22%22+has+not+been+registered.')
|
|
111
|
-
end
|
|
112
|
-
end
|
|
113
|
-
end
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
context 'disabling a group' do
|
|
117
|
-
let(:group_name) { 'admins' }
|
|
118
|
-
|
|
119
|
-
before do
|
|
120
|
-
flipper[:search].enable_group :admins
|
|
121
|
-
post 'features/search/groups',
|
|
122
|
-
{ 'value' => group_name, 'operation' => 'disable', 'authenticity_token' => token },
|
|
123
|
-
'rack.session' => session
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
it 'removes item from members' do
|
|
127
|
-
expect(flipper[:search].groups_value).not_to include('admins')
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
it 'redirects back to feature' do
|
|
131
|
-
expect(last_response.status).to be(302)
|
|
132
|
-
expect(last_response.headers['location']).to eq('/features/search')
|
|
133
|
-
end
|
|
134
|
-
|
|
135
|
-
context 'group name contains whitespace' do
|
|
136
|
-
let(:group_name) { ' admins ' }
|
|
137
|
-
|
|
138
|
-
it 'removes item without whitespace' do
|
|
139
|
-
expect(flipper[:search].groups_value).not_to include('admins')
|
|
140
|
-
end
|
|
141
|
-
end
|
|
142
|
-
end
|
|
143
|
-
end
|
|
144
|
-
end
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
RSpec.describe Flipper::UI::Actions::Home do
|
|
2
|
-
describe 'GET /' do
|
|
3
|
-
before do
|
|
4
|
-
flipper[:stats].enable
|
|
5
|
-
flipper[:search].enable
|
|
6
|
-
get '/'
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
it 'responds with redirect' do
|
|
10
|
-
expect(last_response.status).to be(302)
|
|
11
|
-
expect(last_response.headers['location']).to eq('/features')
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
end
|