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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cc0173948538ea1c5a5efb109694ee186ffdba06
4
- data.tar.gz: a75a8008ced7c513e22c6ecbd378c39f430b4ba0
3
+ metadata.gz: ac02aa3928a20cfd18227e4ea03a710445963411
4
+ data.tar.gz: 4e326d8a1ae7d55df414e89b38f3635e40c58bfb
5
5
  SHA512:
6
- metadata.gz: c66f6b0dbd1bebe6ec49643b48c0fb7b3e52b7595563f4d153bbc24162559e0607d315b5fd4a77ca899cb78542776849f58e94744170985b4a7ada7c003ad22d
7
- data.tar.gz: 437f7ba277a33fabd1526ed09fbdd3e79457113af2b228cf90273bff0c6f02fb8bacc9f668577e1f644cb81ff545abf106894e1dc0ccce0f168d20b64e3ae9bb
6
+ metadata.gz: a7fcb2fb3018253ca9e9cc0f9a3bcffd2b35647761a8da4552cf17cee2b8ad745366daf1f9eb5e449220bcd3b6fbf34b014acf53d6c4a7c9c56079dc40838a54
7
+ data.tar.gz: b58496ab5a0648e98883143d0db86a9ae079e5e79c717179ee378608f15e4591650e2e832609d4bf3b5e1ba1b167609f7a24df3184149d244e933cee088e610b
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Flipper
2
- VERSION = "0.9.0.beta1".freeze
2
+ VERSION = "0.9.0".freeze
3
3
  end
@@ -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.beta1
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-06-23 00:00:00.000000000 Z
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.beta1
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.beta1
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: 1.3.1
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