WpTheme specs
This commit is contained in:
@@ -12,10 +12,16 @@ class WpTheme < WpItem
|
|||||||
|
|
||||||
def allowed_options; super << :style_url end
|
def allowed_options; super << :style_url end
|
||||||
|
|
||||||
|
# Sets the @uri
|
||||||
|
#
|
||||||
|
# @param [ URI ] target_base_uri The URI of the wordpress blog
|
||||||
|
#
|
||||||
|
# @return [ void ]
|
||||||
def forge_uri(target_base_uri)
|
def forge_uri(target_base_uri)
|
||||||
@uri = target_base_uri.merge(URI.encode(wp_content_dir + '/themes/' + name + '/')) # make suer that this last / is present (spec)
|
@uri = target_base_uri.merge(URI.encode(wp_content_dir + '/themes/' + name + '/'))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# @return [ String ] The url to the theme stylesheet
|
||||||
def style_url
|
def style_url
|
||||||
unless @style_url
|
unless @style_url
|
||||||
@style_url = uri.merge('style.css').to_s
|
@style_url = uri.merge('style.css').to_s
|
||||||
|
|||||||
32
spec/lib/common/models/wp_theme_spec.rb
Normal file
32
spec/lib/common/models/wp_theme_spec.rb
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
# encoding: UTF-8
|
||||||
|
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe WpTheme do
|
||||||
|
subject(:wp_theme) { WpTheme.new(uri, options) }
|
||||||
|
let(:uri) { URI.parse('http://example.com') }
|
||||||
|
let(:options) { { name: 'theme-name' } }
|
||||||
|
let(:theme_path) { 'wp-content/themes/theme-name/' }
|
||||||
|
|
||||||
|
describe '#allowed_options' do
|
||||||
|
its(:allowed_options) { should include :style_url }
|
||||||
|
end
|
||||||
|
|
||||||
|
describe '#forge_uri' do
|
||||||
|
its(:uri) { should == uri.merge(theme_path) }
|
||||||
|
end
|
||||||
|
|
||||||
|
describe '#style_url' do
|
||||||
|
its(:style_url) { should == uri.merge(theme_path + '/style.css').to_s }
|
||||||
|
|
||||||
|
context 'when its already set' do
|
||||||
|
it 'returns it instead of the default one' do
|
||||||
|
url = uri.merge(theme_path + '/custom.css').to_s
|
||||||
|
wp_theme.style_url = url
|
||||||
|
|
||||||
|
wp_theme.style_url.should == url
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user