h2ocube_rails_helper 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- data/h2ocube_rails_helper.gemspec +1 -1
- data/lib/h2ocube_rails_helper.rb +2 -2
- data/test/render_keywords_test.rb +5 -3
- metadata +1 -1
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |gem|
|
6
6
|
gem.name = 'h2ocube_rails_helper'
|
7
|
-
gem.version = '0.0.
|
7
|
+
gem.version = '0.0.10'
|
8
8
|
gem.authors = ['Ben']
|
9
9
|
gem.email = ['ben@h2ocube.com']
|
10
10
|
gem.description = %q{Just an helper collection}
|
data/lib/h2ocube_rails_helper.rb
CHANGED
@@ -68,9 +68,9 @@ def _keywords opts = {}
|
|
68
68
|
elsif defined?(@item) && @item.respond_to?(:keywords) && !@item.keywords.blank?
|
69
69
|
keywords = @item.keywords.strip.split(/(,|,)/)
|
70
70
|
else
|
71
|
-
keywords = opts.has_key?(:keywords) ? opts[:keywords] : HelperSettings.keywords
|
71
|
+
keywords = opts.has_key?(:keywords) ? opts[:keywords] : HelperSettings.keywords
|
72
72
|
end
|
73
|
-
[keywords].flatten.compact.map{ |k| k
|
73
|
+
[keywords].flatten.compact.map{ |k| k.strip.split(/(,|,)/) }.flatten.map{ |k| k.gsub(/(,|,)/, '').blank? ? nil : k }.compact.uniq
|
74
74
|
end
|
75
75
|
|
76
76
|
def render_keywords opts = {}
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
1
3
|
require 'test_helper'
|
2
4
|
|
3
5
|
class RenderKeywordsClass < ActionView::TestCase
|
@@ -18,11 +20,11 @@ class RenderKeywordsClass < ActionView::TestCase
|
|
18
20
|
|
19
21
|
test '@item' do
|
20
22
|
@item = Item.new
|
21
|
-
assert_equal render_keywords, '<meta name="keywords" content="item_keywords" />'
|
23
|
+
assert_equal render_keywords, '<meta name="keywords" content="item,item_keywords" />'
|
22
24
|
end
|
23
25
|
|
24
26
|
test 'opts' do
|
25
|
-
assert_equal render_keywords(keywords: 'opts'), '<meta name="keywords" content="opts" />'
|
27
|
+
assert_equal render_keywords(keywords: 'opts,a,b,c'), '<meta name="keywords" content="opts,a,b,c" />'
|
26
28
|
end
|
27
29
|
end
|
28
30
|
|
@@ -34,6 +36,6 @@ end
|
|
34
36
|
|
35
37
|
class Item
|
36
38
|
def keywords
|
37
|
-
'item_keywords'
|
39
|
+
'item,item_keywords'
|
38
40
|
end
|
39
41
|
end
|