flipper-ui 1.4.2 → 1.5.0.rc2

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.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/lib/flipper/ui/action.rb +46 -35
  3. data/lib/flipper/ui/actions/actors_gate.rb +17 -3
  4. data/lib/flipper/ui/actions/cloud_migrate.rb +1 -0
  5. data/lib/flipper/ui/actions/features.rb +5 -1
  6. data/lib/flipper/ui/actions/groups_gate.rb +6 -1
  7. data/lib/flipper/ui/actions/import.rb +20 -2
  8. data/lib/flipper/ui/actions/percentage_of_actors_gate.rb +2 -0
  9. data/lib/flipper/ui/actions/percentage_of_time_gate.rb +2 -0
  10. data/lib/flipper/ui/configuration.rb +6 -1
  11. data/lib/flipper/ui/decorators/feature.rb +6 -12
  12. data/lib/flipper/ui/error.rb +2 -2
  13. data/lib/flipper/ui/middleware.rb +10 -0
  14. data/lib/flipper/ui/public/images/logo.png +0 -0
  15. data/lib/flipper/ui/util.rb +5 -4
  16. data/lib/flipper/ui/views/feature.erb +8 -0
  17. data/lib/flipper/ui/views/layout.erb +8 -4
  18. data/lib/flipper/ui/views/settings.erb +21 -18
  19. data/lib/flipper/ui.rb +4 -1
  20. data/lib/flipper/version.rb +1 -1
  21. metadata +5 -32
  22. data/examples/ui/authorization.ru +0 -48
  23. data/examples/ui/basic.ru +0 -71
  24. data/examples/ui/prefixed.ru +0 -21
  25. data/examples/ui/read_only.ru +0 -43
  26. data/flipper-ui.gemspec +0 -29
  27. data/lib/flipper/ui/decorators/gate.rb +0 -37
  28. data/lib/flipper/ui/public/js/jquery-3.6.0.slim.js +0 -8782
  29. data/spec/flipper/ui/action_spec.rb +0 -76
  30. data/spec/flipper/ui/actions/actors_gate_spec.rb +0 -201
  31. data/spec/flipper/ui/actions/add_feature_spec.rb +0 -57
  32. data/spec/flipper/ui/actions/boolean_gate_spec.rb +0 -139
  33. data/spec/flipper/ui/actions/cloud_migrate_spec.rb +0 -54
  34. data/spec/flipper/ui/actions/export_spec.rb +0 -51
  35. data/spec/flipper/ui/actions/feature_spec.rb +0 -254
  36. data/spec/flipper/ui/actions/features_spec.rb +0 -233
  37. data/spec/flipper/ui/actions/file_spec.rb +0 -21
  38. data/spec/flipper/ui/actions/groups_gate_spec.rb +0 -144
  39. data/spec/flipper/ui/actions/home_spec.rb +0 -14
  40. data/spec/flipper/ui/actions/import_spec.rb +0 -63
  41. data/spec/flipper/ui/actions/percentage_of_actors_gate_spec.rb +0 -65
  42. data/spec/flipper/ui/actions/percentage_of_time_gate_spec.rb +0 -65
  43. data/spec/flipper/ui/actions/settings_spec.rb +0 -35
  44. data/spec/flipper/ui/configuration_spec.rb +0 -229
  45. data/spec/flipper/ui/decorators/feature_spec.rb +0 -59
  46. data/spec/flipper/ui/decorators/gate_spec.rb +0 -45
  47. data/spec/flipper/ui/util_spec.rb +0 -17
  48. data/spec/flipper/ui_spec.rb +0 -197
