Skip to content

Commit

Permalink
Clean spec around default layout view
Browse files Browse the repository at this point in the history
  • Loading branch information
Yannick Francois committed Sep 26, 2013
1 parent 618426e commit 9022318
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 31 deletions.
6 changes: 1 addition & 5 deletions app/helpers/application_helper.rb
Expand Up @@ -95,7 +95,7 @@ def display_user_avatar(user, size='avatar', klass='alignleft')
elsif user.twitter_profile_image.present?
avatar = user.twitter_profile_image.present?
end

return unless avatar
image_tag(File.join(this_blog.base_url, avatar), :alt => user.nickname, :class => klass)
end
Expand Down Expand Up @@ -131,10 +131,6 @@ def use_canonical
"<link rel='canonical' href='#{this_blog.base_url + request.fullpath}' />".html_safe
end

def page_header
render 'shared/page_header'
end

def page_header_includes
content_array.collect { |c| c.whiteboard }.collect do |w|
w.select {|k,v| k =~ /^page_header_/}.collect do |_,v|
Expand Down
2 changes: 1 addition & 1 deletion app/views/shared/_page_header.html.erb
@@ -1,5 +1,5 @@
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<%= meta_tag 'ICBM', this_blog.geourl_location unless this_blog.geourl_location.blank? %>
<%= meta_tag 'ICBM', this_blog.geourl_location if this_blog.geourl_location.present? %>
<%= meta_tag 'description', @description unless @description.blank? %>
<%= meta_tag 'robots', 'noindex, follow' if stop_index_robots? %>
<%= meta_tag 'google-site-verification', this_blog.google_verification unless this_blog.google_verification.blank?%>
Expand Down
33 changes: 10 additions & 23 deletions spec/views/layouts/default_spec.rb
@@ -1,41 +1,28 @@
require 'spec_helper'

describe "layouts/default.html.erb" do
before do
assign(:keywords, ["foo", "bar"])
assign(:auto_discovery_url_atom, "")
assign(:auto_discovery_url_rss, "")
end

with_each_theme do |theme, view_path|
# FIXME: Add default.html.erb in base view dir.
next unless theme

describe theme ? "with theme #{theme}" : "without a theme" do
before do
before(:each) do
assign(:keywords, ["foo", "bar"])
assign(:auto_discovery_url_atom, "")
assign(:auto_discovery_url_rss, "")
@controller.view_paths.unshift(view_path) if theme
end

context "when use_meta_keyword set to true" do
before do
@blog = FactoryGirl.create(:blog, :use_meta_keyword => true)
end

it 'renders assigned keywords' do
render
rendered.should have_selector('head>meta[name="keywords"]')
end
let!(:blog) { create(:blog, use_meta_keyword: true) }
before(:each) {render}
it { expect(rendered).to have_selector('head>meta[name="keywords"]') }
end

context "when use_meta_keyword set to false" do
before do
@blog = FactoryGirl.create(:blog, :use_meta_keyword => false)
end

it 'does not render assigned keywords' do
render
rendered.should_not have_selector('head>meta[name="keywords"]')
end
let!(:blog) { create(:blog, use_meta_keyword: false) }
before(:each) {render}
it { expect(rendered).to_not have_selector('head>meta[name="keywords"]') }
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion themes/bootstrap/views/layouts/default.html.erb
Expand Up @@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><%= h(page_title) %></title>
<%= stylesheet_link_tag "/stylesheets/theme/bootstrap.min.css", "/stylesheets/theme/style.css", :media => 'all' %>
<%= page_header %>
<%= render 'shared/page_header' %>
<style type="text/css">
#logo { background: url(<%= File.join(this_blog.base_url, "images", "theme", "bg#{Random.rand(2) + 1}.jpg") %>) top left no-repeat; }
</style>
Expand Down
2 changes: 1 addition & 1 deletion themes/typographic/views/layouts/default.html.erb
@@ -1,7 +1,7 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<%= page_header %>
<%= render 'shared/page_header' %>
<title><%=h page_title %></title>
<%= stylesheet_link_tag '/stylesheets/theme/style.css', :media => 'all' %>
<!--[if IE 6]>
Expand Down

0 comments on commit 9022318

Please sign in to comment.