metazilla 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/lib/metazilla/version.rb +1 -1
- data/test/minitest_helper.rb +14 -0
- data/test/view_helper_test.rb +144 -0
- metadata +9 -11
- data/.gitignore +0 -9
- data/.travis.yml +0 -3
- data/Gemfile +0 -4
- data/Rakefile +0 -8
- data/bin/console +0 -14
- data/bin/setup +0 -7
- data/metazilla.gemspec +0 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 94c6cca716fbde26463f3ed31a5323dafbb2f0e5
|
4
|
+
data.tar.gz: 9c7d647f99344a1ea931e912e0d6f4f7b921243c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6337e6ea4f46154eba6c35efe7d2bbed621ca0a2342e5708890440d261345bd9f5ca30145f4750eaf3e79f5510aff4b7280b1f7fa54f17bd0e68170a9898c463
|
7
|
+
data.tar.gz: 2849ed3c17a83dedabf8e0e3f1209ab1e6f3439209f6e4df9b5ccb581d9b0ce6c92fe3a951ba5e7eb1e081be76c6da11d7941d0f6c8d13fafa623b7c6a8a295f
|
data/README.md
CHANGED
data/lib/metazilla/version.rb
CHANGED
@@ -0,0 +1,14 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
|
2
|
+
require "metazilla"
|
3
|
+
|
4
|
+
require "minitest/autorun"
|
5
|
+
|
6
|
+
ActiveSupport.test_order = :sorted
|
7
|
+
|
8
|
+
class Minitest::Test
|
9
|
+
def setup
|
10
|
+
I18n.load_path = [File.join(File.dirname(__FILE__), "en.yml")]
|
11
|
+
I18n.reload!
|
12
|
+
Metazilla.reset_configuration
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,144 @@
|
|
1
|
+
require "minitest_helper"
|
2
|
+
|
3
|
+
class MockController < Struct.new(:action_name, :controller_path)
|
4
|
+
attr_accessor :view_assigns
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
@view_assigns = {}
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
class ActionView::TestCase
|
12
|
+
include Metazilla::ViewHelper
|
13
|
+
end
|
14
|
+
|
15
|
+
class ViewHelperTest < ActionView::TestCase
|
16
|
+
def setup
|
17
|
+
super
|
18
|
+
@controller = MockController.new
|
19
|
+
end
|
20
|
+
|
21
|
+
def set_path(controller = nil, action = nil)
|
22
|
+
@controller.controller_path = controller
|
23
|
+
@controller.action_name = action
|
24
|
+
end
|
25
|
+
|
26
|
+
def assign_variable(name, value)
|
27
|
+
@controller.view_assigns[name] = value
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_set_title
|
31
|
+
assert_equal "Page", title("Page")
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_get_title
|
35
|
+
title "Page"
|
36
|
+
|
37
|
+
assert_equal "Page", title
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_set_app_title
|
41
|
+
assert_equal "App", app_title("App")
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_get_app_title
|
45
|
+
app_title "App"
|
46
|
+
|
47
|
+
assert_equal "App", app_title
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_full_title
|
51
|
+
title "Page"
|
52
|
+
app_title "App"
|
53
|
+
|
54
|
+
assert_equal "Page | App", full_title
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_title_tag
|
58
|
+
title "Page"
|
59
|
+
app_title "App"
|
60
|
+
|
61
|
+
assert_equal "<title>Page | App</title>", title_tag
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_loads_translations
|
65
|
+
set_path "posts", "index"
|
66
|
+
|
67
|
+
assert_equal "Posts list | My app", full_title
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_loads_translations_with_namespace
|
71
|
+
set_path "admin/web/posts", "index"
|
72
|
+
|
73
|
+
assert_equal "My web admin app", app_title
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_translation_cascades
|
77
|
+
set_path "missing/missing/posts", "index"
|
78
|
+
|
79
|
+
assert_equal "My app", app_title
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_overrides_loaded_translations
|
83
|
+
set_path "posts", "index"
|
84
|
+
title "New Title"
|
85
|
+
app_title "New App Title"
|
86
|
+
|
87
|
+
assert_equal "New Title | New App Title", full_title
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_translations_with_view_assigns
|
91
|
+
set_path "posts", "show"
|
92
|
+
assign_variable "post", "My post"
|
93
|
+
|
94
|
+
assert_equal "Post My post", title
|
95
|
+
end
|
96
|
+
|
97
|
+
def test_set_meta
|
98
|
+
assert_equal "Test", meta(:description, "Test")
|
99
|
+
end
|
100
|
+
|
101
|
+
def test_get_meta
|
102
|
+
meta :description, "Test"
|
103
|
+
|
104
|
+
assert_equal "Test", meta(:description)
|
105
|
+
end
|
106
|
+
|
107
|
+
def test_meta_tag
|
108
|
+
meta :description, "Test"
|
109
|
+
|
110
|
+
assert_equal %{<meta name="description" content="Test" />}, meta_tag(:description)
|
111
|
+
end
|
112
|
+
|
113
|
+
def test_loads_translated_meta
|
114
|
+
set_path "posts", "index"
|
115
|
+
|
116
|
+
assert_equal "My posts list.", meta(:description)
|
117
|
+
end
|
118
|
+
|
119
|
+
def test_custom_title_separator
|
120
|
+
Metazilla.configure { |c| c.separator = " > " }
|
121
|
+
set_path "posts", "index"
|
122
|
+
|
123
|
+
assert_equal "Posts list > My app", full_title
|
124
|
+
end
|
125
|
+
|
126
|
+
def test_lookup_for_mapped_actions
|
127
|
+
set_path "posts", "create"
|
128
|
+
|
129
|
+
assert_equal "New post", title
|
130
|
+
end
|
131
|
+
|
132
|
+
def test_lookup_for_custom_mapped_actions
|
133
|
+
Metazilla.configure { |c| c.mapping[:test] = :new }
|
134
|
+
set_path "posts", "test"
|
135
|
+
|
136
|
+
assert_equal "New post", title
|
137
|
+
end
|
138
|
+
|
139
|
+
def test_fallbacks_silently
|
140
|
+
set_path "missing", "nothere"
|
141
|
+
|
142
|
+
assert_equal "My app", full_title
|
143
|
+
end
|
144
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metazilla
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eugene Likholetov
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionview
|
@@ -59,18 +59,13 @@ executables: []
|
|
59
59
|
extensions: []
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
|
-
- ".gitignore"
|
63
|
-
- ".travis.yml"
|
64
|
-
- Gemfile
|
65
62
|
- LICENSE.txt
|
66
63
|
- README.md
|
67
|
-
- Rakefile
|
68
|
-
- bin/console
|
69
|
-
- bin/setup
|
70
64
|
- lib/metazilla.rb
|
71
65
|
- lib/metazilla/version.rb
|
72
66
|
- lib/metazilla/view_helper.rb
|
73
|
-
-
|
67
|
+
- test/minitest_helper.rb
|
68
|
+
- test/view_helper_test.rb
|
74
69
|
homepage: https://github.com/bsboris/metazilla
|
75
70
|
licenses:
|
76
71
|
- MIT
|
@@ -95,4 +90,7 @@ rubygems_version: 2.4.5
|
|
95
90
|
signing_key:
|
96
91
|
specification_version: 4
|
97
92
|
summary: Simple metatags and page titles for Rails.
|
98
|
-
test_files:
|
93
|
+
test_files:
|
94
|
+
- test/minitest_helper.rb
|
95
|
+
- test/view_helper_test.rb
|
96
|
+
has_rdoc:
|
data/.gitignore
DELETED
data/.travis.yml
DELETED
data/Gemfile
DELETED
data/Rakefile
DELETED
data/bin/console
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "metazilla"
|
5
|
-
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require "pry"
|
11
|
-
# Pry.start
|
12
|
-
|
13
|
-
require "irb"
|
14
|
-
IRB.start
|
data/bin/setup
DELETED
data/metazilla.gemspec
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'metazilla/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = "metazilla"
|
8
|
-
spec.version = Metazilla::VERSION
|
9
|
-
spec.authors = ["Eugene Likholetov"]
|
10
|
-
spec.email = ["bsboris@gmail.com"]
|
11
|
-
|
12
|
-
spec.summary = %q{Simple metatags and page titles for Rails.}
|
13
|
-
spec.description = %q{Simple metatags and page titles for Rails.}
|
14
|
-
spec.homepage = "https://github.com/bsboris/metazilla"
|
15
|
-
spec.license = "MIT"
|
16
|
-
|
17
|
-
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
-
spec.bindir = "exe"
|
19
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
-
spec.require_paths = ["lib"]
|
21
|
-
|
22
|
-
spec.add_dependency "actionview", ">= 3.0.0"
|
23
|
-
|
24
|
-
spec.add_development_dependency "bundler", "~> 1.8"
|
25
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
-
end
|