page_title_helper 9.1.0 → 11.0.0
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 +4 -4
- data/CHANGELOG.md +24 -0
- data/Gemfile +6 -0
- data/README.md +1 -1
- data/Rakefile +5 -0
- data/page_title_helper.gemspec +29 -24
- metadata +21 -99
- data/CODE_OF_CONDUCT.md +0 -77
- data/lib/page_title_helper/version.rb +0 -5
- data/test/en.yml +0 -21
- data/test/en_wohaapp.yml +0 -12
- data/test/multiple_formats_test.rb +0 -74
- data/test/page_title_helper_test.rb +0 -137
- data/test/test_helper.rb +0 -43
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 814c87d118a884882a8b973f8400381a1f49ffea958b4d54dce1e2b3833b714d
|
|
4
|
+
data.tar.gz: 7cdd22ada5241cd9479bcbffa3eb22bbe5d7a393be28eaec792c0acc433d3c1e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7139b11ec04058df050796a9f5c67655e526f2a060b75ca810387eea73d94fcd91b777b702ab6cf3c26390958bd89162ba95003d20658f88444c385cdc953e68
|
|
7
|
+
data.tar.gz: 8af793d5d6ebb7a1b0dc49058af8c42c24238abed90804bd97172f21589b03e96868ceeeaa92e7298345cc18f3ac7b28185fec4c0eef8910392c4b7025f85a0f
|
data/CHANGELOG.md
CHANGED
|
@@ -20,8 +20,32 @@ about why a change log is important.
|
|
|
20
20
|
|
|
21
21
|
### Security
|
|
22
22
|
|
|
23
|
+
## 11.0.0: Add support for Ruby 4.0, drop support for Rails 7.2 and Ruby 3.2
|
|
24
|
+
|
|
25
|
+
### Added
|
|
26
|
+
|
|
27
|
+
- Add support for Ruby 4.0 (#240)
|
|
28
|
+
|
|
29
|
+
### Removed
|
|
30
|
+
|
|
31
|
+
- Drop support for Rails 7.2 (#264)
|
|
32
|
+
- Drop support for Ruby 3.2 (#246)
|
|
33
|
+
|
|
34
|
+
## 10.0.0: Add support for Rails 8.1, drop support for Ruby 3.1 and Rails < 7.2
|
|
35
|
+
|
|
36
|
+
### Added
|
|
37
|
+
|
|
38
|
+
- Add support for Rails 8.1 (#230, #232, #233)
|
|
39
|
+
|
|
40
|
+
### Removed
|
|
41
|
+
|
|
42
|
+
- Drop support for Ruby 3.1 (#219)
|
|
43
|
+
- Drop support for Rails 7.0 and 7.1 (#218, #220, #228)
|
|
44
|
+
|
|
23
45
|
## 9.1.0: Add support for Ruby 3.4
|
|
24
46
|
|
|
47
|
+
### Added
|
|
48
|
+
|
|
25
49
|
- Add support for Ruby 3.4 (#206)
|
|
26
50
|
|
|
27
51
|
## 9.0.0: Add support for Rails 8.0, drop support for Rails 6.1
|
data/Gemfile
CHANGED
data/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Page title helper
|
|
2
2
|
|
|
3
|
-
[](https://github.com/lwe/page_title_helper/actions/)
|
|
4
4
|
[](https://badge.fury.io/rb/page_title_helper)
|
|
5
5
|
|
|
6
6
|
This project adheres to [Semantic Versioning](https://semver.org/).
|
data/Rakefile
CHANGED
data/page_title_helper.gemspec
CHANGED
|
@@ -1,31 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
require 'page_title_helper/version'
|
|
1
|
+
# frozen_string_literal: true
|
|
3
2
|
|
|
4
|
-
Gem::Specification.new do |
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
s.description = 'Simple, internationalized and DRY page titles and headings for Rails.'
|
|
3
|
+
Gem::Specification.new do |spec|
|
|
4
|
+
spec.name = 'page_title_helper'
|
|
5
|
+
spec.summary = 'Simple, internationalized and DRY page titles and headings for Railspec.'
|
|
6
|
+
spec.version = '11.0.0'
|
|
7
|
+
spec.license = 'MIT'
|
|
10
8
|
|
|
11
|
-
|
|
9
|
+
spec.required_ruby_version = '>= 3.3.0'
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
spec.homepage = 'https://github.com/lwe/page_title_helper'
|
|
12
|
+
spec.authors = ['Lukas Westermann']
|
|
13
|
+
spec.email = ['lukaspec.westermann@gmail.com']
|
|
16
14
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
spec.metadata = {
|
|
16
|
+
'bug_tracker_uri' => 'https://github.com/lwe/page_title_helper/issues',
|
|
17
|
+
'changelog_uri' => 'https://github.com/lwe/page_title_helper/blob/master/CHANGELOG.md',
|
|
18
|
+
'documentation_uri' => 'https://www.rubydoc.info/gems/page_title_helper',
|
|
19
|
+
'homepage_uri' => spec.homepage,
|
|
20
|
+
'source_code_uri' => 'https://github.com/lwe/page_title_helper'
|
|
21
|
+
}
|
|
21
22
|
|
|
22
|
-
|
|
23
|
+
spec.files = %w[
|
|
24
|
+
CHANGELOG.md
|
|
25
|
+
Gemfile
|
|
26
|
+
LICENSE
|
|
27
|
+
README.md
|
|
28
|
+
Rakefile
|
|
29
|
+
lib/page_title_helper.rb
|
|
30
|
+
page_title_helper.gemspec
|
|
31
|
+
]
|
|
32
|
+
spec.extra_rdoc_files = %w[CHANGELOG.md LICENSE README.md]
|
|
33
|
+
spec.require_paths = ['lib']
|
|
23
34
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
s.add_development_dependency 'rake', '~> 13.2.1'
|
|
27
|
-
s.add_development_dependency 'rubocop', '~> 1.69.2'
|
|
28
|
-
s.add_development_dependency 'rubocop-rails', '~> 2.28.0'
|
|
29
|
-
s.add_development_dependency 'rubocop-rake', '~> 0.6.0'
|
|
30
|
-
s.add_development_dependency 'shoulda', '~> 4.0.0'
|
|
35
|
+
spec.add_dependency 'rails', '>= 8.0.0', '< 8.2'
|
|
31
36
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: page_title_helper
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 11.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Lukas Westermann
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: rails
|
|
@@ -16,116 +15,45 @@ dependencies:
|
|
|
16
15
|
requirements:
|
|
17
16
|
- - ">="
|
|
18
17
|
- !ruby/object:Gem::Version
|
|
19
|
-
version:
|
|
18
|
+
version: 8.0.0
|
|
20
19
|
- - "<"
|
|
21
20
|
- !ruby/object:Gem::Version
|
|
22
|
-
version: '8.
|
|
21
|
+
version: '8.2'
|
|
23
22
|
type: :runtime
|
|
24
23
|
prerelease: false
|
|
25
24
|
version_requirements: !ruby/object:Gem::Requirement
|
|
26
25
|
requirements:
|
|
27
26
|
- - ">="
|
|
28
27
|
- !ruby/object:Gem::Version
|
|
29
|
-
version:
|
|
28
|
+
version: 8.0.0
|
|
30
29
|
- - "<"
|
|
31
30
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: '8.
|
|
33
|
-
- !ruby/object:Gem::Dependency
|
|
34
|
-
name: rake
|
|
35
|
-
requirement: !ruby/object:Gem::Requirement
|
|
36
|
-
requirements:
|
|
37
|
-
- - "~>"
|
|
38
|
-
- !ruby/object:Gem::Version
|
|
39
|
-
version: 13.2.1
|
|
40
|
-
type: :development
|
|
41
|
-
prerelease: false
|
|
42
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
43
|
-
requirements:
|
|
44
|
-
- - "~>"
|
|
45
|
-
- !ruby/object:Gem::Version
|
|
46
|
-
version: 13.2.1
|
|
47
|
-
- !ruby/object:Gem::Dependency
|
|
48
|
-
name: rubocop
|
|
49
|
-
requirement: !ruby/object:Gem::Requirement
|
|
50
|
-
requirements:
|
|
51
|
-
- - "~>"
|
|
52
|
-
- !ruby/object:Gem::Version
|
|
53
|
-
version: 1.69.2
|
|
54
|
-
type: :development
|
|
55
|
-
prerelease: false
|
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
57
|
-
requirements:
|
|
58
|
-
- - "~>"
|
|
59
|
-
- !ruby/object:Gem::Version
|
|
60
|
-
version: 1.69.2
|
|
61
|
-
- !ruby/object:Gem::Dependency
|
|
62
|
-
name: rubocop-rails
|
|
63
|
-
requirement: !ruby/object:Gem::Requirement
|
|
64
|
-
requirements:
|
|
65
|
-
- - "~>"
|
|
66
|
-
- !ruby/object:Gem::Version
|
|
67
|
-
version: 2.28.0
|
|
68
|
-
type: :development
|
|
69
|
-
prerelease: false
|
|
70
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
71
|
-
requirements:
|
|
72
|
-
- - "~>"
|
|
73
|
-
- !ruby/object:Gem::Version
|
|
74
|
-
version: 2.28.0
|
|
75
|
-
- !ruby/object:Gem::Dependency
|
|
76
|
-
name: rubocop-rake
|
|
77
|
-
requirement: !ruby/object:Gem::Requirement
|
|
78
|
-
requirements:
|
|
79
|
-
- - "~>"
|
|
80
|
-
- !ruby/object:Gem::Version
|
|
81
|
-
version: 0.6.0
|
|
82
|
-
type: :development
|
|
83
|
-
prerelease: false
|
|
84
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
85
|
-
requirements:
|
|
86
|
-
- - "~>"
|
|
87
|
-
- !ruby/object:Gem::Version
|
|
88
|
-
version: 0.6.0
|
|
89
|
-
- !ruby/object:Gem::Dependency
|
|
90
|
-
name: shoulda
|
|
91
|
-
requirement: !ruby/object:Gem::Requirement
|
|
92
|
-
requirements:
|
|
93
|
-
- - "~>"
|
|
94
|
-
- !ruby/object:Gem::Version
|
|
95
|
-
version: 4.0.0
|
|
96
|
-
type: :development
|
|
97
|
-
prerelease: false
|
|
98
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
99
|
-
requirements:
|
|
100
|
-
- - "~>"
|
|
101
|
-
- !ruby/object:Gem::Version
|
|
102
|
-
version: 4.0.0
|
|
103
|
-
description: Simple, internationalized and DRY page titles and headings for Rails.
|
|
31
|
+
version: '8.2'
|
|
104
32
|
email:
|
|
105
|
-
-
|
|
33
|
+
- lukaspec.westermann@gmail.com
|
|
106
34
|
executables: []
|
|
107
35
|
extensions: []
|
|
108
|
-
extra_rdoc_files:
|
|
36
|
+
extra_rdoc_files:
|
|
37
|
+
- CHANGELOG.md
|
|
38
|
+
- LICENSE
|
|
39
|
+
- README.md
|
|
109
40
|
files:
|
|
110
41
|
- CHANGELOG.md
|
|
111
|
-
- CODE_OF_CONDUCT.md
|
|
112
42
|
- Gemfile
|
|
113
43
|
- LICENSE
|
|
114
44
|
- README.md
|
|
115
45
|
- Rakefile
|
|
116
46
|
- lib/page_title_helper.rb
|
|
117
|
-
- lib/page_title_helper/version.rb
|
|
118
47
|
- page_title_helper.gemspec
|
|
119
|
-
- test/en.yml
|
|
120
|
-
- test/en_wohaapp.yml
|
|
121
|
-
- test/multiple_formats_test.rb
|
|
122
|
-
- test/page_title_helper_test.rb
|
|
123
|
-
- test/test_helper.rb
|
|
124
48
|
homepage: https://github.com/lwe/page_title_helper
|
|
125
49
|
licenses:
|
|
126
50
|
- MIT
|
|
127
|
-
metadata:
|
|
128
|
-
|
|
51
|
+
metadata:
|
|
52
|
+
bug_tracker_uri: https://github.com/lwe/page_title_helper/issues
|
|
53
|
+
changelog_uri: https://github.com/lwe/page_title_helper/blob/master/CHANGELOG.md
|
|
54
|
+
documentation_uri: https://www.rubydoc.info/gems/page_title_helper
|
|
55
|
+
homepage_uri: https://github.com/lwe/page_title_helper
|
|
56
|
+
source_code_uri: https://github.com/lwe/page_title_helper
|
|
129
57
|
rdoc_options: []
|
|
130
58
|
require_paths:
|
|
131
59
|
- lib
|
|
@@ -133,20 +61,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
133
61
|
requirements:
|
|
134
62
|
- - ">="
|
|
135
63
|
- !ruby/object:Gem::Version
|
|
136
|
-
version: 3.
|
|
64
|
+
version: 3.3.0
|
|
137
65
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
138
66
|
requirements:
|
|
139
67
|
- - ">="
|
|
140
68
|
- !ruby/object:Gem::Version
|
|
141
69
|
version: '0'
|
|
142
70
|
requirements: []
|
|
143
|
-
rubygems_version:
|
|
144
|
-
signing_key:
|
|
71
|
+
rubygems_version: 4.0.20
|
|
145
72
|
specification_version: 4
|
|
146
|
-
summary: Simple, internationalized and DRY page titles and headings for
|
|
147
|
-
test_files:
|
|
148
|
-
- test/en.yml
|
|
149
|
-
- test/en_wohaapp.yml
|
|
150
|
-
- test/multiple_formats_test.rb
|
|
151
|
-
- test/page_title_helper_test.rb
|
|
152
|
-
- test/test_helper.rb
|
|
73
|
+
summary: Simple, internationalized and DRY page titles and headings for Railspec.
|
|
74
|
+
test_files: []
|
data/CODE_OF_CONDUCT.md
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
# Contributor Code of Conduct
|
|
2
|
-
|
|
3
|
-
## Our Pledge
|
|
4
|
-
|
|
5
|
-
In the interest of fostering an open and welcoming environment, we as
|
|
6
|
-
contributors and maintainers pledge to making participation in our project and
|
|
7
|
-
our community a harassment-free experience for everyone, regardless of age,
|
|
8
|
-
body size, disability, ethnicity, gender identity and expression, level of
|
|
9
|
-
experience, nationality, personal appearance, race, religion, or sexual
|
|
10
|
-
identity and orientation.
|
|
11
|
-
|
|
12
|
-
## Our Standards
|
|
13
|
-
|
|
14
|
-
Examples of behavior that contributes to creating a positive environment
|
|
15
|
-
include:
|
|
16
|
-
|
|
17
|
-
* Using welcoming and inclusive language
|
|
18
|
-
* Being respectful of differing viewpoints and experiences
|
|
19
|
-
* Gracefully accepting constructive criticism
|
|
20
|
-
* Focusing on what is best for the community
|
|
21
|
-
* Showing empathy towards other community members
|
|
22
|
-
|
|
23
|
-
Examples of unacceptable behavior by participants include:
|
|
24
|
-
|
|
25
|
-
* The use of sexualized language or imagery and unwelcome sexual attention or
|
|
26
|
-
advances
|
|
27
|
-
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
28
|
-
* Public or private harassment
|
|
29
|
-
* Publishing others' private information, such as a physical or electronic
|
|
30
|
-
address, without explicit permission
|
|
31
|
-
* Other conduct which could reasonably be considered inappropriate in a
|
|
32
|
-
professional setting
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
## Our Responsibilities
|
|
36
|
-
|
|
37
|
-
Project maintainers are responsible for clarifying the standards of acceptable
|
|
38
|
-
behavior and are expected to take appropriate and fair corrective action in
|
|
39
|
-
response to any instances of unacceptable behavior.
|
|
40
|
-
|
|
41
|
-
Project maintainers have the right and responsibility to remove, edit, or
|
|
42
|
-
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
43
|
-
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
44
|
-
permanently any contributor for other behaviors that they deem inappropriate,
|
|
45
|
-
threatening, offensive, or harmful.
|
|
46
|
-
|
|
47
|
-
## Scope
|
|
48
|
-
|
|
49
|
-
This Code of Conduct applies both within project spaces and in public spaces
|
|
50
|
-
when an individual is representing the project or its community. Examples of
|
|
51
|
-
representing a project or community include using an official project e-mail
|
|
52
|
-
address, posting via an official social media account, or acting as an
|
|
53
|
-
appointed representative at an online or offline event. Representation of a
|
|
54
|
-
project may be further defined and clarified by project maintainers.
|
|
55
|
-
|
|
56
|
-
## Enforcement
|
|
57
|
-
|
|
58
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
59
|
-
reported by contacting the project team at (lukas dot westermann at gmail dot com).
|
|
60
|
-
All complaints will be reviewed and investigated and will result in a response
|
|
61
|
-
that is deemed necessary and appropriate to the circumstances. The project team
|
|
62
|
-
is obligated to maintain confidentiality with regard to the reporter of an
|
|
63
|
-
incident. Further details of specific enforcement policies may be posted
|
|
64
|
-
separately.
|
|
65
|
-
|
|
66
|
-
Project maintainers who do not follow or enforce the Code of Conduct in good
|
|
67
|
-
faith may face temporary or permanent repercussions as determined by other
|
|
68
|
-
members of the project's leadership.
|
|
69
|
-
|
|
70
|
-
## Attribution
|
|
71
|
-
|
|
72
|
-
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
|
73
|
-
version 1.4, available at
|
|
74
|
-
[https://contributor-covenant.org/version/1/4/][version].
|
|
75
|
-
|
|
76
|
-
[homepage]: https://contributor-covenant.org
|
|
77
|
-
[version]: https://contributor-covenant.org/version/1/4/
|
data/test/en.yml
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
en:
|
|
2
|
-
contacts:
|
|
3
|
-
list:
|
|
4
|
-
title: contacts.list.title
|
|
5
|
-
page_title: custom contacts title
|
|
6
|
-
myhaml:
|
|
7
|
-
title: this is haml!
|
|
8
|
-
admin:
|
|
9
|
-
account:
|
|
10
|
-
title: Account administration
|
|
11
|
-
show:
|
|
12
|
-
title: Account
|
|
13
|
-
new:
|
|
14
|
-
title: New account
|
|
15
|
-
edit:
|
|
16
|
-
title: Edit account
|
|
17
|
-
|
|
18
|
-
placeholder: "Displaying %{name}"
|
|
19
|
-
app:
|
|
20
|
-
tagline: Default
|
|
21
|
-
other_tagline: Other default
|
data/test/en_wohaapp.yml
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'minitest/autorun'
|
|
4
|
-
require 'test_helper'
|
|
5
|
-
|
|
6
|
-
class MultipleFormatsTest < ActiveSupport::TestCase
|
|
7
|
-
context '#page_title supporting multiple formats through arrays' do
|
|
8
|
-
setup do
|
|
9
|
-
@view = TestView.new('contacts', 'list')
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
should 'accept an array passed in the page_title block and use the second argument as format' do
|
|
13
|
-
@view.page_title { ['Oh my...!', ':title // :app'] }
|
|
14
|
-
assert_equal 'Oh my...! // Page title helper', @view.page_title
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
should 'still return title as string and not the array' do
|
|
18
|
-
assert_equal('Oh my...!', @view.page_title { ['Oh my...!', ':title // :app'] })
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
context '#page_title with format aliases' do
|
|
23
|
-
setup do
|
|
24
|
-
PageTitleHelper.formats[:myformat] = ':title <-> :app'
|
|
25
|
-
@view = TestView.new('contacts', 'list')
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
should 'have a default alias named :app' do
|
|
29
|
-
assert_equal 'Page title helper', @view.page_title(format: :app)
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
should 'allow custom aliases to be defined and used' do
|
|
33
|
-
@view.page_title { 'Test' }
|
|
34
|
-
assert_equal 'Test <-> Page title helper', @view.page_title(format: :myformat)
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
should 'fallback to default format, if array is not big enough (i.e. only contains single element...)' do
|
|
38
|
-
assert_equal('Test', @view.page_title { ['Test'] })
|
|
39
|
-
assert_equal 'Test - Page title helper', @view.page_title
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
context 'used with the array block' do
|
|
43
|
-
should 'also allow aliases returned in that array thingy' do
|
|
44
|
-
assert_equal('Test', @view.page_title { ['Test', :myformat] })
|
|
45
|
-
assert_equal 'Test <-> Page title helper', @view.page_title
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
should 'override locally supplied :format arguments' do
|
|
49
|
-
assert_equal('Something', @view.page_title { ['Something', '* * * :title * * *'] })
|
|
50
|
-
# yeah, using x-tra ugly titles :)
|
|
51
|
-
assert_equal '* * * Something * * *', @view.page_title(format: '-= :title =-')
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
context '#page_title, aliases and YAML' do
|
|
57
|
-
setup do
|
|
58
|
-
I18n.load_path = [File.join(File.dirname(__FILE__), 'en_wohaapp.yml')]
|
|
59
|
-
I18n.reload!
|
|
60
|
-
PageTitleHelper.formats[:promo] = ':app > :title'
|
|
61
|
-
@view = TestView.new
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
should 'allow to override format through YAML' do
|
|
65
|
-
@view.controller! 'pages', 'features'
|
|
66
|
-
assert_equal 'Wohaapp > Feature comparison', @view.page_title
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
should 'handle raw string formats from YAML as well' do
|
|
70
|
-
@view.controller! 'pages', 'signup'
|
|
71
|
-
assert_equal 'Sign up for Wohaapp now!', @view.page_title
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
end
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'minitest/autorun'
|
|
4
|
-
require 'test_helper'
|
|
5
|
-
|
|
6
|
-
class PageTitleHelperTest < ActiveSupport::TestCase
|
|
7
|
-
context 'PageTitleHelper' do
|
|
8
|
-
setup do
|
|
9
|
-
I18n.load_path = [File.join(File.dirname(__FILE__), 'en.yml')]
|
|
10
|
-
I18n.reload!
|
|
11
|
-
|
|
12
|
-
@view = TestView.new('contacts', 'list')
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
context '::Interpolations' do
|
|
16
|
-
should 'interpolate :app and :title' do
|
|
17
|
-
assert_equal 'Page title helper', PageTitleHelper::Interpolations.app({})
|
|
18
|
-
assert_equal 'Appname', PageTitleHelper::Interpolations.app(app: 'Appname')
|
|
19
|
-
assert_equal 'untitled', PageTitleHelper::Interpolations.title(title: 'untitled')
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
should 'allow adding custom interpolations' do
|
|
23
|
-
# extend Interpolations
|
|
24
|
-
PageTitleHelper.interpolates(:app_reverse) { |env| app(env).reverse.downcase }
|
|
25
|
-
|
|
26
|
-
assert_equal 'anna', PageTitleHelper::Interpolations.app_reverse(app: 'Anna')
|
|
27
|
-
assert_equal 'ppa', PageTitleHelper::Interpolations.interpolate(':app_reverse', app: 'app')
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
should 'interpolate in correct order, i.e. longest first' do
|
|
31
|
-
PageTitleHelper.interpolates(:foobar) { |_env| 'foobar' }
|
|
32
|
-
PageTitleHelper.interpolates(:foobar_test) { |_env| 'foobar_test' }
|
|
33
|
-
PageTitleHelper.interpolates(:title_foobar) { |_env| 'title_foobar' }
|
|
34
|
-
|
|
35
|
-
assert_equal 'title_foobar / foobar_test / foobar / foobar_x',
|
|
36
|
-
PageTitleHelper::Interpolations.interpolate(':title_foobar / :foobar_test / :foobar / :foobar_x',
|
|
37
|
-
{})
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
context '#page_title (define w/ block)' do
|
|
42
|
-
should 'return title from block and render with app name' do
|
|
43
|
-
assert_equal('foo', @view.page_title { 'foo' })
|
|
44
|
-
assert_equal 'foo - Page title helper', @view.page_title
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
should 'set custom title using a translation with a placeholder' do
|
|
48
|
-
assert_equal('Displaying Bella', @view.page_title { I18n.t(:placeholder, name: 'Bella') })
|
|
49
|
-
assert_equal 'Displaying Bella - Page title helper', @view.page_title
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
context '#page_title! (define)' do
|
|
54
|
-
should 'set page title' do
|
|
55
|
-
assert_equal 'test', @view.page_title!('test')
|
|
56
|
-
assert_equal 'test - Page title helper', @view.page_title
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
should 'set page title and interpret second argument as custom format' do
|
|
60
|
-
PageTitleHelper.formats[:bang] = ':title !! :app'
|
|
61
|
-
assert_equal 'test', @view.page_title!('test', :bang)
|
|
62
|
-
assert_equal 'test !! Page title helper', @view.page_title
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
context '#page_title (rendering)' do
|
|
67
|
-
should 'read default title from I18n, based on controller/action' do
|
|
68
|
-
assert_equal 'contacts.list.title - Page title helper', @view.page_title
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
should 'only print app name if format: :app' do
|
|
72
|
-
assert_equal 'Page title helper', @view.page_title(format: :app)
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
should 'print custom app name if :app defined and format: :app' do
|
|
76
|
-
assert_equal 'Some app', @view.page_title(app: 'Some app', format: :app)
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
should 'use custom format, if :format option is defined' do
|
|
80
|
-
assert_equal('test', @view.page_title { 'test' })
|
|
81
|
-
assert_equal 'Some app :: test', @view.page_title(app: 'Some app', format: ':app :: :title')
|
|
82
|
-
assert_equal 'Some app / test', @view.page_title(format: 'Some app / :title')
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
should 'return just title if format: false is passed' do
|
|
86
|
-
assert_equal('untitled', @view.page_title { 'untitled' })
|
|
87
|
-
assert_equal 'untitled', @view.page_title(format: false)
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
should 'return title if format: false and when using the DRY-I18n titles' do
|
|
91
|
-
assert_equal 'contacts.list.title', @view.page_title(format: false)
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
should 'render translated :"app.tagline" if no title is available' do
|
|
95
|
-
@view.controller! 'view/does', 'not_exist'
|
|
96
|
-
assert_equal 'Default - Page title helper', @view.page_title
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
should 'render use controller.title as first fallback, if no title exists' do
|
|
100
|
-
@view.controller! 'admin/account', 'index'
|
|
101
|
-
assert_equal 'Account administration - Page title helper', @view.page_title(default: 'Other default')
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
should 'not fallback to controller.title if controller.action.title exists' do
|
|
105
|
-
@view.controller! 'admin/account', 'show'
|
|
106
|
-
assert_equal 'Account - Page title helper', @view.page_title(default: 'Other default')
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
should 'fallback to controller.new.title if create has no title' do
|
|
110
|
-
@view.controller! 'admin/account', 'create'
|
|
111
|
-
assert_equal 'New account - Page title helper', @view.page_title(default: 'Other default')
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
should 'fallback to controller.edit.title if update has no title' do
|
|
115
|
-
@view.controller! 'admin/account', 'update'
|
|
116
|
-
assert_equal 'Edit account - Page title helper', @view.page_title(default: 'Other default')
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
should 'render custom "default" string, if title is not available nor controller.title' do
|
|
120
|
-
@view.controller! 'view/does', 'not_exist'
|
|
121
|
-
assert_equal 'Some default - Page title helper', @view.page_title(default: 'Some default')
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
should 'render custom default translation, if title is not available nor controller.title' do
|
|
125
|
-
@view.controller! 'view/does', 'not_exist'
|
|
126
|
-
assert_equal 'Other default - Page title helper', @view.page_title(default: :'app.other_tagline')
|
|
127
|
-
end
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
context 'README.md' do
|
|
131
|
-
should 'interpolate :controller' do
|
|
132
|
-
PageTitleHelper.interpolates(:controller) { |env| env[:view].controller.controller_name.humanize }
|
|
133
|
-
assert_equal 'contacts.list.title - Test', @view.page_title(format: ':title - :controller')
|
|
134
|
-
end
|
|
135
|
-
end
|
|
136
|
-
end
|
|
137
|
-
end
|
data/test/test_helper.rb
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'active_support'
|
|
4
|
-
require 'action_view'
|
|
5
|
-
require 'page_title_helper'
|
|
6
|
-
|
|
7
|
-
unless defined?(IRB)
|
|
8
|
-
require 'active_support/test_case'
|
|
9
|
-
require 'shoulda'
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
# Use sorted tests. We need to change that after the tests have been converted
|
|
13
|
-
# to RSpec.
|
|
14
|
-
ActiveSupport.test_order = :sorted
|
|
15
|
-
|
|
16
|
-
# fake global Rails module
|
|
17
|
-
module Rails
|
|
18
|
-
class << self
|
|
19
|
-
def root
|
|
20
|
-
@root ||= Pathname.new('/this/is/just/for/testing/page_title_helper')
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def env
|
|
24
|
-
'test'
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
# Mock ActionView a bit to allow easy (fake) template assignment
|
|
30
|
-
class TestView < ActionView::Base
|
|
31
|
-
attr_reader :controller
|
|
32
|
-
|
|
33
|
-
def initialize(controller_path = nil, action = nil)
|
|
34
|
-
@controller = ActionView::TestCase::TestController.new
|
|
35
|
-
@controller.controller_path = controller_path
|
|
36
|
-
params[:action] = action if action
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
def controller!(controller_path, action)
|
|
40
|
-
@controller.controller_path = controller_path
|
|
41
|
-
params[:action] = action
|
|
42
|
-
end
|
|
43
|
-
end
|