flipper-ui 0.9.0.beta1 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/flipper/ui/action.rb +12 -1
- data/lib/flipper/version.rb +1 -1
- data/spec/flipper/ui/action_spec.rb +59 -0
- metadata +8 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac02aa3928a20cfd18227e4ea03a710445963411
|
4
|
+
data.tar.gz: 4e326d8a1ae7d55df414e89b38f3635e40c58bfb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a7fcb2fb3018253ca9e9cc0f9a3bcffd2b35647761a8da4552cf17cee2b8ad745366daf1f9eb5e449220bcd3b6fbf34b014acf53d6c4a7c9c56079dc40838a54
|
7
|
+
data.tar.gz: b58496ab5a0648e98883143d0db86a9ae079e5e79c717179ee378608f15e4591650e2e832609d4bf3b5e1ba1b167609f7a24df3184149d244e933cee088e610b
|
data/lib/flipper/ui/action.rb
CHANGED
@@ -8,6 +8,13 @@ module Flipper
|
|
8
8
|
class Action
|
9
9
|
extend Forwardable
|
10
10
|
|
11
|
+
VALID_REQUEST_METHOD_NAMES = Set.new([
|
12
|
+
"get".freeze,
|
13
|
+
"post".freeze,
|
14
|
+
"put".freeze,
|
15
|
+
"delete".freeze,
|
16
|
+
]).freeze
|
17
|
+
|
11
18
|
# Public: Call this in subclasses so the action knows its route.
|
12
19
|
#
|
13
20
|
# regex - The Regexp that this action should run for.
|
@@ -67,7 +74,7 @@ module Flipper
|
|
67
74
|
#
|
68
75
|
# Returns whatever the request method returns in the action.
|
69
76
|
def run
|
70
|
-
if respond_to?(request_method_name)
|
77
|
+
if valid_request_method? && respond_to?(request_method_name)
|
71
78
|
catch(:halt) { send(request_method_name) }
|
72
79
|
else
|
73
80
|
raise UI::RequestMethodNotSupported, "#{self.class} does not support request method #{request_method_name.inspect}"
|
@@ -213,6 +220,10 @@ module Flipper
|
|
213
220
|
def csrf_input_tag
|
214
221
|
%Q(<input type="hidden" name="authenticity_token" value="#{@request.session[:csrf]}">)
|
215
222
|
end
|
223
|
+
|
224
|
+
def valid_request_method?
|
225
|
+
VALID_REQUEST_METHOD_NAMES.include?(request_method_name)
|
226
|
+
end
|
216
227
|
end
|
217
228
|
end
|
218
229
|
end
|
data/lib/flipper/version.rb
CHANGED
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
RSpec.describe Flipper::UI::Action do
|
4
|
+
let(:action_subclass) {
|
5
|
+
Class.new(described_class) do
|
6
|
+
def noooope
|
7
|
+
raise "should never run this"
|
8
|
+
end
|
9
|
+
|
10
|
+
def get
|
11
|
+
[200, {}, "get"]
|
12
|
+
end
|
13
|
+
|
14
|
+
def post
|
15
|
+
[200, {}, "post"]
|
16
|
+
end
|
17
|
+
|
18
|
+
def put
|
19
|
+
[200, {}, "put"]
|
20
|
+
end
|
21
|
+
|
22
|
+
def delete
|
23
|
+
[200, {}, "delete"]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
}
|
27
|
+
|
28
|
+
it "won't run method that isn't whitelisted" do
|
29
|
+
fake_request = Struct.new(:request_method, :env, :session).new("NOOOOPE", {}, {})
|
30
|
+
action = action_subclass.new(flipper, fake_request)
|
31
|
+
expect {
|
32
|
+
action.run
|
33
|
+
}.to raise_error(Flipper::UI::RequestMethodNotSupported)
|
34
|
+
end
|
35
|
+
|
36
|
+
it "will run get" do
|
37
|
+
fake_request = Struct.new(:request_method, :env, :session).new("GET", {}, {})
|
38
|
+
action = action_subclass.new(flipper, fake_request)
|
39
|
+
expect(action.run).to eq([200, {}, "get"])
|
40
|
+
end
|
41
|
+
|
42
|
+
it "will run post" do
|
43
|
+
fake_request = Struct.new(:request_method, :env, :session).new("POST", {}, {})
|
44
|
+
action = action_subclass.new(flipper, fake_request)
|
45
|
+
expect(action.run).to eq([200, {}, "post"])
|
46
|
+
end
|
47
|
+
|
48
|
+
it "will run put" do
|
49
|
+
fake_request = Struct.new(:request_method, :env, :session).new("PUT", {}, {})
|
50
|
+
action = action_subclass.new(flipper, fake_request)
|
51
|
+
expect(action.run).to eq([200, {}, "put"])
|
52
|
+
end
|
53
|
+
|
54
|
+
it "will run delete" do
|
55
|
+
fake_request = Struct.new(:request_method, :env, :session).new("DELETE", {}, {})
|
56
|
+
action = action_subclass.new(flipper, fake_request)
|
57
|
+
expect(action.run).to eq([200, {}, "delete"])
|
58
|
+
end
|
59
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flipper-ui
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.0
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Nunemaker
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-07-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -50,14 +50,14 @@ dependencies:
|
|
50
50
|
requirements:
|
51
51
|
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: 0.9.0
|
53
|
+
version: 0.9.0
|
54
54
|
type: :runtime
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
58
|
- - "~>"
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version: 0.9.0
|
60
|
+
version: 0.9.0
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
62
|
name: erubis
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -249,6 +249,7 @@ files:
|
|
249
249
|
- lib/flipper/ui/views/features.erb
|
250
250
|
- lib/flipper/ui/views/layout.erb
|
251
251
|
- lib/flipper/version.rb
|
252
|
+
- spec/flipper/ui/action_spec.rb
|
252
253
|
- spec/flipper/ui/actions/actors_gate_spec.rb
|
253
254
|
- spec/flipper/ui/actions/add_feature_spec.rb
|
254
255
|
- spec/flipper/ui/actions/boolean_gate_spec.rb
|
@@ -279,9 +280,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
279
280
|
version: '0'
|
280
281
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
281
282
|
requirements:
|
282
|
-
- - "
|
283
|
+
- - ">="
|
283
284
|
- !ruby/object:Gem::Version
|
284
|
-
version:
|
285
|
+
version: '0'
|
285
286
|
requirements: []
|
286
287
|
rubyforge_project:
|
287
288
|
rubygems_version: 2.4.5.1
|
@@ -289,6 +290,7 @@ signing_key:
|
|
289
290
|
specification_version: 4
|
290
291
|
summary: UI for the Flipper gem
|
291
292
|
test_files:
|
293
|
+
- spec/flipper/ui/action_spec.rb
|
292
294
|
- spec/flipper/ui/actions/actors_gate_spec.rb
|
293
295
|
- spec/flipper/ui/actions/add_feature_spec.rb
|
294
296
|
- spec/flipper/ui/actions/boolean_gate_spec.rb
|