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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 56b427edb8fe39d2b124dde7956617717f7a31d2
4
- data.tar.gz: 1de6769e6f69d524232fa2a2f6d60e9c0214ed9b
3
+ metadata.gz: a220248ad207160603f672e811b577ed86219921
4
+ data.tar.gz: c7538218ad95016610473c86ab3d35fc633b66b1
5
5
  SHA512:
6
- metadata.gz: 8dac7e6ee1f0d717b735530382354b080eba36cbcae8b6d66191a6d6e6f6bf468a8ce2a105670db292cea968b027627fecd2c1dc35cecd88b1dc8463238360f3
7
- data.tar.gz: dcff87181b0126f6c6276b4a01549f8af074ff8064fd69b09ca16065722dbc0f093c8c52f8f41b50e648f0cb4b62f5267eae6029c442246d9df908a05bb90ab2
6
+ metadata.gz: 37cf839b98df18604e536b699239c5a7425bd37d3c301c5770f84646906cfc43edbd2e3e006bb795907e3083ec140839deff96d5138240cd3d4c6a64da4530e5
7
+ data.tar.gz: fdc0b1a0f69bbf0e6e669903777f0c3ae6011987ec0b18aebe77c8466dca2255e9e9e55ef25fb8b6953043ec0a4fc081d081b3eb99b6fb35a5c7bbd9ba83967b
@@ -12,7 +12,7 @@ module Detour::FlaggableFlagsHelper
12
12
  end
13
13
 
14
14
  def flag_type
15
- params[:flag_type].underscore
15
+ params[:flag_type].underscore.singularize
16
16
  end
17
17
 
18
18
  def flag_verb
@@ -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
@@ -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
- <ul>
5
- <% @feature.errors.full_messages.each do |msg| %>
6
- <li><%= msg %></li>
7
- <% end %>
8
- </ul>
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
- <ul>
5
- <% @group.errors.full_messages.each do |msg| %>
6
- <li><%= msg %></li>
7
- <% end %>
8
- </ul>
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.singular %>:</div>
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
 
@@ -1,3 +1,3 @@
1
1
  module Detour
2
- VERSION = "0.0.14"
2
+ VERSION = "0.0.15"
3
3
  end
@@ -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 "Memberships user \"\" could not be found"
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 "Users flag ins user \"\" could not be found"
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 "Users opt outs user \"\" could not be found"
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}: Users percentage flag percentage is not a number"
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.14
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