Permalink
Browse files

Merge pull request #1576 from resolve/site_name_i18n

Introduced my patch for site_name being configurable in i18n as well but...
  • Loading branch information...
2 parents 0ed0f45 + 94e5474 commit 6bc0c98344e43c6d4ec74e70f2d4dc3c5e598d34 @parndt parndt committed Apr 10, 2012
Showing with 48 additions and 5 deletions.
  1. +11 −5 core/lib/refinery/core/configuration.rb
  2. +37 −0 core/spec/lib/refinery/core/configuration_spec.rb
@@ -37,12 +37,18 @@ def config.register_stylesheet(*args)
self.stylesheets << Stylesheet.new(*args)
end
- def self.clear_javascripts!
- self.javascripts = []
- end
+ class << self
+ def clear_javascripts!
+ self.javascripts = []
+ end
- def self.clear_stylesheets!
- self.stylesheets = []
+ def clear_stylesheets!
+ self.stylesheets = []
+ end
+
+ def site_name
+ ::I18n.t('site_name', :scope => 'refinery.core.config', :default => config.site_name)
+ end
end
# wrapper for stylesheet registration
@@ -0,0 +1,37 @@
+require 'spec_helper'
+
+module Refinery
+ module Core
+ describe 'configuration' do
+ describe '.site_name' do
+ # reset any previously defined site name
+ before do
+ Refinery::Core.site_name = nil
+ end
+
+ context 'when set in configuration' do
+ it 'returns name set by Refinery::Core.config' do
+ Refinery::Core.stub(:site_name).and_return('Test Site Name')
+ Refinery::Core.site_name.should eq('Test Site Name')
+ end
+ end
+
+ context 'when set in locale file' do
+ before do
+ ::I18n.backend.store_translations :en, :refinery => {
+ :core => {
+ :config => {
+ :site_name => 'I18n Site Name'
+ }
+ }
+ }
+ end
+
+ it 'returns name set in locale' do
+ Refinery::Core.site_name.should eq('I18n Site Name')
+ end
+ end
+ end
+ end
+ end
+end

0 comments on commit 6bc0c98

Please sign in to comment.