detour 0.0.14 → 0.0.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/helpers/detour/flaggable_flags_helper.rb +1 -1
- data/app/models/detour/concerns/custom_human_attributes.rb +21 -0
- data/app/models/detour/feature.rb +2 -0
- data/app/models/detour/group.rb +2 -0
- data/app/views/detour/flaggable_flags/index.html.erb +12 -6
- data/app/views/detour/groups/show.html.erb +11 -5
- data/app/views/detour/shared/_errors.html.erb +1 -1
- data/lib/detour/acts_as_flaggable.rb +7 -0
- data/lib/detour/version.rb +1 -1
- data/spec/features/database_groups_spec.rb +13 -1
- data/spec/features/features_spec.rb +6 -0
- data/spec/features/flag_in_flags_spec.rb +13 -1
- data/spec/features/opt_out_flags_spec.rb +13 -1
- data/spec/features/percentage_flags_spec.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a220248ad207160603f672e811b577ed86219921
|
4
|
+
data.tar.gz: c7538218ad95016610473c86ab3d35fc633b66b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37cf839b98df18604e536b699239c5a7425bd37d3c301c5770f84646906cfc43edbd2e3e006bb795907e3083ec140839deff96d5138240cd3d4c6a64da4530e5
|
7
|
+
data.tar.gz: fdc0b1a0f69bbf0e6e669903777f0c3ae6011987ec0b18aebe77c8466dca2255e9e9e55ef25fb8b6953043ec0a4fc081d081b3eb99b6fb35a5c7bbd9ba83967b
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Detour::Concerns
|
2
|
+
module CustomHumanAttributes
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
@human_attribute_names = {}
|
7
|
+
|
8
|
+
class << self
|
9
|
+
alias :original_human_attribute_name :human_attribute_name
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.human_attribute_name(*args)
|
13
|
+
@human_attribute_names[args[0]] || original_human_attribute_name(*args)
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.set_human_attribute_name(key, name)
|
17
|
+
@human_attribute_names[key] = name
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
# Represents an individual feature that may be rolled out to a set of records
|
2
2
|
# via individual flags, percentages, or defined groups.
|
3
3
|
class Detour::Feature < ActiveRecord::Base
|
4
|
+
include Detour::Concerns::CustomHumanAttributes
|
5
|
+
|
4
6
|
self.table_name = :detour_features
|
5
7
|
|
6
8
|
serialize :flag_in_counts, JSON
|
data/app/models/detour/group.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
class Detour::Group < ActiveRecord::Base
|
2
|
+
include Detour::Concerns::CustomHumanAttributes
|
3
|
+
|
2
4
|
validates :name, presence: true, uniqueness: { scope: :flaggable_type }
|
3
5
|
validates :flaggable_type, presence: true, inclusion: { in: Detour.config.flaggable_types }
|
4
6
|
has_many :memberships, dependent: :destroy
|
@@ -1,11 +1,17 @@
|
|
1
|
-
<h1><%= flaggable_type.classify %> <%= flag_verb %> <%= feature_name %></h1>
|
1
|
+
<h1><%= flaggable_type.classify.pluralize %> <%= flag_verb %> <%= feature_name %></h1>
|
2
2
|
|
3
3
|
<% if @feature.errors.any? %>
|
4
|
-
<
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
<div class="panel panel-danger">
|
5
|
+
<div class="panel-heading">Whoops! There were some errors saving your <%= flag_noun.pluralize %>:</div>
|
6
|
+
|
7
|
+
<div class="panel-body">
|
8
|
+
<ul>
|
9
|
+
<% @feature.errors.full_messages.each do |msg| %>
|
10
|
+
<li><%= msg %></li>
|
11
|
+
<% end %>
|
12
|
+
</ul>
|
13
|
+
</div>
|
14
|
+
</div>
|
9
15
|
<% end %>
|
10
16
|
|
11
17
|
<%= form_for @feature, url: request.path do |form| %>
|
@@ -1,11 +1,17 @@
|
|
1
1
|
<h1><%= @group.flaggable_class %> Group: <%= @group %></h1>
|
2
2
|
|
3
3
|
<% if @group.errors.any? %>
|
4
|
-
<
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
<div class="panel panel-danger">
|
5
|
+
<div class="panel-heading">Whoops! There were some errors saving your group:</div>
|
6
|
+
|
7
|
+
<div class="panel-body">
|
8
|
+
<ul>
|
9
|
+
<% @group.errors.full_messages.each do |msg| %>
|
10
|
+
<li><%= msg %></li>
|
11
|
+
<% end %>
|
12
|
+
</ul>
|
13
|
+
</div>
|
14
|
+
</div>
|
9
15
|
<% end %>
|
10
16
|
|
11
17
|
<%= form_for @group do |form| %>
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<div class="panel panel-danger">
|
2
|
-
<div class="panel-heading">Whoops! There were some errors saving your <%= model.class.model_name.
|
2
|
+
<div class="panel-heading">Whoops! There were some errors saving your <%= model.class.model_name.demodulize.downcase %>:</div>
|
3
3
|
|
4
4
|
<div class="panel-body">
|
5
5
|
<ul>
|
@@ -17,6 +17,7 @@ module Detour::ActsAsFlaggable
|
|
17
17
|
dependent: :destroy,
|
18
18
|
conditions: { flaggable_type: "#{self}" }
|
19
19
|
|
20
|
+
set_human_attribute_name(:"#{table_name}_percentage_flag.percentage", "Percentage")
|
20
21
|
attr_accessible :#{table_name}_percentage_flag_attributes
|
21
22
|
|
22
23
|
accepts_nested_attributes_for :#{table_name}_percentage_flag,
|
@@ -47,6 +48,7 @@ module Detour::ActsAsFlaggable
|
|
47
48
|
dependent: :destroy,
|
48
49
|
conditions: { flaggable_type: "#{self}" }
|
49
50
|
|
51
|
+
set_human_attribute_name(:"#{table_name}_flag_ins.#{self.model_name}", "#{self.model_name}")
|
50
52
|
attr_accessible :#{table_name}_flag_ins_attributes
|
51
53
|
accepts_nested_attributes_for :#{table_name}_flag_ins, allow_destroy: true
|
52
54
|
|
@@ -56,10 +58,15 @@ module Detour::ActsAsFlaggable
|
|
56
58
|
dependent: :destroy,
|
57
59
|
conditions: { flaggable_type: "#{self}" }
|
58
60
|
|
61
|
+
set_human_attribute_name(:"#{table_name}_opt_outs.#{self.model_name}", "#{self.model_name}")
|
59
62
|
attr_accessible :#{table_name}_opt_outs_attributes
|
60
63
|
accepts_nested_attributes_for :#{table_name}_opt_outs, allow_destroy: true
|
61
64
|
EOF
|
62
65
|
|
66
|
+
Detour::Group.class_eval <<-EOF
|
67
|
+
set_human_attribute_name(:"memberships.#{self.model_name}", "#{self.model_name}")
|
68
|
+
EOF
|
69
|
+
|
63
70
|
class_eval do
|
64
71
|
@detour_flaggable_find_by = :id
|
65
72
|
|
data/lib/detour/version.rb
CHANGED
@@ -62,6 +62,12 @@ describe "creating a group", js: true do
|
|
62
62
|
click_button "Create Group"
|
63
63
|
end
|
64
64
|
|
65
|
+
it "displays a correct error header" do
|
66
|
+
within ".modal .panel-heading" do
|
67
|
+
page.should have_content "Whoops! There were some errors saving your group:"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
65
71
|
it "displays error messages" do
|
66
72
|
page.should have_content "Name can't be blank"
|
67
73
|
end
|
@@ -135,8 +141,14 @@ describe "adding a member to a group", js: true do
|
|
135
141
|
click_button "Update Group"
|
136
142
|
end
|
137
143
|
|
144
|
+
it "displays a correct error header" do
|
145
|
+
within ".panel-danger .panel-heading" do
|
146
|
+
page.should have_content "Whoops! There were some errors saving your group:"
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
138
150
|
it "displays error messages" do
|
139
|
-
page.should have_content "
|
151
|
+
page.should have_content "User \"\" could not be found"
|
140
152
|
end
|
141
153
|
end
|
142
154
|
end
|
@@ -89,6 +89,12 @@ describe "creating a new feature", js: true do
|
|
89
89
|
click_button "Create Feature"
|
90
90
|
end
|
91
91
|
|
92
|
+
it "displays a correct error header" do
|
93
|
+
within ".modal .panel-heading" do
|
94
|
+
page.should have_content "Whoops! There were some errors saving your feature:"
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
92
98
|
it "displays error messages" do
|
93
99
|
page.should have_content "Name can't be blank"
|
94
100
|
end
|
@@ -22,6 +22,12 @@ describe "listing flag_in_flags" do
|
|
22
22
|
visit "/detour/flag-ins/#{flag.feature.name}/users"
|
23
23
|
end
|
24
24
|
|
25
|
+
it "displays the correct header" do
|
26
|
+
within "h1" do
|
27
|
+
page.should have_content "Users flagged in to #{flag.feature.name}"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
25
31
|
it "displays the flagged-in model's find-by" do
|
26
32
|
page.find("input[type='text'][disabled]").value.should eq flag.flaggable.email
|
27
33
|
end
|
@@ -58,8 +64,14 @@ describe "creating a flag-in", js: true do
|
|
58
64
|
click_button "Update Flag-in"
|
59
65
|
end
|
60
66
|
|
67
|
+
it "displays a correct error header" do
|
68
|
+
within ".panel-danger .panel-heading" do
|
69
|
+
page.should have_content "Whoops! There were some errors saving your flag-ins:"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
61
73
|
it "displays error messages" do
|
62
|
-
page.should have_content "
|
74
|
+
page.should have_content "User \"\" could not be found"
|
63
75
|
end
|
64
76
|
end
|
65
77
|
end
|
@@ -22,6 +22,12 @@ describe "listing opt_out_flags" do
|
|
22
22
|
visit "/detour/opt-outs/#{flag.feature.name}/users"
|
23
23
|
end
|
24
24
|
|
25
|
+
it "displays the correct header" do
|
26
|
+
within "h1" do
|
27
|
+
page.should have_content "Users opted out of #{flag.feature.name}"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
25
31
|
it "displays the opted-out model's find-by" do
|
26
32
|
page.find("input[type='text'][disabled]").value.should eq flag.flaggable.email
|
27
33
|
end
|
@@ -58,8 +64,14 @@ describe "creating a opt-out", js: true do
|
|
58
64
|
click_button "Update Opt-outs"
|
59
65
|
end
|
60
66
|
|
67
|
+
it "displays a correct error header" do
|
68
|
+
within ".panel-danger .panel-heading" do
|
69
|
+
page.should have_content "Whoops! There were some errors saving your opt-outs:"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
61
73
|
it "displays error messages" do
|
62
|
-
page.should have_content "
|
74
|
+
page.should have_content "User \"\" could not be found"
|
63
75
|
end
|
64
76
|
end
|
65
77
|
end
|
@@ -42,7 +42,7 @@ describe "creating a percentage flag" do
|
|
42
42
|
end
|
43
43
|
|
44
44
|
it "displays error messages" do
|
45
|
-
page.should have_content "#{feature.name}:
|
45
|
+
page.should have_content "#{feature.name}: Percentage is not a number"
|
46
46
|
end
|
47
47
|
end
|
48
48
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: detour
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Clem
|
@@ -244,6 +244,7 @@ files:
|
|
244
244
|
- app/helpers/detour/flaggable_flags_helper.rb
|
245
245
|
- app/helpers/detour/flags_helper.rb
|
246
246
|
- app/models/detour/concerns/countable_flag.rb
|
247
|
+
- app/models/detour/concerns/custom_human_attributes.rb
|
247
248
|
- app/models/detour/concerns/keepable.rb
|
248
249
|
- app/models/detour/database_group_flag.rb
|
249
250
|
- app/models/detour/defined_group.rb
|