title 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +3 -3
- data/app/helpers/title/title_helper.rb +5 -1
- data/lib/title/version.rb +1 -1
- data/spec/helpers/title_helper_spec.rb +17 -7
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a5223d4bc45bb6bde8e268cb533e675a4a77628b85518151e10d1033f20ef341
|
4
|
+
data.tar.gz: 9fc368e00d9242fad23bba51657b34e46c54b436c9cc48a54de4abd8c304ad3a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1ea8d9d9b5eb0cfc566a497e06d09e3bfcfa7cd8a617134c7da91bb84e67b3bf6c57bcdd1b2654a52f2dcb9eea34e7e8b358eee0cd7e26131ef5b8cf8b22052
|
7
|
+
data.tar.gz: 1546ca41e1d44809a45685d846f6de98c42aea2a510218e3aae726a3508fa71209c0fce39006d3cec5910940788aeafc886dcef79405532f0628c142c9b01f3f
|
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# Title
|
2
2
|
|
3
|
-
[![Build Status](https://travis-ci.org/calebthompson/title.
|
4
|
-
[![Code Climate](https://codeclimate.com/github/calebthompson/title.
|
5
|
-
[![Coverage Status](https://coveralls.io/repos/calebthompson/title/badge.
|
3
|
+
[![Build Status](https://travis-ci.org/calebthompson/title.svg)](https://travis-ci.org/calebthompson/title)
|
4
|
+
[![Code Climate](https://codeclimate.com/github/calebthompson/title.svg)](https://codeclimate.com/github/calebthompson/title)
|
5
|
+
[![Coverage Status](https://coveralls.io/repos/calebthompson/title/badge.svg)](https://coveralls.io/r/calebthompson/title)
|
6
6
|
|
7
7
|
Translations for \<title\>s!
|
8
8
|
|
@@ -15,7 +15,7 @@ module Title
|
|
15
15
|
def to_s
|
16
16
|
I18n.t(
|
17
17
|
[:titles, controller_name, action_name].join('.'),
|
18
|
-
|
18
|
+
**safe_context.merge(default: defaults)
|
19
19
|
)
|
20
20
|
end
|
21
21
|
|
@@ -59,6 +59,10 @@ module Title
|
|
59
59
|
action_name
|
60
60
|
end
|
61
61
|
end
|
62
|
+
|
63
|
+
def safe_context
|
64
|
+
context.except(*I18n::RESERVED_KEYS)
|
65
|
+
end
|
62
66
|
end
|
63
67
|
end
|
64
68
|
end
|
data/lib/title/version.rb
CHANGED
@@ -37,7 +37,7 @@ describe Title::TitleHelper do
|
|
37
37
|
stub_rails
|
38
38
|
stub_controller_and_action(:users, :show)
|
39
39
|
load_translations(users: { show: '%{name}' })
|
40
|
-
helper.
|
40
|
+
allow(helper).to receive_message_chain(:controller, :view_assigns).and_return('name' => 'Caleb')
|
41
41
|
|
42
42
|
expect(helper.title).to eq('Caleb')
|
43
43
|
end
|
@@ -46,20 +46,30 @@ describe Title::TitleHelper do
|
|
46
46
|
stub_rails
|
47
47
|
stub_controller_and_action(:users, :show)
|
48
48
|
load_translations(users: { show: '%{greeting} %{name}' })
|
49
|
-
helper.
|
49
|
+
allow(helper).to receive_message_chain(:controller, :view_assigns).and_return('name' => 'Caleb')
|
50
50
|
|
51
51
|
expect(helper.title(greeting: 'Hello')).to eq('Hello Caleb')
|
52
52
|
end
|
53
53
|
|
54
|
+
it 'makes context safe to be passed as interpolation options' do
|
55
|
+
stub_rails
|
56
|
+
stub_controller_and_action(:users, :show)
|
57
|
+
load_translations(users: { show: 'User' })
|
58
|
+
allow(helper).to receive_message_chain(:controller, :view_assigns).and_return('scope' => 'Foo')
|
59
|
+
|
60
|
+
expect(helper.title).to eq('User')
|
61
|
+
end
|
62
|
+
|
54
63
|
def stub_rails
|
55
|
-
helper.
|
56
|
-
helper.
|
57
|
-
helper.
|
58
|
-
Rails.
|
64
|
+
allow(helper).to receive(:controller_path).and_return('dashboards')
|
65
|
+
allow(helper).to receive(:action_name)
|
66
|
+
allow(helper).to receive_message_chain(:controller, :view_assigns).and_return({})
|
67
|
+
allow(Rails).to receive_message_chain(:application, :class).and_return('Dummy::Application')
|
59
68
|
end
|
60
69
|
|
61
70
|
def stub_controller_and_action(controller, action)
|
62
|
-
helper.
|
71
|
+
allow(helper).to receive(:controller_path).and_return(controller.to_s)
|
72
|
+
allow(helper).to receive(:action_name).and_return(action.to_s)
|
63
73
|
end
|
64
74
|
|
65
75
|
def helper
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: title
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Caleb Thompson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-08-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -147,8 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
147
147
|
- !ruby/object:Gem::Version
|
148
148
|
version: '0'
|
149
149
|
requirements: []
|
150
|
-
|
151
|
-
rubygems_version: 2.5.1
|
150
|
+
rubygems_version: 3.1.2
|
152
151
|
signing_key:
|
153
152
|
specification_version: 4
|
154
153
|
summary: I18n your <title>s
|