flipper-ui 0.10.1 → 0.10.2
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/actions/actors_gate.rb +1 -1
- data/lib/flipper/ui/actions/features.rb +1 -1
- data/lib/flipper/ui/actions/groups_gate.rb +1 -1
- data/lib/flipper/version.rb +1 -1
- data/spec/flipper/ui/actions/actors_gate_spec.rb +39 -12
- data/spec/flipper/ui/actions/features_spec.rb +61 -29
- data/spec/flipper/ui/actions/groups_gate_spec.rb +48 -12
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aecff7000b2350bc4238cd50dcfc9cad07c8bb27
|
4
|
+
data.tar.gz: 86be7431a5eca0a785984083c645dbf6fa7e510e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7945d54ccb03a0d2b3b309175a601d797b68f1c96fa80d66354d1028aafe12abc7fc2b1eb83b40577180a8dec3450044ad86b8ae58bf4d7653c0d3d3890e6185
|
7
|
+
data.tar.gz: d5d68823b6d56dfe8069792b5e18c52530400967ca8ff078cf0590dc9768d0c61c2a8ea44780a0cf2b290ac9181673e795c84ec7690af53c300e12db4e788e98
|
@@ -24,7 +24,7 @@ module Flipper
|
|
24
24
|
def post
|
25
25
|
feature_name = Rack::Utils.unescape(request.path.split('/')[-2])
|
26
26
|
feature = flipper[feature_name.to_sym]
|
27
|
-
value = params["value"]
|
27
|
+
value = params["value"].to_s.strip
|
28
28
|
|
29
29
|
if Util.blank?(value)
|
30
30
|
error = Rack::Utils.escape("#{value.inspect} is not a valid actor value.")
|
data/lib/flipper/version.rb
CHANGED
@@ -32,9 +32,11 @@ RSpec.describe Flipper::UI::Actions::ActorsGate do
|
|
32
32
|
|
33
33
|
describe "POST /features/:feature/actors" do
|
34
34
|
context "enabling an actor" do
|
35
|
+
let(:value) { "User:6" }
|
36
|
+
|
35
37
|
before do
|
36
38
|
post "features/search/actors",
|
37
|
-
{"value" =>
|
39
|
+
{"value" => value, "operation" => "enable", "authenticity_token" => token},
|
38
40
|
"rack.session" => session
|
39
41
|
end
|
40
42
|
|
@@ -46,13 +48,43 @@ RSpec.describe Flipper::UI::Actions::ActorsGate do
|
|
46
48
|
expect(last_response.status).to be(302)
|
47
49
|
expect(last_response.headers["Location"]).to eq("/features/search")
|
48
50
|
end
|
51
|
+
|
52
|
+
context 'value contains whitespace' do
|
53
|
+
let(:value) { " User:6 " }
|
54
|
+
|
55
|
+
it "adds item without whitespace" do
|
56
|
+
expect(flipper[:search].actors_value).to include("User:6")
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
context "for an invalid actor value" do
|
61
|
+
context "empty value" do
|
62
|
+
let(:value) { "" }
|
63
|
+
|
64
|
+
it "redirects back to feature" do
|
65
|
+
expect(last_response.status).to be(302)
|
66
|
+
expect(last_response.headers["Location"]).to eq("/features/search/actors?error=%22%22+is+not+a+valid+actor+value.")
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
context "nil value" do
|
71
|
+
let(:value) { nil }
|
72
|
+
|
73
|
+
it "redirects back to feature" do
|
74
|
+
expect(last_response.status).to be(302)
|
75
|
+
expect(last_response.headers["Location"]).to eq("/features/search/actors?error=%22%22+is+not+a+valid+actor+value.")
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
49
79
|
end
|
50
80
|
|
51
81
|
context "disabling an actor" do
|
82
|
+
let(:value) { "User:6" }
|
83
|
+
|
52
84
|
before do
|
53
85
|
flipper[:search].enable_actor Flipper::UI::Actor.new("User:6")
|
54
86
|
post "features/search/actors",
|
55
|
-
{"value" =>
|
87
|
+
{"value" => value, "operation" => "disable", "authenticity_token" => token},
|
56
88
|
"rack.session" => session
|
57
89
|
end
|
58
90
|
|
@@ -64,18 +96,13 @@ RSpec.describe Flipper::UI::Actions::ActorsGate do
|
|
64
96
|
expect(last_response.status).to be(302)
|
65
97
|
expect(last_response.headers["Location"]).to eq("/features/search")
|
66
98
|
end
|
67
|
-
end
|
68
99
|
|
69
|
-
|
70
|
-
|
71
|
-
post "features/search/actors",
|
72
|
-
{"value" => "", "operation" => "enable", "authenticity_token" => token},
|
73
|
-
"rack.session" => session
|
74
|
-
end
|
100
|
+
context 'value contains whitespace' do
|
101
|
+
let(:value) { " User:6 " }
|
75
102
|
|
76
|
-
|
77
|
-
|
78
|
-
|
103
|
+
it "removes item whitout whitespace" do
|
104
|
+
expect(flipper[:search].actors_value).not_to include("User:6")
|
105
|
+
end
|
79
106
|
end
|
80
107
|
end
|
81
108
|
end
|
@@ -33,12 +33,14 @@ RSpec.describe Flipper::UI::Actions::Features do
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
describe "POST /features
|
36
|
+
describe "POST /features" do
|
37
|
+
let(:feature_name) { "notifications_next" }
|
38
|
+
|
37
39
|
before do
|
38
40
|
@original_feature_creation_enabled = Flipper::UI.feature_creation_enabled
|
39
|
-
Flipper::UI.feature_creation_enabled =
|
41
|
+
Flipper::UI.feature_creation_enabled = feature_creation_enabled
|
40
42
|
post "/features",
|
41
|
-
{"value" =>
|
43
|
+
{"value" => feature_name, "authenticity_token" => token},
|
42
44
|
"rack.session" => session
|
43
45
|
end
|
44
46
|
|
@@ -46,39 +48,69 @@ RSpec.describe Flipper::UI::Actions::Features do
|
|
46
48
|
Flipper::UI.feature_creation_enabled = @original_feature_creation_enabled
|
47
49
|
end
|
48
50
|
|
49
|
-
|
50
|
-
|
51
|
-
end
|
51
|
+
context 'feature_creation_enabled set to true' do
|
52
|
+
let(:feature_creation_enabled) { true }
|
52
53
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
end
|
57
|
-
end
|
54
|
+
it "adds feature" do
|
55
|
+
expect(flipper.features.map(&:key)).to include("notifications_next")
|
56
|
+
end
|
58
57
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
post "/features",
|
64
|
-
{"value" => "notifications_next", "authenticity_token" => token},
|
65
|
-
"rack.session" => session
|
66
|
-
end
|
58
|
+
it "redirects to feature" do
|
59
|
+
expect(last_response.status).to be(302)
|
60
|
+
expect(last_response.headers["Location"]).to eq("/features/notifications_next")
|
61
|
+
end
|
67
62
|
|
68
|
-
|
69
|
-
|
70
|
-
end
|
63
|
+
context 'feature name contains whitespace' do
|
64
|
+
let(:feature_name) { " notifications_next " }
|
71
65
|
|
72
|
-
|
73
|
-
|
74
|
-
|
66
|
+
it "adds feature without whitespace" do
|
67
|
+
expect(flipper.features.map(&:key)).to include("notifications_next")
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
context "for an invalid feature name" do
|
72
|
+
context "empty feature name" do
|
73
|
+
let(:feature_name) { "" }
|
74
|
+
|
75
|
+
it "does not add feature" do
|
76
|
+
expect(flipper.features.map(&:key)).to eq([])
|
77
|
+
end
|
78
|
+
|
79
|
+
it "redirects back to feature" do
|
80
|
+
expect(last_response.status).to be(302)
|
81
|
+
expect(last_response.headers["Location"]).to eq("/features/new?error=%22%22+is+not+a+valid+feature+name.")
|
82
|
+
end
|
83
|
+
end
|
75
84
|
|
76
|
-
|
77
|
-
|
85
|
+
context "nil feature name" do
|
86
|
+
let(:feature_name) { nil }
|
87
|
+
|
88
|
+
it "does not add feature" do
|
89
|
+
expect(flipper.features.map(&:key)).to eq([])
|
90
|
+
end
|
91
|
+
|
92
|
+
it "redirects back to feature" do
|
93
|
+
expect(last_response.status).to be(302)
|
94
|
+
expect(last_response.headers["Location"]).to eq("/features/new?error=%22%22+is+not+a+valid+feature+name.")
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
78
98
|
end
|
79
99
|
|
80
|
-
|
81
|
-
|
100
|
+
context 'feature_creation_enabled set to false' do
|
101
|
+
let(:feature_creation_enabled) { false }
|
102
|
+
|
103
|
+
it "does not add feature" do
|
104
|
+
expect(flipper.features.map(&:key)).to_not include("notifications_next")
|
105
|
+
end
|
106
|
+
|
107
|
+
it "returns 403" do
|
108
|
+
expect(last_response.status).to be(403)
|
109
|
+
end
|
110
|
+
|
111
|
+
it "renders feature creation disabled template" do
|
112
|
+
expect(last_response.body).to include("Feature creation is disabled.")
|
113
|
+
end
|
82
114
|
end
|
83
115
|
end
|
84
116
|
end
|
@@ -36,6 +36,8 @@ RSpec.describe Flipper::UI::Actions::GroupsGate do
|
|
36
36
|
end
|
37
37
|
|
38
38
|
describe "POST /features/:feature/groups" do
|
39
|
+
let(:group_name) { "admins" }
|
40
|
+
|
39
41
|
before do
|
40
42
|
Flipper.register(:admins) { |user| user.admin? }
|
41
43
|
end
|
@@ -47,7 +49,7 @@ RSpec.describe Flipper::UI::Actions::GroupsGate do
|
|
47
49
|
context "enabling a group" do
|
48
50
|
before do
|
49
51
|
post "features/search/groups",
|
50
|
-
{"value" =>
|
52
|
+
{"value" => group_name, "operation" => "enable", "authenticity_token" => token},
|
51
53
|
"rack.session" => session
|
52
54
|
end
|
53
55
|
|
@@ -59,13 +61,52 @@ RSpec.describe Flipper::UI::Actions::GroupsGate do
|
|
59
61
|
expect(last_response.status).to be(302)
|
60
62
|
expect(last_response.headers["Location"]).to eq("/features/search")
|
61
63
|
end
|
64
|
+
|
65
|
+
context 'group name contains whitespace' do
|
66
|
+
let(:group_name) { " admins " }
|
67
|
+
|
68
|
+
it "adds item without whitespace" do
|
69
|
+
expect(flipper[:search].groups_value).to include("admins")
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
context "for an unregistered group" do
|
74
|
+
context "unknown group name" do
|
75
|
+
let(:group_name) { "not_here" }
|
76
|
+
|
77
|
+
it "redirects back to feature" do
|
78
|
+
expect(last_response.status).to be(302)
|
79
|
+
expect(last_response.headers["Location"]).to eq("/features/search/groups?error=The+group+named+%22not_here%22+has+not+been+registered.")
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
context "empty group name" do
|
84
|
+
let(:group_name) { "" }
|
85
|
+
|
86
|
+
it "redirects back to feature" do
|
87
|
+
expect(last_response.status).to be(302)
|
88
|
+
expect(last_response.headers["Location"]).to eq("/features/search/groups?error=The+group+named+%22%22+has+not+been+registered.")
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
context "nil group name" do
|
93
|
+
let(:group_name) { nil }
|
94
|
+
|
95
|
+
it "redirects back to feature" do
|
96
|
+
expect(last_response.status).to be(302)
|
97
|
+
expect(last_response.headers["Location"]).to eq("/features/search/groups?error=The+group+named+%22%22+has+not+been+registered.")
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
62
101
|
end
|
63
102
|
|
64
103
|
context "disabling a group" do
|
104
|
+
let(:group_name) { "admins" }
|
105
|
+
|
65
106
|
before do
|
66
107
|
flipper[:search].enable_group :admins
|
67
108
|
post "features/search/groups",
|
68
|
-
{"value" =>
|
109
|
+
{"value" => group_name, "operation" => "disable", "authenticity_token" => token},
|
69
110
|
"rack.session" => session
|
70
111
|
end
|
71
112
|
|
@@ -77,18 +118,13 @@ RSpec.describe Flipper::UI::Actions::GroupsGate do
|
|
77
118
|
expect(last_response.status).to be(302)
|
78
119
|
expect(last_response.headers["Location"]).to eq("/features/search")
|
79
120
|
end
|
80
|
-
end
|
81
121
|
|
82
|
-
|
83
|
-
|
84
|
-
post "features/search/groups",
|
85
|
-
{"value" => "not_here", "operation" => "enable", "authenticity_token" => token},
|
86
|
-
"rack.session" => session
|
87
|
-
end
|
122
|
+
context 'group name contains whitespace' do
|
123
|
+
let(:group_name) { " admins " }
|
88
124
|
|
89
|
-
|
90
|
-
|
91
|
-
|
125
|
+
it "removes item without whitespace" do
|
126
|
+
expect(flipper[:search].groups_value).not_to include("admins")
|
127
|
+
end
|
92
128
|
end
|
93
129
|
end
|
94
130
|
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.10.
|
4
|
+
version: 0.10.2
|
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-12-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -56,14 +56,14 @@ dependencies:
|
|
56
56
|
requirements:
|
57
57
|
- - "~>"
|
58
58
|
- !ruby/object:Gem::Version
|
59
|
-
version: 0.10.
|
59
|
+
version: 0.10.2
|
60
60
|
type: :runtime
|
61
61
|
prerelease: false
|
62
62
|
version_requirements: !ruby/object:Gem::Requirement
|
63
63
|
requirements:
|
64
64
|
- - "~>"
|
65
65
|
- !ruby/object:Gem::Version
|
66
|
-
version: 0.10.
|
66
|
+
version: 0.10.2
|
67
67
|
- !ruby/object:Gem::Dependency
|
68
68
|
name: erubis
|
69
69
|
requirement: !ruby/object:Gem::Requirement
|