@@ -1,197 +0,0 @@
1
- RSpec.describe Flipper::UI 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
- let(:configuration) { described_class.configuration }
13
-
14
- describe 'Initializing middleware with flipper instance' do
15
- let(:app) { build_app(flipper) }
16
-
17
- it 'works' do
18
- flipper.enable :some_great_feature
19
- get '/features'
20
- expect(last_response.status).to be(200)
21
- expect(last_response.body).to include('some_great_feature')
22
- end
23
- end
24
-
25
- describe 'Request method unsupported by action' do
26
- it 'raises error' do
27
- expect do
28
- head '/features'
29
- end.to raise_error(Flipper::UI::RequestMethodNotSupported)
30
- end
31
- end
32
-
33
- describe 'Inspecting the built Rack app' do
34
- it 'returns a String' do
35
- expect(build_app(flipper).inspect).to eq("Flipper::UI")
36
- end
37
- end
38
-
39
- # See https://github.com/flippercloud/flipper/issues/80
40
- it 'can route features with names that match static directories' do
41
- post 'features/refactor-images/actors',
42
- { 'value' => 'User;6', 'operation' => 'enable', 'authenticity_token' => token },
43
- 'rack.session' => session
44
- expect(last_response.status).to be(302)
45
- expect(last_response.headers['location']).to eq('/features/refactor-images')
46
- end
47
-
48
- describe 'configure' do
49
- it 'yields configuration instance' do
50
- described_class.configure do |config|
51
- expect(config).to be_instance_of(Flipper::UI::Configuration)
52
- end
53
- end
54
-
55
- describe 'banner' do
56
- it 'does not include the banner if banner_text is not set' do
57
- get '/features'
58
- expect(last_response.body).not_to include('Production Environment')
59
- end
60
-
61
- describe 'when set' do
62
- around do |example|
63
- begin
64
- @original_banner_text = described_class.configuration.banner_text
65
- described_class.configuration.banner_text = 'Production Environment'
66
- example.run
67
- ensure
68
- described_class.configuration.banner_text = @original_banner_text
69
- end
70
- end
71
-
72
- it 'includes banner' do
73
- get '/features'
74
- expect(last_response.body).to include('Production Environment')
75
- end
76
- end
77
- end
78
-
79
- describe "application_href" do
80
- around do |example|
81
- original_href = configuration.application_href
82
- example.run
83
- ensure
84
- configuration.application_href = original_href
85
- end
86
-
87
- it 'does not have an application_href by default' do
88
- expect(configuration.application_href).to be(nil)
89
- end
90
-
91
- context 'with application_href not set' do
92
- it 'does not add App link' do
93
- get '/features'
94
- expect(last_response.body).not_to include('<a href="/myapp">App</a>')
95
- end
96
- end
97
-
98
- context 'with application_href set' do
99
- before do
100
- configuration.application_href = '/myapp'
101
- end
102
-
103
- it 'does add App link' do
104
- get '/features'
105
- expect(last_response.body).to match('<a.*href="/myapp"')
106
- end
107
- end
108
-
109
- context 'with application_href set to full url' do
110
- before do
111
- configuration.application_href = "https://myapp.com/"
112
- end
113
-
114
- it 'does add App link' do
115
- get '/features'
116
- expect(last_response.body).to match('<a.*href="https://myapp.com/"')
117
- end
118
- end
119
- end
120
-
121
- describe "feature_creation_enabled" do
122
- it 'sets feature_creation_enabled to true by default' do
123
- expect(configuration.feature_creation_enabled).to be(true)
124
- end
125
-
126
- context 'with feature_creation_enabled set to true' do
127
- before do
128
- @original_feature_creation_enabled = configuration.feature_creation_enabled
129
- configuration.feature_creation_enabled = true
130
- end
131
-
132
- it 'has the add_feature button' do
133
- get '/features'
134
- expect(last_response.body).to include('Add Feature')
135
- end
136
-
137
- after do
138
- configuration.feature_creation_enabled = @original_feature_creation_enabled
139
- end
140
- end
141
-
142
- context 'with feature_creation_enabled set to false' do
143
- before do
144
- @original_feature_creation_enabled = configuration.feature_creation_enabled
145
- configuration.feature_creation_enabled = false
146
- end
147
-
148
- it 'does not have the add_feature button' do
149
- get '/features'
150
- expect(last_response.body).not_to include('Add Feature')
151
- end
152
-
153
- after do
154
- configuration.feature_creation_enabled = @original_feature_creation_enabled
155
- end
156
- end
157
- end
158
-
159
- describe "feature_removal_enabled" do
160
- it 'sets feature_removal_enabled to true by default' do
161
- expect(configuration.feature_removal_enabled).to be(true)
162
- end
163
-
164
- context 'with feature_removal_enabled set to true' do
165
- before do
166
- @original_feature_removal_enabled = configuration.feature_removal_enabled
167
- configuration.feature_removal_enabled = true
168
- end
169
-
170
- it 'has the add_feature button' do
171
- get '/features/test'
172
- expect(last_response.body).to include('Delete')
173
- end
174
-
175
- after do
176
- configuration.feature_removal_enabled = @original_feature_removal_enabled
177
- end
178
- end
179
-
180
- context 'with feature_removal_enabled set to false' do
181
- before do
182
- @original_feature_removal_enabled = configuration.feature_removal_enabled
183
- configuration.feature_removal_enabled = false
184
- end
185
-
186
- it 'does not have the add_feature button' do
187
- get '/features/test'
188
- expect(last_response.body).not_to include('Delete')
189
- end
190
-
191
- after do
192
- configuration.feature_removal_enabled = @original_feature_removal_enabled
193
- end
194
- end
195
- end
196
- end
197
- end