diff --git a/lib/rails_utils.rb b/lib/rails_utils.rb index 2e8ac72..e8d4b4d 100644 --- a/lib/rails_utils.rb +++ b/lib/rails_utils.rb @@ -17,7 +17,7 @@ def page_class def page_title(options={}) default_page_title = "#{page_controller_class.capitalize} #{page_action_class.capitalize}" - i18n_options = { default: default_page_title }.reverse_merge!(options) + i18n_options = { default: default_page_title }.merge!(options) I18n.t("#{page_controller_class}.#{page_action_class}.title", i18n_options) end diff --git a/test/rails_utils_test.rb b/test/rails_utils_test.rb index 6c69a01..9d7c6dc 100644 --- a/test/rails_utils_test.rb +++ b/test/rails_utils_test.rb @@ -85,9 +85,13 @@ it "combines page_controller_class and page_action_class" do view.page_title.must_equal default_translation end + + it "uses :default provided by gem user" do + view.page_title(default: 'my custom default').must_equal 'my custom default' + end end - describe 'when translation is avaiable' do + describe 'when translation is available' do let(:action_name) { "show" } before { I18n.backend.store_translations("en", { controller_name.to_sym => { action_name.to_sym => { title: "An awesome title" } }}) } @@ -97,7 +101,7 @@ end end - describe "when translation is avaiable + interpolations" do + describe "when translation is available + interpolations" do let(:action_name) { "show" } before { I18n.backend.store_translations("en", { controller_name.to_sym => { action_name.to_sym => { title: "An awesome title, %{name}" } }}) }