title 0.0.7 → 0.0.8

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: c9ed9cfe7986e563d62faa4cefe3b89f306024a1
4
- data.tar.gz: 3037d1aab90cb329e833afba0289ab77441fbb1f
2
+ SHA256:
3
+ metadata.gz: a5223d4bc45bb6bde8e268cb533e675a4a77628b85518151e10d1033f20ef341
4
+ data.tar.gz: 9fc368e00d9242fad23bba51657b34e46c54b436c9cc48a54de4abd8c304ad3a
5
5
  SHA512:
6
- metadata.gz: f268b193660c5dccf85016a73baca651a74790c33d84912c6be41b81cf66b654bf062fc920158d7dedf5c46ee50f09b82ffca3a7f08083464cd21c0ba51d9b45
7
- data.tar.gz: 1f42157da292bbfc7cba1c9bcc8b6e21b23d441d5eee7ed64dd1a4120dfb79b941bdfa82b013fcd2b2d527a29f7c0e05dfe39bf5616b8795f0152e6d7e61a697
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.png)](https://travis-ci.org/calebthompson/title)
4
- [![Code Climate](https://codeclimate.com/github/calebthompson/title.png)](https://codeclimate.com/github/calebthompson/title)
5
- [![Coverage Status](https://coveralls.io/repos/calebthompson/title/badge.png)](https://coveralls.io/r/calebthompson/title)
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
- context.merge(default: defaults)
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
@@ -1,3 +1,3 @@
1
1
  module Title
2
- VERSION = '0.0.7'
2
+ VERSION = '0.0.8'
3
3
  end
@@ -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.stub_chain(:controller, :view_assigns).and_return('name' => 'Caleb')
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.stub_chain(:controller, :view_assigns).and_return('name' => 'Caleb')
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.stub(:controller_path).and_return('dashboards')
56
- helper.stub(:action_name)
57
- helper.stub_chain(:controller, :view_assigns).and_return({})
58
- Rails.stub_chain(:application, :class).and_return('Dummy::Application')
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.stub(controller_path: controller.to_s, action_name: action.to_s)
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.7
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: 2016-04-29 00:00:00.000000000 Z
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
- rubyforge_project:
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