h2ocube_rails_helper 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.travis.yml +4 -0
- data/Gemfile +5 -1
- data/README.md +2 -0
- data/Rakefile +11 -1
- data/h2ocube_rails_helper.gemspec +1 -1
- data/lib/h2ocube_rails_helper.rb +19 -21
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/config/application.rb +20 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +22 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +23 -0
- data/test/dummy/config/environments/production.rb +49 -0
- data/test/dummy/config/environments/test.rb +25 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +10 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +58 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/log/production.log +0 -0
- data/test/dummy/log/test.log +1 -0
- data/test/dummy/script/rails +6 -0
- data/test/render_canonical_test.rb +16 -0
- data/test/render_description_test.rb +33 -0
- data/test/render_ga_test.rb +30 -0
- data/test/render_html_class_test.rb +76 -0
- data/test/render_keywords_test.rb +35 -0
- data/test/render_title_test.rb +31 -0
- data/test/test_helper.rb +7 -0
- metadata +62 -3
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/README.md
CHANGED
data/Rakefile
CHANGED
@@ -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.7'
|
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
@@ -42,63 +42,61 @@ def _title
|
|
42
42
|
title = @title.class.to_s == 'Array' ? @title : [ @title.strip ]
|
43
43
|
else
|
44
44
|
if defined?(@item)
|
45
|
-
if @item.respond_to?(:
|
46
|
-
title = @item.seo_title
|
47
|
-
elsif @item.respond_to?(:title) && !@item.title.blank?
|
45
|
+
if @item.respond_to?(:title) && !@item.title.blank?
|
48
46
|
title = @item.title
|
49
|
-
elsif @item.respond_to?(:name) && !@item.name.blank?
|
50
|
-
title = @item.name
|
51
47
|
end
|
52
48
|
end
|
53
49
|
title ||= []
|
54
50
|
end
|
55
51
|
title = [ title ] if title.class.to_s != 'Array'
|
56
52
|
title.push HelperSettings.title
|
57
|
-
title.map{ |t| t.strip }
|
53
|
+
title.compact.map{ |t| t = t.strip; t == '' ? nil : t }.compact
|
58
54
|
end
|
59
55
|
|
60
|
-
def render_title
|
56
|
+
def render_title opts = {}
|
61
57
|
"<title>#{_title.join(' - ')}</title>".html_safe
|
62
58
|
end
|
63
59
|
|
64
60
|
def _keywords
|
65
61
|
if defined? @keywords
|
66
|
-
keywords = (@keywords.class.to_s == 'Array' ? @keywords : @keywords.strip.split(/(,|,)/))
|
67
|
-
elsif defined?(@item) && @item.respond_to?(:
|
68
|
-
keywords = @item.
|
62
|
+
keywords = (@keywords.class.to_s == 'Array' ? @keywords : @keywords.to_s.strip.split(/(,|,)/))
|
63
|
+
elsif defined?(@item) && @item.respond_to?(:keywords) && !@item.keywords.blank?
|
64
|
+
keywords = @item.keywords.strip.split(/(,|,)/)
|
69
65
|
else
|
70
66
|
keywords = HelperSettings.keywords.strip.split(/(,|,)/)
|
71
67
|
end
|
72
|
-
keywords.map{ |k| k = k.gsub(/(,|,)/, '').strip; k.blank? ? nil : k }.compact.uniq
|
68
|
+
keywords.compact.map{ |k| k = k.gsub(/(,|,)/, '').strip; k.blank? ? nil : k }.compact.uniq
|
73
69
|
end
|
74
70
|
|
75
|
-
def render_keywords
|
71
|
+
def render_keywords opts = {}
|
72
|
+
return '' if _keywords.length == 0
|
76
73
|
"<meta name=\"keywords\" content=\"#{_keywords.join(',')}\" />".html_safe
|
77
74
|
end
|
78
75
|
|
79
76
|
def _description
|
80
77
|
if defined? @description
|
81
78
|
description = @description
|
82
|
-
elsif defined?(@item) && @item.respond_to?(:
|
83
|
-
description = @item.
|
79
|
+
elsif defined?(@item) && @item.respond_to?(:description) && !@item.description.blank?
|
80
|
+
description = @item.description
|
84
81
|
else
|
85
82
|
description = HelperSettings.description
|
86
83
|
end
|
87
|
-
description.strip
|
84
|
+
description.to_s.strip
|
88
85
|
end
|
89
86
|
|
90
|
-
def render_description
|
87
|
+
def render_description opts = {}
|
88
|
+
return '' if _description == ''
|
91
89
|
"<meta name=\"description\" content=\"#{_description}\" />".html_safe
|
92
90
|
end
|
93
91
|
|
94
|
-
def render_canonical
|
92
|
+
def render_canonical opts = {}
|
95
93
|
defined?(@canonical) && !@canonical.blank? ? "<link rel=\"canonical\" href=\"#{@canonical}\" />".html_safe : ''
|
96
94
|
end
|
97
95
|
|
98
|
-
def render_seo
|
99
|
-
render_title << render_canonical << render_keywords << render_description << render_ga << csrf_meta_tags
|
96
|
+
def render_seo opts = {}
|
97
|
+
render_title(opts) << render_canonical(opts) << render_keywords(opts) << render_description(opts) << render_ga(opts) << csrf_meta_tags
|
100
98
|
end
|
101
99
|
|
102
|
-
def render_ga
|
103
|
-
("<script>_gaq=[['_setDomainName', '#{HelperSettings.domain}'],['_trackPageview'],['_trackPageLoadTime']];</script>" << Garelic.monitoring(HelperSettings.ga)).html_safe if defined?(Garelic) && Rails.env.
|
100
|
+
def render_ga opts = {}
|
101
|
+
("<script>_gaq=[['_setDomainName', '#{HelperSettings.domain}'],['_trackPageview'],['_trackPageLoadTime']];</script>" << Garelic.monitoring(opts[:ga] || HelperSettings.ga)).html_safe if defined?(Garelic)# && !Rails.env.development?
|
104
102
|
end
|
data/test/dummy/Rakefile
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
2
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
3
|
+
|
4
|
+
require File.expand_path('../config/application', __FILE__)
|
5
|
+
require 'rake'
|
6
|
+
|
7
|
+
Dummy::Application.load_tasks
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
#require "active_model/railtie"
|
4
|
+
require "action_controller/railtie"
|
5
|
+
#require "action_view/railtie"
|
6
|
+
|
7
|
+
Bundler.require
|
8
|
+
|
9
|
+
Dir[File.dirname(__FILE__) << '/../../../']
|
10
|
+
|
11
|
+
module Dummy
|
12
|
+
class Application < Rails::Application
|
13
|
+
|
14
|
+
# Configure the default encoding used in templates for Ruby 1.9.
|
15
|
+
config.encoding = "utf-8"
|
16
|
+
|
17
|
+
# Configure sensitive parameters which will be filtered from the log file.
|
18
|
+
config.filter_parameters += [:password]
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# SQLite version 3.x
|
2
|
+
# gem install sqlite3
|
3
|
+
development:
|
4
|
+
adapter: sqlite3
|
5
|
+
database: db/development.sqlite3
|
6
|
+
pool: 5
|
7
|
+
timeout: 5000
|
8
|
+
|
9
|
+
# Warning: The database defined as "test" will be erased and
|
10
|
+
# re-generated from your development database when you run "rake".
|
11
|
+
# Do not set this db to the same as development or production.
|
12
|
+
test:
|
13
|
+
adapter: sqlite3
|
14
|
+
database: db/test.sqlite3
|
15
|
+
pool: 5
|
16
|
+
timeout: 5000
|
17
|
+
|
18
|
+
production:
|
19
|
+
adapter: sqlite3
|
20
|
+
database: db/production.sqlite3
|
21
|
+
pool: 5
|
22
|
+
timeout: 5000
|
@@ -0,0 +1,23 @@
|
|
1
|
+
Dummy::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# In the development environment your application's code is reloaded on
|
5
|
+
# every request. This slows down response time but is perfect for development
|
6
|
+
# since you don't have to restart the webserver when you make code changes.
|
7
|
+
config.cache_classes = false
|
8
|
+
|
9
|
+
# Log error messages when you accidentally call methods on nil.
|
10
|
+
config.whiny_nils = true
|
11
|
+
|
12
|
+
# Show full error reports and disable caching
|
13
|
+
config.consider_all_requests_local = true
|
14
|
+
config.action_view.debug_rjs = true
|
15
|
+
config.action_controller.perform_caching = false
|
16
|
+
|
17
|
+
# Print deprecation notices to the Rails logger
|
18
|
+
config.active_support.deprecation = :log
|
19
|
+
|
20
|
+
# Only use best-standards-support built into browsers
|
21
|
+
config.action_dispatch.best_standards_support = :builtin
|
22
|
+
end
|
23
|
+
|
@@ -0,0 +1,49 @@
|
|
1
|
+
Dummy::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# The production environment is meant for finished, "live" apps.
|
5
|
+
# Code is not reloaded between requests
|
6
|
+
config.cache_classes = true
|
7
|
+
|
8
|
+
# Full error reports are disabled and caching is turned on
|
9
|
+
config.consider_all_requests_local = false
|
10
|
+
config.action_controller.perform_caching = true
|
11
|
+
|
12
|
+
# Specifies the header that your server uses for sending files
|
13
|
+
config.action_dispatch.x_sendfile_header = "X-Sendfile"
|
14
|
+
|
15
|
+
# For nginx:
|
16
|
+
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
|
17
|
+
|
18
|
+
# If you have no front-end server that supports something like X-Sendfile,
|
19
|
+
# just comment this out and Rails will serve the files
|
20
|
+
|
21
|
+
# See everything in the log (default is :info)
|
22
|
+
# config.log_level = :debug
|
23
|
+
|
24
|
+
# Use a different logger for distributed setups
|
25
|
+
# config.logger = SyslogLogger.new
|
26
|
+
|
27
|
+
# Use a different cache store in production
|
28
|
+
# config.cache_store = :mem_cache_store
|
29
|
+
|
30
|
+
# Disable Rails's static asset server
|
31
|
+
# In production, Apache or nginx will already do this
|
32
|
+
config.serve_static_assets = false
|
33
|
+
|
34
|
+
# Enable serving of images, stylesheets, and javascripts from an asset server
|
35
|
+
config.action_controller.asset_host = "http://assets.com"
|
36
|
+
|
37
|
+
# Disable delivery errors, bad email addresses will be ignored
|
38
|
+
# config.action_mailer.raise_delivery_errors = false
|
39
|
+
|
40
|
+
# Enable threaded mode
|
41
|
+
# config.threadsafe!
|
42
|
+
|
43
|
+
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
44
|
+
# the I18n.default_locale when a translation can not be found)
|
45
|
+
config.i18n.fallbacks = true
|
46
|
+
|
47
|
+
# Send deprecation notices to registered listeners
|
48
|
+
config.active_support.deprecation = :notify
|
49
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
Dummy::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# The test environment is used exclusively to run your application's
|
5
|
+
# test suite. You never need to work with it otherwise. Remember that
|
6
|
+
# your test database is "scratch space" for the test suite and is wiped
|
7
|
+
# and recreated between test runs. Don't rely on the data there!
|
8
|
+
config.cache_classes = true
|
9
|
+
|
10
|
+
# Log error messages when you accidentally call methods on nil.
|
11
|
+
config.whiny_nils = true
|
12
|
+
|
13
|
+
# Show full error reports and disable caching
|
14
|
+
config.consider_all_requests_local = true
|
15
|
+
config.action_controller.perform_caching = false
|
16
|
+
|
17
|
+
# Raise exceptions instead of rendering exception templates
|
18
|
+
config.action_dispatch.show_exceptions = false
|
19
|
+
|
20
|
+
# Disable request forgery protection in test environment
|
21
|
+
config.action_controller.allow_forgery_protection = false
|
22
|
+
|
23
|
+
# Print deprecation notices to the stderr
|
24
|
+
config.active_support.deprecation = :stderr
|
25
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
|
4
|
+
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
|
5
|
+
|
6
|
+
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
|
7
|
+
# Rails.backtrace_cleaner.remove_silencers!
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Add new inflection rules using the following format
|
4
|
+
# (all these examples are active by default):
|
5
|
+
# ActiveSupport::Inflector.inflections do |inflect|
|
6
|
+
# inflect.plural /^(ox)$/i, '\1en'
|
7
|
+
# inflect.singular /^(ox)en/i, '\1'
|
8
|
+
# inflect.irregular 'person', 'people'
|
9
|
+
# inflect.uncountable %w( fish sheep )
|
10
|
+
# end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Your secret key for verifying the integrity of signed cookies.
|
4
|
+
# If you change this key, all old signed cookies will become invalid!
|
5
|
+
# Make sure the secret is at least 30 characters and all random,
|
6
|
+
# no regular words or you'll be exposed to dictionary attacks.
|
7
|
+
Dummy::Application.config.secret_token = 'ca3f29ce2033cebff511999f2fce3f4777dda12be7b8ad71e3f82bead7b95c26cd995ece00052674ee35dfd7892b7c78d0faaaffc9274fcf1b9bb49805ff0a2e'
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
Dummy::Application.config.session_store :cookie_store, :key => '_dummy_session'
|
4
|
+
|
5
|
+
# Use the database for sessions instead of the cookie-based default,
|
6
|
+
# which shouldn't be used to store highly confidential information
|
7
|
+
# (create the session table with "rails generate session_migration")
|
8
|
+
# Dummy::Application.config.session_store :active_record_store
|
@@ -0,0 +1,58 @@
|
|
1
|
+
Dummy::Application.routes.draw do
|
2
|
+
# The priority is based upon order of creation:
|
3
|
+
# first created -> highest priority.
|
4
|
+
|
5
|
+
# Sample of regular route:
|
6
|
+
# match 'products/:id' => 'catalog#view'
|
7
|
+
# Keep in mind you can assign values other than :controller and :action
|
8
|
+
|
9
|
+
# Sample of named route:
|
10
|
+
# match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
|
11
|
+
# This route can be invoked with purchase_url(:id => product.id)
|
12
|
+
|
13
|
+
# Sample resource route (maps HTTP verbs to controller actions automatically):
|
14
|
+
# resources :products
|
15
|
+
|
16
|
+
# Sample resource route with options:
|
17
|
+
# resources :products do
|
18
|
+
# member do
|
19
|
+
# get 'short'
|
20
|
+
# post 'toggle'
|
21
|
+
# end
|
22
|
+
#
|
23
|
+
# collection do
|
24
|
+
# get 'sold'
|
25
|
+
# end
|
26
|
+
# end
|
27
|
+
|
28
|
+
# Sample resource route with sub-resources:
|
29
|
+
# resources :products do
|
30
|
+
# resources :comments, :sales
|
31
|
+
# resource :seller
|
32
|
+
# end
|
33
|
+
|
34
|
+
# Sample resource route with more complex sub-resources
|
35
|
+
# resources :products do
|
36
|
+
# resources :comments
|
37
|
+
# resources :sales do
|
38
|
+
# get 'recent', :on => :collection
|
39
|
+
# end
|
40
|
+
# end
|
41
|
+
|
42
|
+
# Sample resource route within a namespace:
|
43
|
+
# namespace :admin do
|
44
|
+
# # Directs /admin/products/* to Admin::ProductsController
|
45
|
+
# # (app/controllers/admin/products_controller.rb)
|
46
|
+
# resources :products
|
47
|
+
# end
|
48
|
+
|
49
|
+
# You can have the root of your site routed with "root"
|
50
|
+
# just remember to delete public/index.html.
|
51
|
+
# root :to => "welcome#index"
|
52
|
+
|
53
|
+
# See how all your routes lay out with "rake routes"
|
54
|
+
|
55
|
+
# This is a legacy wild controller route that's not recommended for RESTful applications.
|
56
|
+
# Note: This route will make all actions in every controller accessible via GET requests.
|
57
|
+
# match ':controller(/:action(/:id(.:format)))'
|
58
|
+
end
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
Connecting to database specified by database.yml
|
@@ -0,0 +1,6 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
|
+
|
4
|
+
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
5
|
+
require File.expand_path('../../config/boot', __FILE__)
|
6
|
+
require 'rails/commands'
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class RenderCanonicalClass < ActionView::TestCase
|
4
|
+
test 'simple' do
|
5
|
+
assert_equal render_canonical, ''
|
6
|
+
end
|
7
|
+
|
8
|
+
test '@canonical' do
|
9
|
+
@canonical = '@canonical'
|
10
|
+
assert_equal render_canonical, '<link rel="canonical" href="@canonical" />'
|
11
|
+
[' ', '', nil].each do |desc|
|
12
|
+
@canonical = desc
|
13
|
+
assert_equal render_canonical, ''
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class RenderDescriptionClass < ActionView::TestCase
|
4
|
+
test 'simple' do
|
5
|
+
assert_equal render_description, '<meta name="description" content="description" />'
|
6
|
+
end
|
7
|
+
|
8
|
+
test '@description' do
|
9
|
+
@description = '@description'
|
10
|
+
assert_equal render_description, '<meta name="description" content="@description" />'
|
11
|
+
[' ', '', nil].each do |desc|
|
12
|
+
@description = desc
|
13
|
+
assert_equal render_description, ''
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
test '@item' do
|
18
|
+
@item = Item.new
|
19
|
+
assert_equal render_description, '<meta name="description" content="item_description" />'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class HelperSettings
|
24
|
+
def self.description
|
25
|
+
'description'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
class Item
|
30
|
+
def description
|
31
|
+
'item_description'
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class RenderGaClass < ActionView::TestCase
|
4
|
+
test 'simple' do
|
5
|
+
assert render_ga.include?('ga_code')
|
6
|
+
assert render_ga(ga: '123').include?('123')
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
class HelperSettings
|
11
|
+
def self.title
|
12
|
+
'title'
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.keywords
|
16
|
+
'keywords'
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.description
|
20
|
+
'description'
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.ga
|
24
|
+
'ga_code'
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.domain
|
28
|
+
'domain'
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class RenderHtmlClass < ActionView::TestCase
|
4
|
+
test 'simple params' do
|
5
|
+
self.params = {
|
6
|
+
controller: 'controller',
|
7
|
+
action: 'action'
|
8
|
+
}
|
9
|
+
cls = render_html_class.split ' '
|
10
|
+
assert cls.include?('controller')
|
11
|
+
assert cls.include?('action')
|
12
|
+
assert cls.include?('controller_action')
|
13
|
+
end
|
14
|
+
|
15
|
+
test 'module controller' do
|
16
|
+
self.params = {
|
17
|
+
controller: 'module/controller',
|
18
|
+
action: 'action'
|
19
|
+
}
|
20
|
+
cls = render_html_class.split ' '
|
21
|
+
assert cls.include?('module_controller')
|
22
|
+
assert cls.include?('controller')
|
23
|
+
assert cls.include?('action')
|
24
|
+
assert cls.include?('module_controller_action')
|
25
|
+
end
|
26
|
+
|
27
|
+
test 'addition html class' do
|
28
|
+
self.params = {
|
29
|
+
controller: 'controller',
|
30
|
+
action: 'action',
|
31
|
+
html_class: 'addition'
|
32
|
+
}
|
33
|
+
cls = render_html_class.split ' '
|
34
|
+
assert cls.include?('controller')
|
35
|
+
assert cls.include?('action')
|
36
|
+
assert cls.include?('controller_action')
|
37
|
+
assert cls.include?('addition')
|
38
|
+
end
|
39
|
+
|
40
|
+
test 'mobile' do
|
41
|
+
self.params = {
|
42
|
+
controller: 'controller',
|
43
|
+
action: 'action'
|
44
|
+
}
|
45
|
+
self.request.env['X_MOBILE_DEVICE'] = 'iPad'
|
46
|
+
cls = render_html_class.split ' '
|
47
|
+
assert cls.include?('controller')
|
48
|
+
assert cls.include?('action')
|
49
|
+
assert cls.include?('controller_action')
|
50
|
+
assert cls.include?('mobile')
|
51
|
+
assert cls.include?('iPad')
|
52
|
+
end
|
53
|
+
|
54
|
+
def params
|
55
|
+
@params || {}
|
56
|
+
end
|
57
|
+
|
58
|
+
def params= data
|
59
|
+
@params = data
|
60
|
+
end
|
61
|
+
|
62
|
+
class Request
|
63
|
+
def env
|
64
|
+
@env || {}
|
65
|
+
end
|
66
|
+
|
67
|
+
def env= data
|
68
|
+
@env = data
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def request
|
73
|
+
@request ||= Request.new
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class RenderKeywordsClass < ActionView::TestCase
|
4
|
+
test 'simple' do
|
5
|
+
assert_equal render_keywords, '<meta name="keywords" content="keywords" />'
|
6
|
+
end
|
7
|
+
|
8
|
+
test '@keywords' do
|
9
|
+
@keywords = '@keywords'
|
10
|
+
assert_equal render_keywords, '<meta name="keywords" content="@keywords" />'
|
11
|
+
@keywords = ['@keywords', ' ', '', nil]
|
12
|
+
assert_equal render_keywords, '<meta name="keywords" content="@keywords" />'
|
13
|
+
[' ', '', nil].each do |key|
|
14
|
+
@keywords = key
|
15
|
+
assert_equal render_keywords, ''
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
test '@item' do
|
20
|
+
@item = Item.new
|
21
|
+
assert_equal render_keywords, '<meta name="keywords" content="item_keywords" />'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
class HelperSettings
|
26
|
+
def self.keywords
|
27
|
+
'keywords'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class Item
|
32
|
+
def keywords
|
33
|
+
'item_keywords'
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class RenderTitleClass < ActionView::TestCase
|
4
|
+
test 'simple' do
|
5
|
+
assert_equal render_title, '<title>title</title>'
|
6
|
+
end
|
7
|
+
|
8
|
+
test '@title' do
|
9
|
+
@title = '@title'
|
10
|
+
assert_equal render_title, '<title>@title - title</title>'
|
11
|
+
@title = ['@title', ' ', '', nil]
|
12
|
+
assert_equal render_title, '<title>@title - title</title>'
|
13
|
+
end
|
14
|
+
|
15
|
+
test '@item' do
|
16
|
+
@item = Item.new
|
17
|
+
assert_equal render_title, '<title>item_title - title</title>'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class HelperSettings
|
22
|
+
def self.title
|
23
|
+
'title'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
class Item
|
28
|
+
def title
|
29
|
+
'item_title'
|
30
|
+
end
|
31
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: h2ocube_rails_helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-01-
|
12
|
+
date: 2013-01-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: settingslogic
|
@@ -67,6 +67,7 @@ extensions: []
|
|
67
67
|
extra_rdoc_files: []
|
68
68
|
files:
|
69
69
|
- .gitignore
|
70
|
+
- .travis.yml
|
70
71
|
- Gemfile
|
71
72
|
- LICENSE.txt
|
72
73
|
- README.md
|
@@ -76,6 +77,35 @@ files:
|
|
76
77
|
- lib/generators/source/helper.yml.erb
|
77
78
|
- lib/generators/source/helper_settings.rb.erb
|
78
79
|
- lib/h2ocube_rails_helper.rb
|
80
|
+
- test/dummy/Rakefile
|
81
|
+
- test/dummy/app/controllers/application_controller.rb
|
82
|
+
- test/dummy/app/helpers/application_helper.rb
|
83
|
+
- test/dummy/app/views/layouts/application.html.erb
|
84
|
+
- test/dummy/config.ru
|
85
|
+
- test/dummy/config/application.rb
|
86
|
+
- test/dummy/config/boot.rb
|
87
|
+
- test/dummy/config/database.yml
|
88
|
+
- test/dummy/config/environment.rb
|
89
|
+
- test/dummy/config/environments/development.rb
|
90
|
+
- test/dummy/config/environments/production.rb
|
91
|
+
- test/dummy/config/environments/test.rb
|
92
|
+
- test/dummy/config/initializers/backtrace_silencers.rb
|
93
|
+
- test/dummy/config/initializers/inflections.rb
|
94
|
+
- test/dummy/config/initializers/mime_types.rb
|
95
|
+
- test/dummy/config/initializers/secret_token.rb
|
96
|
+
- test/dummy/config/initializers/session_store.rb
|
97
|
+
- test/dummy/config/locales/en.yml
|
98
|
+
- test/dummy/config/routes.rb
|
99
|
+
- test/dummy/log/production.log
|
100
|
+
- test/dummy/log/test.log
|
101
|
+
- test/dummy/script/rails
|
102
|
+
- test/render_canonical_test.rb
|
103
|
+
- test/render_description_test.rb
|
104
|
+
- test/render_ga_test.rb
|
105
|
+
- test/render_html_class_test.rb
|
106
|
+
- test/render_keywords_test.rb
|
107
|
+
- test/render_title_test.rb
|
108
|
+
- test/test_helper.rb
|
79
109
|
homepage: https://github.com/h2ocube/h2ocube_rails_helper
|
80
110
|
licenses: []
|
81
111
|
post_install_message:
|
@@ -100,4 +130,33 @@ rubygems_version: 1.8.24
|
|
100
130
|
signing_key:
|
101
131
|
specification_version: 3
|
102
132
|
summary: Just an helper collection
|
103
|
-
test_files:
|
133
|
+
test_files:
|
134
|
+
- test/dummy/Rakefile
|
135
|
+
- test/dummy/app/controllers/application_controller.rb
|
136
|
+
- test/dummy/app/helpers/application_helper.rb
|
137
|
+
- test/dummy/app/views/layouts/application.html.erb
|
138
|
+
- test/dummy/config.ru
|
139
|
+
- test/dummy/config/application.rb
|
140
|
+
- test/dummy/config/boot.rb
|
141
|
+
- test/dummy/config/database.yml
|
142
|
+
- test/dummy/config/environment.rb
|
143
|
+
- test/dummy/config/environments/development.rb
|
144
|
+
- test/dummy/config/environments/production.rb
|
145
|
+
- test/dummy/config/environments/test.rb
|
146
|
+
- test/dummy/config/initializers/backtrace_silencers.rb
|
147
|
+
- test/dummy/config/initializers/inflections.rb
|
148
|
+
- test/dummy/config/initializers/mime_types.rb
|
149
|
+
- test/dummy/config/initializers/secret_token.rb
|
150
|
+
- test/dummy/config/initializers/session_store.rb
|
151
|
+
- test/dummy/config/locales/en.yml
|
152
|
+
- test/dummy/config/routes.rb
|
153
|
+
- test/dummy/log/production.log
|
154
|
+
- test/dummy/log/test.log
|
155
|
+
- test/dummy/script/rails
|
156
|
+
- test/render_canonical_test.rb
|
157
|
+
- test/render_description_test.rb
|
158
|
+
- test/render_ga_test.rb
|
159
|
+
- test/render_html_class_test.rb
|
160
|
+
- test/render_keywords_test.rb
|
161
|
+
- test/render_title_test.rb
|
162
|
+
- test/test_helper.rb
|