item 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/item/version.rb +1 -1
- data/lib/item/view_helpers.rb +3 -3
- data/test/view_helpers_test.rb +18 -12
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d5bff2b3b8741143f52dde7c47f23c9d2243b5a
|
4
|
+
data.tar.gz: 947c18bb986760d1bdda67119d148f46b0efda65
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87700a0384d477e26500e0b67eac4d724312c4443f423ac034e20abb9f9a9c58fe1d9f80ddf6a8a7340b727efe1bf8cef48f99c4cdede90e4890b31e091c2a52
|
7
|
+
data.tar.gz: 62442db6af25325ec2cb7b68b2de0d0d6fb5f4347db6da5c921c16a1d5f001a9c570d6a889a916e4dbdab70675b53e23639d447920c1e3ea01437df231621e03
|
data/lib/item/version.rb
CHANGED
data/lib/item/view_helpers.rb
CHANGED
@@ -23,8 +23,8 @@ module Item
|
|
23
23
|
options, value = value, nil if value.is_a?(Hash)
|
24
24
|
itemprop = Util.itemprop(key)
|
25
25
|
|
26
|
-
|
27
|
-
@_item_enabled =
|
26
|
+
item_enabled_old = @_item_enabled
|
27
|
+
@_item_enabled = item_enabled_old && options.fetch(:if, !options.fetch(:unless, false))
|
28
28
|
|
29
29
|
options.delete(:if)
|
30
30
|
options.delete(:unless)
|
@@ -40,7 +40,7 @@ module Item
|
|
40
40
|
content_tag(tag, value, options)
|
41
41
|
end
|
42
42
|
|
43
|
-
@_item_enabled =
|
43
|
+
@_item_enabled = item_enabled_old
|
44
44
|
|
45
45
|
content
|
46
46
|
end
|
data/test/view_helpers_test.rb
CHANGED
@@ -100,14 +100,17 @@ class ViewHelpersTest < ActionView::TestCase
|
|
100
100
|
|
101
101
|
test "prop with falsey if" do
|
102
102
|
content = scope :product do
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
103
|
+
"".tap do |content|
|
104
|
+
content << prop(:offers, type: :offer, tag: :custom1, class: "offers-container", if: nil) do
|
105
|
+
[prop(:price, 123.5, tag: :custom2, class: "price-container"),
|
106
|
+
prop(availability: :in_stock, price_currency: "DKK"),
|
107
|
+
prop(:other_key, :other_value)].join.html_safe
|
108
|
+
end
|
109
|
+
content << prop(:name, "Product Name")
|
110
|
+
end.html_safe
|
108
111
|
end
|
109
112
|
|
110
|
-
assert_equal %{<div itemscope
|
113
|
+
assert_equal %{<div itemscope=\"itemscope\" itemtype=\"http://schema.org/Product\"><custom1 class=\"offers-container\"><custom2 class=\"price-container\">123.5</custom2></custom1><span itemprop=\"name\">Product Name</span></div>},
|
111
114
|
content
|
112
115
|
end
|
113
116
|
|
@@ -126,14 +129,17 @@ class ViewHelpersTest < ActionView::TestCase
|
|
126
129
|
|
127
130
|
test "prop with trueish unless" do
|
128
131
|
content = scope :product do
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
132
|
+
"".tap do |content|
|
133
|
+
content << prop(:offers, type: :offer, tag: :custom1, class: "offers-container", if: nil) do
|
134
|
+
[prop(:price, 123.5, tag: :custom2, class: "price-container"),
|
135
|
+
prop(availability: :in_stock, price_currency: "DKK"),
|
136
|
+
prop(:other_key, :other_value)].join.html_safe
|
137
|
+
end
|
138
|
+
content << prop(:name, "Product Name")
|
139
|
+
end.html_safe
|
134
140
|
end
|
135
141
|
|
136
|
-
assert_equal %{<div itemscope
|
142
|
+
assert_equal %{<div itemscope=\"itemscope\" itemtype=\"http://schema.org/Product\"><custom1 class=\"offers-container\"><custom2 class=\"price-container\">123.5</custom2></custom1><span itemprop=\"name\">Product Name</span></div>},
|
137
143
|
content
|
138
144
|
end
|
139
145
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: item
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lasse Bunk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|