page_title 0.0.2 → 0.0.3

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
2
  SHA1:
3
- metadata.gz: 0442979508a4ac0dc6e2ab080044c3e80fa9fa6d
4
- data.tar.gz: 7a48f169530fe9f6da8a5cee9f61dbbcd7a1d9af
3
+ metadata.gz: 6ebdec67a8353f9c6dca9167062bf4f8c4e4ac29
4
+ data.tar.gz: edd75fc6dc083c3f04267697f7c56a0d9c4b18cc
5
5
  SHA512:
6
- metadata.gz: b3c205d7e98777d639c2bbd74aa817150a53979e51eb14d7fde2d3c50c2ca4abd4de879fcf53ce093cbf18f7d1f9b49ceba78064bc7769baa49d1d28c504f267
7
- data.tar.gz: a5f8dcea30ceaf8b936e12a83ab115ed722c13348aed54140a6c69ab2751d8d965936020bf681700c6254756e2a458385c5fac293122921935d1d051cb08444c
6
+ metadata.gz: 300153de050d929fa3a92840220ae23a4acfa9a8dfbab26913d6ed57f29972f356460b976ca7aa0e7ba20eac48448e6be90454f2347c79e9a9befdfec018cad0
7
+ data.tar.gz: d8857320577d41796a912dc42cbd0577f6dd743ae567f04ef679cd8033a33de81405cf2654a7ff7a36b6a631dfc440df416816abea6fd83cfda8802c44ffaa1f
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- page_title (0.0.2)
4
+ page_title (0.0.3)
5
5
  rails
6
6
 
7
7
  GEM
@@ -31,7 +31,7 @@ GEM
31
31
  multi_json (~> 1.3)
32
32
  thread_safe (~> 0.1)
33
33
  tzinfo (~> 0.3.37)
34
- arel (4.0.0)
34
+ arel (4.0.1)
35
35
  atomic (1.1.14)
36
36
  awesome_print (1.2.0)
37
37
  builder (3.1.4)
@@ -6,6 +6,13 @@ require "page_title/version"
6
6
 
7
7
  module PageTitle
8
8
  class Base
9
+ # Set all action aliases.
10
+ ACTION_ALIAS = {
11
+ "update" => "edit",
12
+ "create" => "new",
13
+ "destroy" => "remove"
14
+ }
15
+
9
16
  # Set the controller instance. It must implement
10
17
  # the methods controller_name and action_name.
11
18
  attr_reader :controller
@@ -37,6 +44,10 @@ module PageTitle
37
44
  I18n.t("titles.base", title: title_translation)
38
45
  end
39
46
 
47
+ def normalized_action_name
48
+ ACTION_ALIAS.fetch(controller.action_name, controller.action_name)
49
+ end
50
+
40
51
  def normalized_controller_name
41
52
  controller.class.name.underscore
42
53
  .gsub(/_controller/, "")
@@ -44,7 +55,7 @@ module PageTitle
44
55
  end
45
56
 
46
57
  def title_scope
47
- [normalized_controller_name, controller.action_name].join(".")
58
+ [normalized_controller_name, normalized_action_name].join(".")
48
59
  end
49
60
  end
50
61
  end
@@ -1,3 +1,3 @@
1
1
  module PageTitle
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -29,4 +29,18 @@ describe PageTitle do
29
29
  expect(page_title.to_s).to eql("TITLE")
30
30
  }
31
31
  end
32
+
33
+ {
34
+ "update" => "edit",
35
+ "create" => "new",
36
+ "destroy" => "remove"
37
+ }.each do |action, alias_name|
38
+ context "action alias - #{action}" do
39
+ set_controller "site", action
40
+ set_translations "titles.site.#{alias_name}" => "TITLE",
41
+ "titles.base" => "%{title}"
42
+
43
+ it { expect(page_title.to_s).to eql("TITLE") }
44
+ end
45
+ end
32
46
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: page_title
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nando Vieira