show_for 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -2
- data/README.md +25 -19
- data/lib/generators/show_for/install_generator.rb +1 -1
- data/lib/show_for/association.rb +2 -2
- data/lib/show_for/attribute.rb +4 -6
- data/lib/show_for/content.rb +6 -6
- data/lib/show_for/helper.rb +1 -1
- data/lib/show_for/label.rb +1 -1
- data/lib/show_for/version.rb +1 -1
- data/test/association_test.rb +11 -11
- data/test/attribute_test.rb +32 -28
- data/test/builder_test.rb +9 -9
- data/test/content_test.rb +6 -6
- data/test/helper_test.rb +6 -6
- data/test/label_test.rb +11 -11
- data/test/support/misc_helpers.rb +7 -7
- data/test/support/models.rb +1 -1
- data/test/test_helper.rb +11 -16
- data/test/value_test.rb +8 -9
- metadata +11 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f887e097d4512d2b054ca7dde3017a18c4389d6fe376a254518474fb266e99da
|
4
|
+
data.tar.gz: 6f1be23083f6459f303f87a5060d3ae7494c15d9754db16d0a2565aa1ef595d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73ca01b5978117f4b942f7784cb8da9d7b3651ab1ad3c8b6995864fd057e7af172e17f7035d24467fdc1171bb00385a9314b26b71abdfe9d6cf5d05a1d50bcb4
|
7
|
+
data.tar.gz: b122b66cdc14e4db341337e37b1f23726354580448e3e311c4d3ba49b54d06bb4bd448a3edec6a29aaad5274999ec5f021268dd25c0120591eef9c0d15f68f76
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,9 @@
|
|
1
|
-
##
|
1
|
+
## 0.8.0
|
2
|
+
|
3
|
+
* Respect `nil` value when provided, by skipping model attribute value.
|
4
|
+
* Add support for Ruby 3.0, drop support for Ruby < 2.5.
|
5
|
+
* Add support for Rails 6.1, drop support for Rails < 5.2.
|
6
|
+
* Move CI to GitHub Actions.
|
2
7
|
|
3
8
|
## 0.7.0
|
4
9
|
|
@@ -125,7 +130,7 @@
|
|
125
130
|
## 0.1.2
|
126
131
|
|
127
132
|
### enhancements
|
128
|
-
* allow `f.attribute :nickname, :
|
133
|
+
* allow `f.attribute :nickname, in: :profile` as association shortcut
|
129
134
|
|
130
135
|
### deprecations
|
131
136
|
* `:method` now becomes `:using`
|
data/README.md
CHANGED
@@ -1,26 +1,25 @@
|
|
1
1
|
# ShowFor
|
2
2
|
|
3
3
|
[![Gem Version](https://fury-badge.herokuapp.com/rb/show_for.png)](http://badge.fury.io/rb/show_for)
|
4
|
-
[![
|
5
|
-
[![Code Climate](https://codeclimate.com/github/plataformatec/show_for.png)](https://codeclimate.com/github/plataformatec/show_for)
|
4
|
+
[![Code Climate](https://codeclimate.com/github/heartcombo/show_for.png)](https://codeclimate.com/github/heartcombo/show_for)
|
6
5
|
|
7
6
|
ShowFor allows you to quickly show a model information with I18n features.
|
8
7
|
|
9
8
|
```erb
|
10
9
|
<%= show_for @user do |u| %>
|
11
10
|
<%= u.attribute :name %>
|
12
|
-
<%= u.attribute :nickname, :
|
11
|
+
<%= u.attribute :nickname, in: :profile %>
|
13
12
|
<%= u.attribute :confirmed? %>
|
14
|
-
<%= u.attribute :created_at, :
|
15
|
-
<%= u.attribute :last_sign_in_at, :
|
16
|
-
:
|
13
|
+
<%= u.attribute :created_at, format: :short %>
|
14
|
+
<%= u.attribute :last_sign_in_at, if_blank: "User did not access yet",
|
15
|
+
wrapper_html: { id: "sign_in_timestamp" } %>
|
17
16
|
|
18
17
|
<%= u.attribute :photo do %>
|
19
18
|
<%= image_tag(@user.photo_url) %>
|
20
19
|
<% end %>
|
21
20
|
|
22
21
|
<%= u.association :company %>
|
23
|
-
<%= u.association :tags, :
|
22
|
+
<%= u.association :tags, to_sentence: true %>
|
24
23
|
<% end %>
|
25
24
|
```
|
26
25
|
|
@@ -50,11 +49,11 @@ ShowFor allows you to quickly show a model information with I18n features.
|
|
50
49
|
```erb
|
51
50
|
<%= show_for @admin do |a| %>
|
52
51
|
<%= a.attribute :name %>
|
53
|
-
<%= a.attribute :login, :
|
52
|
+
<%= a.attribute :login, value: :upcase %>
|
54
53
|
<%= a.attribute :confirmed? %>
|
55
|
-
<%= a.attribute :created_at, :
|
56
|
-
<%= a.attribute :last_sign_in_at, :
|
57
|
-
:
|
54
|
+
<%= a.attribute :created_at, format: :short %>
|
55
|
+
<%= a.attribute :last_sign_in_at, if_blank: "Administrator did not access yet"
|
56
|
+
wrapper_html: { id: "sign_in_timestamp" } %>
|
58
57
|
|
59
58
|
<%= a.attribute :photo do %>
|
60
59
|
<%= image_tag(@admin.photo_url) %>
|
@@ -141,8 +140,8 @@ ShowFor also exposes the label method. In case you want to use the default
|
|
141
140
|
`human_attribute_name` lookup and the default wrapping:
|
142
141
|
|
143
142
|
```ruby
|
144
|
-
a.label :name
|
145
|
-
a.label "Name", :
|
143
|
+
a.label :name #=> <strong class="label">Name</strong>
|
144
|
+
a.label "Name", id: "my_name" #=> <strong class="label" id="my_name">Name</strong>
|
146
145
|
```
|
147
146
|
|
148
147
|
Optionally, if you want to wrap the inner part of the label with some text
|
@@ -163,16 +162,16 @@ ShowFor also supports associations.
|
|
163
162
|
```erb
|
164
163
|
<%= show_for @artwork do |a| %>
|
165
164
|
<%= a.association :artist %>
|
166
|
-
<%= a.association :artist, :
|
167
|
-
<%= a.attribute :name_with_title, :
|
165
|
+
<%= a.association :artist, using: :name_with_title %>
|
166
|
+
<%= a.attribute :name_with_title, in: :artist %>
|
168
167
|
|
169
168
|
<%= a.association :tags %>
|
170
|
-
<%= a.association :tags, :
|
169
|
+
<%= a.association :tags, to_sentence: true %>
|
171
170
|
<%= a.association :tags do
|
172
171
|
@artwork.tags.map(&:name).to_sentence
|
173
172
|
end %>
|
174
173
|
|
175
|
-
<%= a.association :fans, :
|
174
|
+
<%= a.association :fans, collection_tag: :ol do |fan| %>
|
176
175
|
<li><%= link_to fan.name, fan %></li>
|
177
176
|
<% end %>
|
178
177
|
<% end %>
|
@@ -196,7 +195,7 @@ collection objects.
|
|
196
195
|
Here are some other examples of the many possibilites to custom the output content:
|
197
196
|
|
198
197
|
```erb
|
199
|
-
<%= u.association :relationships, :
|
198
|
+
<%= u.association :relationships, label: 'test' do %>
|
200
199
|
<% @user.relationships.each do |relation| %>
|
201
200
|
<%= relation.related_user.name if relation.related_user_role == 'supervisor' %>
|
202
201
|
<% end %>
|
@@ -216,10 +215,17 @@ Here are some other examples of the many possibilites to custom the output conte
|
|
216
215
|
|
217
216
|
* Jonas Grimfelt (http://github.com/grimen)
|
218
217
|
|
218
|
+
## Supported Ruby / Rails versions
|
219
|
+
|
220
|
+
We intend to maintain support for all Ruby / Rails versions that haven't reached end-of-life.
|
221
|
+
|
222
|
+
For more information about specific versions please check [Ruby](https://www.ruby-lang.org/en/downloads/branches/)
|
223
|
+
and [Rails](https://guides.rubyonrails.org/maintenance_policy.html) maintenance policies, and our test matrix.
|
224
|
+
|
219
225
|
## Bugs and Feedback
|
220
226
|
|
221
227
|
If you discover any bugs or want to drop a line, feel free to create an issue on GitHub.
|
222
228
|
|
223
|
-
http://github.com/
|
229
|
+
http://github.com/heartcombo/show_for/issues
|
224
230
|
|
225
231
|
MIT License. Copyright 2012-2019 Plataformatec. http://plataformatec.com.br
|
@@ -2,7 +2,7 @@ module ShowFor
|
|
2
2
|
module Generators
|
3
3
|
class InstallGenerator < Rails::Generators::Base
|
4
4
|
desc "Copy ShowFor installation files"
|
5
|
-
class_option :template_engine, :
|
5
|
+
class_option :template_engine, desc: 'Template engine to be invoked (erb or haml or slim).'
|
6
6
|
source_root File.expand_path('../templates', __FILE__)
|
7
7
|
|
8
8
|
def copy_initializers
|
data/lib/show_for/association.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module ShowFor
|
2
2
|
module Association
|
3
|
-
def attribute(attribute_name, options={}, &block)
|
3
|
+
def attribute(attribute_name, options = {}, &block)
|
4
4
|
if association_name = options.delete(:in)
|
5
5
|
options[:using] = attribute_name
|
6
6
|
association(association_name, options, &block)
|
@@ -9,7 +9,7 @@ module ShowFor
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
def association(association_name, options={}, &block)
|
12
|
+
def association(association_name, options = {}, &block)
|
13
13
|
apply_default_options!(association_name, options)
|
14
14
|
|
15
15
|
# If a block with an iterator was given, no need to calculate the labels
|
data/lib/show_for/attribute.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module ShowFor
|
2
2
|
module Attribute
|
3
|
-
def attribute(attribute_name, options={}, &block)
|
3
|
+
def attribute(attribute_name, options = {}, &block)
|
4
4
|
apply_default_options!(attribute_name, options)
|
5
5
|
block = block_from_value_option(attribute_name, options) unless block
|
6
6
|
collection_block, block = block, nil if collection_block?(block)
|
@@ -10,7 +10,7 @@ module ShowFor
|
|
10
10
|
wrap_label_and_content(attribute_name, value, options, &collection_block)
|
11
11
|
end
|
12
12
|
|
13
|
-
def value(attribute_name, options={}, &block)
|
13
|
+
def value(attribute_name, options = {}, &block)
|
14
14
|
apply_default_options!(attribute_name, options)
|
15
15
|
collection_block, block = block, nil if collection_block?(block)
|
16
16
|
|
@@ -38,10 +38,9 @@ module ShowFor
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def block_from_value_option(attribute_name, options)
|
41
|
-
|
42
|
-
when nil
|
41
|
+
if !options.has_key?(:value)
|
43
42
|
nil
|
44
|
-
|
43
|
+
elsif options[:value].is_a?(Symbol)
|
45
44
|
block_from_symbol(attribute_name, options)
|
46
45
|
else
|
47
46
|
lambda { options[:value].to_s }
|
@@ -59,4 +58,3 @@ module ShowFor
|
|
59
58
|
end
|
60
59
|
end
|
61
60
|
end
|
62
|
-
|
data/lib/show_for/content.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module ShowFor
|
2
2
|
module Content
|
3
|
-
def content(value, options={}, apply_options=true, &block)
|
3
|
+
def content(value, options = {}, apply_options = true, &block)
|
4
4
|
# cache value for apply_wrapper_options!
|
5
5
|
sample_value = value
|
6
6
|
|
@@ -10,11 +10,11 @@ module ShowFor
|
|
10
10
|
|
11
11
|
content = case value
|
12
12
|
when Date, Time, DateTime
|
13
|
-
I18n.l value, :
|
13
|
+
I18n.l value, format: options.delete(:format) || ShowFor.i18n_format
|
14
14
|
when TrueClass
|
15
|
-
I18n.t :"show_for.yes", :
|
15
|
+
I18n.t :"show_for.yes", default: "Yes"
|
16
16
|
when FalseClass
|
17
|
-
I18n.t :"show_for.no", :
|
17
|
+
I18n.t :"show_for.no", default: "No"
|
18
18
|
when Array, Hash
|
19
19
|
collection_handler(value, options, &block) unless value.empty?
|
20
20
|
when Proc
|
@@ -48,11 +48,11 @@ module ShowFor
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def translate_blank_html
|
51
|
-
template.t(:'show_for.blank_html', :
|
51
|
+
template.t(:'show_for.blank_html', default: translate_blank_text)
|
52
52
|
end
|
53
53
|
|
54
54
|
def translate_blank_text
|
55
|
-
I18n.t(:'show_for.blank', :
|
55
|
+
I18n.t(:'show_for.blank', default: "Not specified")
|
56
56
|
end
|
57
57
|
|
58
58
|
def blank_value(options)
|
data/lib/show_for/helper.rb
CHANGED
data/lib/show_for/label.rb
CHANGED
data/lib/show_for/version.rb
CHANGED
data/test/association_test.rb
CHANGED
@@ -7,17 +7,17 @@ class AssociationTest < ActionView::TestCase
|
|
7
7
|
end
|
8
8
|
|
9
9
|
test "show_for accepts :using as option to tell how to retrieve association value" do
|
10
|
-
with_association_for @user, :company, :
|
10
|
+
with_association_for @user, :company, using: :alternate_name
|
11
11
|
assert_select "div.show_for div.wrapper", /Alternate Plataformatec/
|
12
12
|
end
|
13
13
|
|
14
14
|
test "show_for accepts :in to tell to retrieve an attribute from association" do
|
15
|
-
with_attribute_for @user, :alternate_name, :
|
15
|
+
with_attribute_for @user, :alternate_name, in: :company
|
16
16
|
assert_select "div.show_for div.wrapper", /Alternate Plataformatec/
|
17
17
|
end
|
18
18
|
|
19
19
|
test "show_for forwards all options send with :in to association" do
|
20
|
-
with_attribute_for @user, :alternate_name, :
|
20
|
+
with_attribute_for @user, :alternate_name, in: :tags, to_sentence: true
|
21
21
|
assert_no_select "div.show_for div.wrapper ul.collection"
|
22
22
|
assert_select "div.show_for div.wrapper", /Alternate Tag 1, Alternate Tag 2, and Alternate Tag 3/
|
23
23
|
end
|
@@ -35,7 +35,7 @@ class AssociationTest < ActionView::TestCase
|
|
35
35
|
[]
|
36
36
|
end
|
37
37
|
|
38
|
-
swap ShowFor, :
|
38
|
+
swap ShowFor, association_methods: [:name] do
|
39
39
|
with_association_for @user, :tags
|
40
40
|
assert_no_select "div.show_for div.wrapper ul.collection"
|
41
41
|
assert_no_select "div.show_for div.wrapper", /Enumerator/
|
@@ -47,7 +47,7 @@ class AssociationTest < ActionView::TestCase
|
|
47
47
|
[]
|
48
48
|
end
|
49
49
|
|
50
|
-
swap ShowFor, :
|
50
|
+
swap ShowFor, association_methods: [:name] do
|
51
51
|
with_association_for @user, :tags do |tag|
|
52
52
|
tag.name
|
53
53
|
end
|
@@ -89,7 +89,7 @@ class AssociationTest < ActionView::TestCase
|
|
89
89
|
end
|
90
90
|
|
91
91
|
test "show_for accepts :using as option to tell how to retrieve association values" do
|
92
|
-
with_association_for @user, :tags, :
|
92
|
+
with_association_for @user, :tags, using: :alternate_name
|
93
93
|
assert_select "div.show_for div.wrapper ul.collection"
|
94
94
|
assert_select "div.show_for div.wrapper ul.collection li", "Alternate Tag 1"
|
95
95
|
assert_select "div.show_for div.wrapper ul.collection li", "Alternate Tag 2"
|
@@ -97,13 +97,13 @@ class AssociationTest < ActionView::TestCase
|
|
97
97
|
end
|
98
98
|
|
99
99
|
test "show_for accepts :to_sentence as option in collection associations" do
|
100
|
-
with_association_for @user, :tags, :
|
100
|
+
with_association_for @user, :tags, to_sentence: true
|
101
101
|
assert_no_select "div.show_for div.wrapper ul.collection"
|
102
102
|
assert_select "div.show_for div.wrapper", /Tag 1, Tag 2, and Tag 3/
|
103
103
|
end
|
104
104
|
|
105
105
|
test "show_for accepts :join as option in collection associations" do
|
106
|
-
with_association_for @user, :tags, :
|
106
|
+
with_association_for @user, :tags, join: ", "
|
107
107
|
assert_no_select "div.show_for div.wrapper ul.collection"
|
108
108
|
assert_select "div.show_for div.wrapper", /Tag 1, Tag 2, Tag 3/
|
109
109
|
end
|
@@ -117,7 +117,7 @@ class AssociationTest < ActionView::TestCase
|
|
117
117
|
end
|
118
118
|
|
119
119
|
test "show_for accepts a block with argument in collection associations" do
|
120
|
-
with_association_for @user, :tags, :
|
120
|
+
with_association_for @user, :tags, collection_tag: :p do |tag|
|
121
121
|
assert_kind_of Tag, tag
|
122
122
|
content_tag(:span, tag.name)
|
123
123
|
end
|
@@ -133,7 +133,7 @@ class AssociationTest < ActionView::TestCase
|
|
133
133
|
[]
|
134
134
|
end
|
135
135
|
|
136
|
-
swap ShowFor, :
|
136
|
+
swap ShowFor, skip_blanks: true do
|
137
137
|
with_association_for @user, :tags
|
138
138
|
assert_no_select "div.show_for div.wrapper"
|
139
139
|
end
|
@@ -144,7 +144,7 @@ class AssociationTest < ActionView::TestCase
|
|
144
144
|
nil
|
145
145
|
end
|
146
146
|
|
147
|
-
swap ShowFor, :
|
147
|
+
swap ShowFor, skip_blanks: true do
|
148
148
|
with_association_for @user, :company
|
149
149
|
assert_no_select "div.show_for div.wrapper"
|
150
150
|
end
|
data/test/attribute_test.rb
CHANGED
@@ -5,7 +5,7 @@ class AttributeTest < ActionView::TestCase
|
|
5
5
|
test "show_for accepts an attribute as a collection" do
|
6
6
|
with_attribute_for @user, :scopes
|
7
7
|
assert_select "div.show_for div.wrapper ul.collection"
|
8
|
-
assert_select "div.show_for div.wrapper ul.collection li", :
|
8
|
+
assert_select "div.show_for div.wrapper ul.collection li", count: 3
|
9
9
|
end
|
10
10
|
|
11
11
|
test "show_for accepts an attribute as a collection with a block to iterate the collection" do
|
@@ -13,25 +13,25 @@ class AttributeTest < ActionView::TestCase
|
|
13
13
|
content_tag :span, scope
|
14
14
|
end
|
15
15
|
assert_select "div.show_for div.wrapper ul.collection"
|
16
|
-
assert_select "div.show_for div.wrapper ul.collection span", :
|
16
|
+
assert_select "div.show_for div.wrapper ul.collection span", count: 3
|
17
17
|
end
|
18
18
|
|
19
19
|
test "show_for treats symbol for :value as method on each element of collection" do
|
20
|
-
with_attribute_for @user, :scopes, :
|
20
|
+
with_attribute_for @user, :scopes, value: :upcase
|
21
21
|
@user.scopes.each do |scope|
|
22
22
|
assert_select "div.show_for div.wrapper ul.collection", /#{scope.upcase}/
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
26
|
test "show_for allows collection tag to be configured globally" do
|
27
|
-
swap ShowFor, :
|
27
|
+
swap ShowFor, collection_tag: :ol, collection_class: "my_collection" do
|
28
28
|
with_attribute_for @user, :scopes
|
29
29
|
assert_select "div.show_for div.wrapper ol.my_collection"
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
33
|
test "show_for allows collection class to be disabled globally" do
|
34
|
-
swap ShowFor, :
|
34
|
+
swap ShowFor, collection_tag: :ol, collection_class: nil do
|
35
35
|
with_attribute_for @user, :scopes
|
36
36
|
assert_select "div.show_for div.wrapper ol"
|
37
37
|
assert_no_select "ol[class]"
|
@@ -39,25 +39,25 @@ class AttributeTest < ActionView::TestCase
|
|
39
39
|
end
|
40
40
|
|
41
41
|
test "show_for allows collection tag to be changed by attribute" do
|
42
|
-
with_attribute_for @user, :scopes, :
|
42
|
+
with_attribute_for @user, :scopes, collection_tag: :ol
|
43
43
|
assert_select "div.show_for div.wrapper ol.collection"
|
44
44
|
end
|
45
45
|
|
46
46
|
test "show_for allows collection tag html to be configured by attribute" do
|
47
|
-
with_attribute_for @user, :scopes, :
|
47
|
+
with_attribute_for @user, :scopes, collection_html: { id: "thecollection", class: "special" }
|
48
48
|
assert_select "div.show_for div.wrapper ul#thecollection.special.collection"
|
49
49
|
end
|
50
50
|
|
51
51
|
# CONTENT
|
52
52
|
test "show_for allows content tag to be configured globally" do
|
53
|
-
swap ShowFor, :
|
53
|
+
swap ShowFor, content_tag: :span, content_class: :my_content do
|
54
54
|
with_attribute_for @user, :name
|
55
55
|
assert_select "div.show_for div.wrapper span.my_content"
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
59
|
test "show_for allows content class to be disabled globally" do
|
60
|
-
swap ShowFor, :
|
60
|
+
swap ShowFor, content_tag: :span, content_class: nil do
|
61
61
|
with_attribute_for @user, :name
|
62
62
|
assert_select "div.show_for div.wrapper span"
|
63
63
|
assert_no_select "span[class]"
|
@@ -65,12 +65,12 @@ class AttributeTest < ActionView::TestCase
|
|
65
65
|
end
|
66
66
|
|
67
67
|
test "show_for allows content tag to be changed by attribute" do
|
68
|
-
with_attribute_for @user, :name, :
|
68
|
+
with_attribute_for @user, :name, content_tag: :span
|
69
69
|
assert_select "div.show_for div.wrapper span.content"
|
70
70
|
end
|
71
71
|
|
72
72
|
test "show_for allows content tag html to be configured by attribute" do
|
73
|
-
with_attribute_for @user, :name, :
|
73
|
+
with_attribute_for @user, :name, content_tag: :span, content_html: { id: "thecontent", class: "special" }
|
74
74
|
assert_select "div.show_for div.wrapper span#thecontent.special.content"
|
75
75
|
end
|
76
76
|
|
@@ -90,8 +90,8 @@ class AttributeTest < ActionView::TestCase
|
|
90
90
|
end
|
91
91
|
|
92
92
|
test "show_for accepts an attribute as time with format options" do
|
93
|
-
with_attribute_for @user, :created_at, :
|
94
|
-
assert_select "div.show_for div.wrapper", /#{Regexp.escape(I18n.l(@user.created_at, :
|
93
|
+
with_attribute_for @user, :created_at, format: :long
|
94
|
+
assert_select "div.show_for div.wrapper", /#{Regexp.escape(I18n.l(@user.created_at, format: :long))}/
|
95
95
|
end
|
96
96
|
|
97
97
|
test "show_for accepts an attribute as true" do
|
@@ -100,7 +100,7 @@ class AttributeTest < ActionView::TestCase
|
|
100
100
|
end
|
101
101
|
|
102
102
|
test "show_for accepts an attribute as true which can be localized" do
|
103
|
-
store_translations(:en, :
|
103
|
+
store_translations(:en, show_for: { yes: "Hell yeah!" }) do
|
104
104
|
with_attribute_for @user, :active
|
105
105
|
assert_select "div.show_for div.wrapper", /Hell yeah!/
|
106
106
|
end
|
@@ -112,7 +112,7 @@ class AttributeTest < ActionView::TestCase
|
|
112
112
|
end
|
113
113
|
|
114
114
|
test "show_for accepts an attribute as false which can be localized" do
|
115
|
-
store_translations(:en, :
|
115
|
+
store_translations(:en, show_for: { no: "Hell no!" }) do
|
116
116
|
with_attribute_for @user, :invalid
|
117
117
|
assert_select "div.show_for div.wrapper", /Hell no!/
|
118
118
|
end
|
@@ -124,21 +124,21 @@ class AttributeTest < ActionView::TestCase
|
|
124
124
|
end
|
125
125
|
|
126
126
|
test "show_for accepts not spcified message can be localized" do
|
127
|
-
store_translations(:en, :
|
127
|
+
store_translations(:en, show_for: { blank: "OMG! It's blank!" }) do
|
128
128
|
with_attribute_for @user, :description
|
129
129
|
assert_select "div.show_for div.wrapper", /OMG! It's blank!/
|
130
130
|
end
|
131
131
|
end
|
132
132
|
|
133
133
|
test "show_for accepts not spcified message can be localized with html" do
|
134
|
-
store_translations(:en, :
|
134
|
+
store_translations(:en, show_for: { blank_html: "<span>OMG! It's blank!</span>" }) do
|
135
135
|
with_attribute_for @user, :description
|
136
136
|
assert_select "div.show_for div.wrapper span", "OMG! It's blank!"
|
137
137
|
end
|
138
138
|
end
|
139
139
|
|
140
140
|
test "show_for uses :if_blank if attribute is blank" do
|
141
|
-
with_attribute_for @user, :description, :
|
141
|
+
with_attribute_for @user, :description, if_blank: "No description provided"
|
142
142
|
assert_select "div.show_for div.wrapper", /No description provided/
|
143
143
|
end
|
144
144
|
|
@@ -150,7 +150,7 @@ class AttributeTest < ActionView::TestCase
|
|
150
150
|
end
|
151
151
|
|
152
152
|
test "show_for uses :if_blank if the block content is blank" do
|
153
|
-
with_attribute_for @user, :description, :
|
153
|
+
with_attribute_for @user, :description, if_blank: "No description provided" do
|
154
154
|
""
|
155
155
|
end
|
156
156
|
assert_select "div.show_for div.wrapper", /No description provided/
|
@@ -167,8 +167,7 @@ class AttributeTest < ActionView::TestCase
|
|
167
167
|
@user.name = "<b>hack you!</b>"
|
168
168
|
with_attribute_for @user, :name
|
169
169
|
assert_no_select "div.show_for div.wrapper b"
|
170
|
-
assert_select "div.show_for div.wrapper",
|
171
|
-
rails_42? ? "Super User Name!<b>hack you!</b>" : "Super User Name!<b>hack you!</b>"
|
170
|
+
assert_select "div.show_for div.wrapper", "Super User Name!<b>hack you!</b>"
|
172
171
|
end
|
173
172
|
|
174
173
|
test "show_for works with html_safe marked strings" do
|
@@ -178,36 +177,41 @@ class AttributeTest < ActionView::TestCase
|
|
178
177
|
end
|
179
178
|
|
180
179
|
test "show_for uses :value if supplied" do
|
181
|
-
with_attribute_for @user, :name, :
|
180
|
+
with_attribute_for @user, :name, value: "Calculated Value"
|
182
181
|
assert_select "div.show_for div.wrapper", /Calculated Value/
|
183
182
|
end
|
184
183
|
|
185
184
|
test "show_for uses :value and casts to string if supplied" do
|
186
|
-
with_attribute_for @user, :name, :
|
185
|
+
with_attribute_for @user, :name, value: 123
|
187
186
|
assert_select "div.show_for div.wrapper", /123/
|
188
187
|
end
|
189
188
|
|
189
|
+
test "show_for ignores attribute if :value supplied but with nil value" do
|
190
|
+
with_attribute_for @user, :name, value: nil
|
191
|
+
assert_select "div.show_for div.wrapper", /Not specified/
|
192
|
+
end
|
193
|
+
|
190
194
|
test "show_for ignores :value if a block is supplied" do
|
191
|
-
with_attribute_for @user, :name, :
|
195
|
+
with_attribute_for @user, :name, value: "Calculated Value" do
|
192
196
|
@user.name.upcase
|
193
197
|
end
|
194
198
|
assert_select "div.show_for div.wrapper", /#{@user.name.upcase}/
|
195
199
|
end
|
196
200
|
|
197
201
|
test "show_for treats symbol for :value as method on attribute" do
|
198
|
-
with_attribute_for @user, :name, :
|
202
|
+
with_attribute_for @user, :name, value: :upcase
|
199
203
|
assert_select "div.show_for div.wrapper", /#{@user.name.upcase}/
|
200
204
|
end
|
201
205
|
|
202
206
|
test "show_for does not display blank attribute if skip_blanks option is passed" do
|
203
|
-
swap ShowFor, :
|
207
|
+
swap ShowFor, skip_blanks: true do
|
204
208
|
with_attribute_for @user, :description
|
205
209
|
assert_no_select "div.show_for div.wrapper"
|
206
210
|
end
|
207
211
|
end
|
208
212
|
|
209
213
|
test "show_for display false attribute if skip_blanks option is passed" do
|
210
|
-
swap ShowFor, :
|
214
|
+
swap ShowFor, skip_blanks: true do
|
211
215
|
with_attribute_for @user, :invalid
|
212
216
|
assert_select "div.show_for div.wrapper", /No/
|
213
217
|
end
|
@@ -223,7 +227,7 @@ class AttributeTest < ActionView::TestCase
|
|
223
227
|
end
|
224
228
|
|
225
229
|
test "show_for should wrap blank attributes with no_attribute" do
|
226
|
-
swap ShowFor, :
|
230
|
+
swap ShowFor, blank_content_class: 'no_attribute' do
|
227
231
|
with_attributes_for @user, :name, :birthday, :karma
|
228
232
|
assert_select ".wrapper.user_birthday.no_attribute"
|
229
233
|
assert_select ".wrapper.user_karma.no_attribute"
|
data/test/builder_test.rb
CHANGED
@@ -3,7 +3,7 @@ require 'test_helper'
|
|
3
3
|
class BuilderTest < ActionView::TestCase
|
4
4
|
# WRAPPER
|
5
5
|
test "show_for allows wrapper to be configured globally" do
|
6
|
-
swap ShowFor, :
|
6
|
+
swap ShowFor, wrapper_tag: "li", wrapper_class: "my_wrapper" do
|
7
7
|
with_attribute_for @user, :name
|
8
8
|
assert_select "div.show_for li.user_name.my_wrapper"
|
9
9
|
assert_select "div.show_for li.my_wrapper strong.label"
|
@@ -12,7 +12,7 @@ class BuilderTest < ActionView::TestCase
|
|
12
12
|
end
|
13
13
|
|
14
14
|
test "show_for allows wrapper class to be disabled globally" do
|
15
|
-
swap ShowFor, :
|
15
|
+
swap ShowFor, wrapper_tag: "li", wrapper_class: nil do
|
16
16
|
with_attribute_for @user, :name
|
17
17
|
assert_select "div.show_for li[class='user_name']"
|
18
18
|
end
|
@@ -26,7 +26,7 @@ class BuilderTest < ActionView::TestCase
|
|
26
26
|
end
|
27
27
|
|
28
28
|
test "show_for properly deals with namespaced models" do
|
29
|
-
@user = Namespaced::User.new(:
|
29
|
+
@user = Namespaced::User.new(id: 1, name: "ShowFor")
|
30
30
|
|
31
31
|
with_attribute_for @user, :name
|
32
32
|
assert_select "div.show_for div.namespaced_user_name.wrapper"
|
@@ -35,18 +35,18 @@ class BuilderTest < ActionView::TestCase
|
|
35
35
|
end
|
36
36
|
|
37
37
|
test "show_for allows wrapper tag to be changed by attribute" do
|
38
|
-
with_attribute_for @user, :name, :
|
38
|
+
with_attribute_for @user, :name, wrapper_tag: :span
|
39
39
|
assert_select "div.show_for span.user_name.wrapper"
|
40
40
|
end
|
41
41
|
|
42
42
|
test "show_for allows wrapper html to be configured by attribute" do
|
43
|
-
with_attribute_for @user, :name, :
|
43
|
+
with_attribute_for @user, :name, wrapper_html: { id: "thewrapper", class: "special" }
|
44
44
|
assert_select "div.show_for div#thewrapper.user_name.wrapper.special"
|
45
45
|
end
|
46
46
|
|
47
47
|
# SEPARATOR
|
48
48
|
test "show_for allows separator to be configured globally" do
|
49
|
-
swap ShowFor, :
|
49
|
+
swap ShowFor, separator: '<span class="separator"></span>' do
|
50
50
|
with_attribute_for @user, :name
|
51
51
|
assert_select "div.show_for div.user_name span.separator"
|
52
52
|
assert_select "div.show_for div.wrapper span.separator"
|
@@ -55,13 +55,13 @@ class BuilderTest < ActionView::TestCase
|
|
55
55
|
end
|
56
56
|
|
57
57
|
test "show_for allows separator to be changed by attribute"do
|
58
|
-
with_attribute_for @user, :name, :
|
58
|
+
with_attribute_for @user, :name, separator: '<span class="separator"></span>'
|
59
59
|
assert_select "div.show_for div.wrapper span.separator"
|
60
60
|
assert_no_select "div.show_for br"
|
61
61
|
end
|
62
62
|
|
63
63
|
test "show_for allows disabling separator by attribute" do
|
64
|
-
with_attribute_for @user, :name, :
|
64
|
+
with_attribute_for @user, :name, separator: false
|
65
65
|
assert_no_select "div.show_for div.wrapper span.separator"
|
66
66
|
assert_no_select "div.show_for div.wrapper br"
|
67
67
|
assert_no_select "div.show_for div.wrapper", /false/
|
@@ -73,7 +73,7 @@ class BuilderTest < ActionView::TestCase
|
|
73
73
|
end
|
74
74
|
|
75
75
|
test "show_for does not blow if a separator is not set" do
|
76
|
-
swap ShowFor, :
|
76
|
+
swap ShowFor, separator: nil do
|
77
77
|
with_attribute_for @user, :name
|
78
78
|
assert_select "div.show_for div.wrapper"
|
79
79
|
end
|
data/test/content_test.rb
CHANGED
@@ -7,26 +7,26 @@ class ContentTest < ActionView::TestCase
|
|
7
7
|
end
|
8
8
|
|
9
9
|
test "show_for#content accepts :if_blank as option" do
|
10
|
-
with_content_for @user, "", :
|
10
|
+
with_content_for @user, "", if_blank: "Got blank"
|
11
11
|
assert_select "div.show_for", "Got blank"
|
12
12
|
end
|
13
13
|
|
14
14
|
test "show_for#content accepts html options" do
|
15
|
-
with_content_for @user, "Special content", :
|
15
|
+
with_content_for @user, "Special content", content_tag: :b, id: "thecontent", class: "special"
|
16
16
|
assert_select "div.show_for b#thecontent.special.content", "Special content"
|
17
17
|
assert_no_select "div.show_for b[content_tag]"
|
18
18
|
end
|
19
19
|
|
20
20
|
test "show_for#content with blank value has a 'no value'-class" do
|
21
|
-
swap ShowFor, :
|
22
|
-
with_content_for @user, nil, :
|
21
|
+
swap ShowFor, blank_content_class: "nothing" do
|
22
|
+
with_content_for @user, nil, content_tag: :b
|
23
23
|
assert_select "div.show_for b.nothing"
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
27
|
test "show_for#content with blank value does not display content if skip_blanks option is passed" do
|
28
|
-
swap ShowFor, :
|
29
|
-
with_content_for @user, nil, :
|
28
|
+
swap ShowFor, skip_blanks: true do
|
29
|
+
with_content_for @user, nil, content_tag: :b
|
30
30
|
assert_no_select "div.show_for b"
|
31
31
|
end
|
32
32
|
end
|
data/test/helper_test.rb
CHANGED
@@ -11,7 +11,7 @@ class HelperTest < ActionView::TestCase
|
|
11
11
|
end
|
12
12
|
|
13
13
|
test "show for yields an instance of builder class specified by builder option" do
|
14
|
-
show_for(@user, :
|
14
|
+
show_for(@user, builder: CustomBuilder) do |f|
|
15
15
|
assert f.instance_of?(CustomBuilder)
|
16
16
|
end
|
17
17
|
end
|
@@ -27,28 +27,28 @@ class HelperTest < ActionView::TestCase
|
|
27
27
|
end
|
28
28
|
|
29
29
|
test "show for should pass options" do
|
30
|
-
concat(show_for(@user, :
|
30
|
+
concat(show_for(@user, id: "my_div", class: "common") do |f| end)
|
31
31
|
assert_select "div#my_div.show_for.user.common"
|
32
32
|
end
|
33
33
|
|
34
34
|
test "show for tag should be configurable" do
|
35
|
-
swap ShowFor, :
|
35
|
+
swap ShowFor, show_for_tag: :p do
|
36
36
|
concat(show_for(@user) do |f| end)
|
37
37
|
assert_select "p.show_for"
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
41
|
test "show for class should be configurable" do
|
42
|
-
swap ShowFor, :
|
42
|
+
swap ShowFor, show_for_class: :awesome do
|
43
43
|
concat(show_for(@user) do |f| end)
|
44
44
|
assert_select "div.show_for.user.awesome"
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
48
|
test "show for options hash should not be modified" do
|
49
|
-
html_options = { :
|
49
|
+
html_options = { show_for_tag: :li }
|
50
50
|
concat(show_for(@user, html_options) do |f| end)
|
51
|
-
assert_equal({ :
|
51
|
+
assert_equal({ show_for_tag: :li }, html_options)
|
52
52
|
end
|
53
53
|
|
54
54
|
end
|
data/test/label_test.rb
CHANGED
@@ -7,25 +7,25 @@ class LabelTest < ActionView::TestCase
|
|
7
7
|
end
|
8
8
|
|
9
9
|
test "show_for skips label if requested" do
|
10
|
-
with_attribute_for @user, :name, :
|
10
|
+
with_attribute_for @user, :name, label: false
|
11
11
|
assert_no_select "div.show_for div.wrapper strong.label"
|
12
12
|
assert_no_select "div.show_for div.wrapper br"
|
13
13
|
end
|
14
14
|
|
15
15
|
test "show_for uses custom content_tag and skips label if requested" do
|
16
|
-
with_attribute_for @user, :name, :
|
16
|
+
with_attribute_for @user, :name, label: false, content_tag: :h2
|
17
17
|
assert_select "div.show_for div.wrapper h2.content", "ShowFor"
|
18
18
|
end
|
19
19
|
|
20
20
|
test "show_for allows label to be configured globally" do
|
21
|
-
swap ShowFor, :
|
21
|
+
swap ShowFor, label_tag: :span, label_class: "my_label" do
|
22
22
|
with_attribute_for @user, :name
|
23
23
|
assert_select "div.show_for div.wrapper span.my_label"
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
27
|
test "show_for allows label class to be disabled globally" do
|
28
|
-
swap ShowFor, :
|
28
|
+
swap ShowFor, label_tag: :span, label_class: nil do
|
29
29
|
with_attribute_for @user, :name
|
30
30
|
assert_select "div.show_for div.wrapper span"
|
31
31
|
assert_no_select "span[class]"
|
@@ -33,17 +33,17 @@ class LabelTest < ActionView::TestCase
|
|
33
33
|
end
|
34
34
|
|
35
35
|
test "show_for allows label to be changed by attribute" do
|
36
|
-
with_attribute_for @user, :name, :
|
36
|
+
with_attribute_for @user, :name, label_tag: :span
|
37
37
|
assert_select "div.show_for div.wrapper span.label"
|
38
38
|
end
|
39
39
|
|
40
40
|
test "show_for allows label html to be configured by attribute" do
|
41
|
-
with_attribute_for @user, :name, :
|
41
|
+
with_attribute_for @user, :name, label_html: { id: "thelabel", class: "special" }
|
42
42
|
assert_select "div.show_for div.wrapper strong#thelabel.special.label"
|
43
43
|
end
|
44
44
|
|
45
45
|
test "show_for allows label to be set without lookup" do
|
46
|
-
with_attribute_for @user, :name, :
|
46
|
+
with_attribute_for @user, :name, label: "Special Label"
|
47
47
|
assert_select "div.show_for div.wrapper strong.label", "Special Label"
|
48
48
|
end
|
49
49
|
|
@@ -58,20 +58,20 @@ class LabelTest < ActionView::TestCase
|
|
58
58
|
end
|
59
59
|
|
60
60
|
test "show_for#label accepts html options" do
|
61
|
-
with_label_for @user, :name, :
|
61
|
+
with_label_for @user, :name, id: "thelabel", class: "special"
|
62
62
|
assert_select "div.show_for strong#thelabel.special.label"
|
63
63
|
end
|
64
64
|
|
65
65
|
test "should let you override the label wrapper" do
|
66
|
-
swap ShowFor, :
|
66
|
+
swap ShowFor, label_proc: proc { |l| l + ":" } do
|
67
67
|
with_label_for @user, "Special Label"
|
68
68
|
assert_select "div.show_for strong.label", "Special Label:"
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
72
|
test "should you skip wrapping the label on a per item basis" do
|
73
|
-
swap ShowFor, :
|
74
|
-
with_label_for @user, "Special Label", :
|
73
|
+
swap ShowFor, label_proc: proc { |l| l + ":" } do
|
74
|
+
with_label_for @user, "Special Label", wrap_label: false
|
75
75
|
assert_select "div.show_for strong.label", "Special Label"
|
76
76
|
end
|
77
77
|
end
|
@@ -8,8 +8,8 @@ module MiscHelpers
|
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
|
-
def assert_no_select(selector, value=nil)
|
12
|
-
assert_select(selector, :
|
11
|
+
def assert_no_select(selector, value = nil)
|
12
|
+
assert_select(selector, text: value, count: 0)
|
13
13
|
end
|
14
14
|
|
15
15
|
def swap(object, new_values)
|
@@ -25,31 +25,31 @@ module MiscHelpers
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
def with_attribute_for(object, attribute, options={}, &block)
|
28
|
+
def with_attribute_for(object, attribute, options = {}, &block)
|
29
29
|
concat(show_for(object) do |o|
|
30
30
|
concat o.attribute(attribute, options, &block)
|
31
31
|
end)
|
32
32
|
end
|
33
33
|
|
34
|
-
def with_value_for(object, attribute, options={}, &block)
|
34
|
+
def with_value_for(object, attribute, options = {}, &block)
|
35
35
|
concat(show_for(object) do |o|
|
36
36
|
concat o.value(attribute, options, &block)
|
37
37
|
end)
|
38
38
|
end
|
39
39
|
|
40
|
-
def with_association_for(object, association, options={}, &block)
|
40
|
+
def with_association_for(object, association, options = {}, &block)
|
41
41
|
concat(show_for(object) do |o|
|
42
42
|
concat o.association(association, options, &block)
|
43
43
|
end)
|
44
44
|
end
|
45
45
|
|
46
|
-
def with_label_for(object, attribute, options={})
|
46
|
+
def with_label_for(object, attribute, options = {})
|
47
47
|
concat(show_for(object) do |o|
|
48
48
|
concat o.label(attribute, options)
|
49
49
|
end)
|
50
50
|
end
|
51
51
|
|
52
|
-
def with_content_for(object, value, options={})
|
52
|
+
def with_content_for(object, value, options = {})
|
53
53
|
concat(show_for(object) do |o|
|
54
54
|
concat o.content(value, options)
|
55
55
|
end)
|
data/test/support/models.rb
CHANGED
data/test/test_helper.rb
CHANGED
@@ -26,23 +26,18 @@ class ActionView::TestCase
|
|
26
26
|
|
27
27
|
setup :setup_new_user
|
28
28
|
|
29
|
-
def setup_new_user(options={})
|
29
|
+
def setup_new_user(options = {})
|
30
30
|
@user = User.new({
|
31
|
-
:
|
32
|
-
:
|
33
|
-
:
|
34
|
-
:
|
35
|
-
:
|
36
|
-
:
|
37
|
-
:
|
38
|
-
:
|
39
|
-
:
|
40
|
-
:
|
31
|
+
id: 1,
|
32
|
+
name: 'ShowFor',
|
33
|
+
description: '',
|
34
|
+
active: true,
|
35
|
+
invalid: false,
|
36
|
+
scopes: ["admin", "manager", "visitor"],
|
37
|
+
birthday: nil,
|
38
|
+
karma: Proc.new { nil },
|
39
|
+
created_at: Time.now,
|
40
|
+
updated_at: Date.today
|
41
41
|
}.merge(options))
|
42
42
|
end
|
43
|
-
|
44
|
-
# TODO: remove after supporting Rails 4.2+ only.
|
45
|
-
def rails_42?
|
46
|
-
ActiveModel::VERSION::STRING >= "4.2.0"
|
47
|
-
end
|
48
43
|
end
|
data/test/value_test.rb
CHANGED
@@ -2,7 +2,7 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
class ValueTest < ActionView::TestCase
|
4
4
|
test "show_for allows content tag to be configured globally, without label and separator" do
|
5
|
-
swap ShowFor, :
|
5
|
+
swap ShowFor, content_tag: :span do
|
6
6
|
with_value_for @user, :name
|
7
7
|
assert_no_select "div.show_for div.wrapper strong.label"
|
8
8
|
assert_no_select "div.show_for div.wrapper br"
|
@@ -11,14 +11,14 @@ class ValueTest < ActionView::TestCase
|
|
11
11
|
end
|
12
12
|
|
13
13
|
test "show_for allows content with tag to be changed by attribute, without label and separator" do
|
14
|
-
with_value_for @user, :name, :
|
14
|
+
with_value_for @user, :name, content_tag: :span
|
15
15
|
assert_no_select "div.show_for div.wrapper strong.label"
|
16
16
|
assert_no_select "div.show_for div.wrapper br"
|
17
17
|
assert_select "div.show_for div.wrapper span.content"
|
18
18
|
end
|
19
19
|
|
20
20
|
test "show_for allows content tag html to be configured by attribute, without label and separator" do
|
21
|
-
with_value_for @user, :name, :
|
21
|
+
with_value_for @user, :name, content_tag: :span, content_html: { id: "thecontent", class: "special" }
|
22
22
|
assert_no_select "div.show_for div.wrapper strong.label"
|
23
23
|
assert_no_select "div.show_for div.wrapper br"
|
24
24
|
assert_select "div.show_for div.wrapper span#thecontent.special.content"
|
@@ -46,8 +46,8 @@ class ValueTest < ActionView::TestCase
|
|
46
46
|
end
|
47
47
|
|
48
48
|
test "show_for accepts an attribute as time with format options, without label and separator" do
|
49
|
-
with_value_for @user, :created_at, :
|
50
|
-
assert_select "div.show_for div.wrapper", /#{Regexp.escape(I18n.l(@user.created_at, :
|
49
|
+
with_value_for @user, :created_at, format: :long
|
50
|
+
assert_select "div.show_for div.wrapper", /#{Regexp.escape(I18n.l(@user.created_at, format: :long))}/
|
51
51
|
end
|
52
52
|
|
53
53
|
test "show_for accepts an attribute as nil, without label and separator" do
|
@@ -65,14 +65,14 @@ class ValueTest < ActionView::TestCase
|
|
65
65
|
end
|
66
66
|
|
67
67
|
test "show_for uses :if_blank if attribute is nil, without label and separator" do
|
68
|
-
with_value_for @user, :birthday, :
|
68
|
+
with_value_for @user, :birthday, if_blank: "No description provided"
|
69
69
|
assert_no_select "div.show_for div.wrapper strong.label"
|
70
70
|
assert_no_select "div.show_for div.wrapper br"
|
71
71
|
assert_select "div.show_for div.wrapper", /No description provided/
|
72
72
|
end
|
73
73
|
|
74
74
|
test "show_for uses :if_blank if attribute is blank, without label and separator" do
|
75
|
-
with_value_for @user, :description, :
|
75
|
+
with_value_for @user, :description, if_blank: "No description provided"
|
76
76
|
assert_no_select "div.show_for div.wrapper strong.label"
|
77
77
|
assert_no_select "div.show_for div.wrapper br"
|
78
78
|
assert_select "div.show_for div.wrapper", /No description provided/
|
@@ -84,7 +84,6 @@ class ValueTest < ActionView::TestCase
|
|
84
84
|
assert_no_select "div.show_for div.wrapper strong.label"
|
85
85
|
assert_no_select "div.show_for div.wrapper br"
|
86
86
|
assert_no_select "div.show_for div.wrapper b"
|
87
|
-
assert_select "div.show_for div.wrapper",
|
88
|
-
rails_42? ? "<b>hack you!</b>" : "<b>hack you!</b>"
|
87
|
+
assert_select "div.show_for div.wrapper", "<b>hack you!</b>"
|
89
88
|
end
|
90
89
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: show_for
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- José Valim
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '5.
|
19
|
+
version: '5.2'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '5.
|
26
|
+
version: '5.2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: actionpack
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '5.
|
33
|
+
version: '5.2'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '5.
|
40
|
+
version: '5.2'
|
41
41
|
description: Wrap your objects with a helper to easily show them
|
42
42
|
email: contact@plataformatec.com.br
|
43
43
|
executables: []
|
@@ -77,7 +77,7 @@ homepage: http://github.com/plataformatec/show_for
|
|
77
77
|
licenses:
|
78
78
|
- MIT
|
79
79
|
metadata: {}
|
80
|
-
post_install_message:
|
80
|
+
post_install_message:
|
81
81
|
rdoc_options: []
|
82
82
|
require_paths:
|
83
83
|
- lib
|
@@ -85,15 +85,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
85
85
|
requirements:
|
86
86
|
- - ">="
|
87
87
|
- !ruby/object:Gem::Version
|
88
|
-
version: 2.
|
88
|
+
version: 2.5.0
|
89
89
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
90
|
requirements:
|
91
91
|
- - ">="
|
92
92
|
- !ruby/object:Gem::Version
|
93
93
|
version: '0'
|
94
94
|
requirements: []
|
95
|
-
rubygems_version: 3.0.
|
96
|
-
signing_key:
|
95
|
+
rubygems_version: 3.0.3
|
96
|
+
signing_key:
|
97
97
|
specification_version: 4
|
98
98
|
summary: Wrap your objects with a helper to easily show them
|
99
99
|
test_files:
|