Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Remove deprecated layout locations

  • Loading branch information...
commit 01821993f5aaadfbd5a2e85781b44b89478948ed 1 parent 9c0afeb
@mvz mvz authored fdv committed
Showing with 44 additions and 38 deletions.
  1. +1 −9 app/models/theme.rb
  2. +43 −29 spec/models/theme_spec.rb
View
10 app/models/theme.rb
@@ -13,16 +13,8 @@ def layout(action=:default)
if File.exists? "#{::Rails.root.to_s}/themes/#{name}/views/layouts/pages.html.erb"
return "layouts/pages.html"
end
- # FIXME: This old-fashioned location will be removed soon
- if File.exists? "#{::Rails.root.to_s}/themes/#{name}/layouts/pages.html.erb"
- return "#{::Rails.root.to_s}/themes/#{name}/layouts/pages.html"
- end
- end
- if File.exists? "#{::Rails.root.to_s}/themes/#{name}/views/layouts/default.html.erb"
- return "layouts/default.html"
end
- # FIXME: This old-fashioned location will be removed soon
- "#{::Rails.root.to_s}/themes/#{name}/layouts/default.html.erb"
+ "layouts/default.html"
end
def description
View
72 spec/models/theme_spec.rb
@@ -1,46 +1,60 @@
require 'spec_helper'
-describe 'Given a new test theme' do
- it 'layout path should be "#{::Rails.root.to_s}/themes/test/layouts/default.html.erb"' do
- theme = Theme.new("test", "test")
- theme.layout('index').should == "#{::Rails.root.to_s}/themes/test/layouts/default.html.erb"
- end
-end
+describe Theme do
+ let(:blog) { build_stubbed :blog }
+ let(:default_theme) { blog.current_theme }
-describe 'Given the default theme' do
- before(:each) do
- FactoryGirl.create(:blog)
- @theme = Blog.default.current_theme
+ describe '#layout' do
+ it 'returns "layouts/default.html" by default' do
+ theme = Theme.new("test", "test")
+ theme.layout('index').should eq "layouts/default.html"
+ end
+
+ # FIXME: Test pages layout
end
- it 'theme should be typographic' do
- @theme.name.should == 'bootstrap'
+ describe '#name' do
+ it "returns the theme's name (default: bootstrap)" do
+ default_theme.name.should eq 'bootstrap'
+ end
end
- it 'theme description should be correct' do
- @theme.description.should ==
- File.open(::Rails.root.to_s + '/themes/bootstrap/about.markdown') {|f| f.read}
+ describe '#description' do
+ it 'returns the contents of the corresponding markdown file' do
+ default_theme.description.should eq(
+ File.open(::Rails.root.to_s + '/themes/bootstrap/about.markdown') {|f| f.read})
+ end
end
- it 'theme_from_path should find the correct theme' do
- Theme.theme_from_path(::Rails.root.to_s + 'themes/typographic').name.should == 'typographic'
+ describe '.theme_from_path' do
+ it 'finds the correct theme' do
+ Theme.theme_from_path(::Rails.root.to_s + 'themes/bootstrap').name.
+ should eq 'bootstrap'
+ end
end
- it '#search_theme_path finds the right things 2' do
- fake_blue_theme_dir = 'fake_blue_theme_dir'
- fake_red_theme_dir = 'fake_red_theme_dir'
- fake_bad_theme_dir = 'fake_bad_theme_dir'
- Dir.should_receive(:glob).and_return([fake_blue_theme_dir, fake_bad_theme_dir, fake_red_theme_dir])
- File.should_receive(:readable?).with(fake_blue_theme_dir + "/about.markdown").and_return(true)
- File.should_receive(:readable?).with(fake_bad_theme_dir + "/about.markdown").and_return(false)
- File.should_receive(:readable?).with(fake_red_theme_dir + "/about.markdown").and_return(true)
- Theme.search_theme_directory.should == %w{ fake_blue_theme_dir fake_red_theme_dir }
+ describe '.search_theme_path' do
+ it 'finds directories containing an about.markdown file' do
+ fake_blue_theme_dir = 'fake_blue_theme_dir'
+ fake_red_theme_dir = 'fake_red_theme_dir'
+ fake_bad_theme_dir = 'fake_bad_theme_dir'
+ Dir.should_receive(:glob).and_return([fake_blue_theme_dir, fake_bad_theme_dir, fake_red_theme_dir])
+ File.should_receive(:readable?).with(fake_blue_theme_dir + "/about.markdown").and_return(true)
+ File.should_receive(:readable?).with(fake_bad_theme_dir + "/about.markdown").and_return(false)
+ File.should_receive(:readable?).with(fake_red_theme_dir + "/about.markdown").and_return(true)
+ Theme.search_theme_directory.should eq %w{ fake_blue_theme_dir fake_red_theme_dir }
+ end
end
- it 'find_all finds all the installed themes' do
- Theme.find_all.size.should ==
+ describe '.find_all' do
+ let(:theme_directories) do
Dir.glob(::Rails.root.to_s + '/themes/[a-zA-Z0-9]*').select do |file|
File.readable? "#{file}/about.markdown"
- end.size
+ end
+ end
+
+ it 'finds all the installed themes' do
+ Theme.find_all.size.should eq theme_directories.size
+ end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.