Instance helper to replace site title helper (#2038)
* Move site title helper to instance helper (name change only) * Remove newline in <title> tag * Add site_hostname helper method to wrap up local_domain value * Use site_hostname helper in places that need local_domain valueth-downstream
parent
4cc1317571
commit
d087c95aa7
@ -0,0 +1,11 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module InstanceHelper
|
||||
def site_title
|
||||
Setting.site_title.to_s
|
||||
end
|
||||
|
||||
def site_hostname
|
||||
Rails.configuration.x.local_domain
|
||||
end
|
||||
end
|
@ -1,7 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module SiteTitleHelper
|
||||
def site_title
|
||||
Setting.site_title.to_s
|
||||
end
|
||||
end
|
@ -1,6 +1,6 @@
|
||||
object false
|
||||
|
||||
node(:uri) { Rails.configuration.x.local_domain }
|
||||
node(:uri) { site_hostname }
|
||||
node(:title) { Setting.site_title }
|
||||
node(:description) { Setting.site_description }
|
||||
node(:email) { Setting.site_contact_email }
|
||||
|
@ -1,5 +1,5 @@
|
||||
<%= yield %>
|
||||
---
|
||||
|
||||
<%= t('application_mailer.signature', instance: Rails.configuration.x.local_domain) %>
|
||||
<%= t('application_mailer.signature', instance: site_hostname) %>
|
||||
<%= t('application_mailer.settings', link: settings_preferences_url) %>
|
||||
|
@ -1,5 +1,5 @@
|
||||
.landing-strip
|
||||
= t('landing_strip_html',
|
||||
name: content_tag(:span, display_name(account), class: :emojify),
|
||||
domain: Rails.configuration.x.local_domain,
|
||||
domain: site_hostname,
|
||||
sign_up_path: new_user_registration_path)
|
||||
|
@ -0,0 +1,33 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe InstanceHelper do
|
||||
describe 'site_title' do
|
||||
it 'Uses the Setting.site_title value when it exists' do
|
||||
Setting.site_title = 'New site title'
|
||||
|
||||
expect(helper.site_title).to eq 'New site title'
|
||||
end
|
||||
|
||||
it 'returns empty string when Setting.site_title is nil' do
|
||||
Setting.site_title = nil
|
||||
|
||||
expect(helper.site_title).to eq ''
|
||||
end
|
||||
end
|
||||
|
||||
describe 'site_hostname' do
|
||||
around(:each) do |example|
|
||||
before = Rails.configuration.x.local_domain
|
||||
example.run
|
||||
Rails.configuration.x.local_domain = before
|
||||
end
|
||||
|
||||
it 'returns the local domain value' do
|
||||
Rails.configuration.x.local_domain = 'example.com'
|
||||
|
||||
expect(helper.site_hostname).to eq 'example.com'
|
||||
end
|
||||
end
|
||||
end
|
@ -1,15 +0,0 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe "site_title" do
|
||||
it "Uses the Setting.site_title value when it exists" do
|
||||
Setting.site_title = "New site title"
|
||||
|
||||
expect(helper.site_title).to eq "New site title"
|
||||
end
|
||||
|
||||
it "returns empty string when Setting.site_title is nil" do
|
||||
Setting.site_title = nil
|
||||
|
||||
expect(helper.site_title).to eq ""
|
||||
end
|
||||
end
|
Loading…
Reference in new issue