Skip to content
This repository has been archived by the owner on Apr 26, 2022. It is now read-only.

Commit

Permalink
fix js breakage in some browsers due to console.log call failures
Browse files Browse the repository at this point in the history
- use html5boilerplate's plugins.js

fix sporadically passing specs
  • Loading branch information
Jeremiah Heller committed May 9, 2012
1 parent a65cc72 commit 18aba14
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 9 deletions.
15 changes: 8 additions & 7 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module ApplicationHelper
include CkeditorHelper

def top_menu
@top_menu ? @top_menu.body_for_display : "TODO: create the top menu"
end
Expand All @@ -27,7 +27,7 @@ def search_box(options = {})
def site_title
@site_title ||= SiteSetting.read_setting('site title') || "A Site [edit me in site settings]"
end

def blog_title
@blog_title ||= SiteSetting.read_setting('blog title') || "Blog [edit me in site settings]"
end
Expand Down Expand Up @@ -93,7 +93,7 @@ def site_footer
end

def user_box(my_options={})
options = { :include_line_breaks => true, :include_blog_link => true,
options = { :include_line_breaks => true, :include_blog_link => true,
:include_events_link => true, :include_wiki_link => true,
:include_forum_link => true,
:link_separator => ' | '
Expand All @@ -103,7 +103,7 @@ def user_box(my_options={})
if current_user
out += "Welcome, #{current_user.first_name}! "
if(options[:include_line_breaks])
out += "<br />"
out += "<br />"
end
out += link_to("My Account", account_path) + options[:link_separator].html_safe +
link_to("Logout", user_session_path, :method => :delete,
Expand Down Expand Up @@ -135,7 +135,7 @@ def user_box(my_options={})
end
unless other_links.empty?
if(options[:include_line_breaks])
out += "<br/>"
out += "<br/>"
else
out += options[:link_separator]
end
Expand Down Expand Up @@ -197,14 +197,15 @@ def uniq_filenames(file_paths_or_names)
end
def javascripts
uniq_filenames(
host_javascripts +
host_javascripts +
behaviors +
['app.js']
)
end
def host_javascripts
list = [
'rails', 'lowpro.jquery.js',
'h5bp-plugins',
'rails', 'lowpro.jquery.js',
'jquery.string.1.0-min.js',
'jquery.clonePosition.js',
'jquery.qtip-1.0.0-rc3.js',
Expand Down
11 changes: 11 additions & 0 deletions public/javascripts/h5bp-plugins.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// usage: log('inside coolFunc', this, arguments);
// paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/
window.log = function f(){ log.history = log.history || []; log.history.push(arguments); if(this.console) { var args = arguments, newarr; args.callee = args.callee.caller; newarr = [].slice.call(args); if (typeof console.log === 'object') log.apply.call(console.log, console, newarr); else console.log.apply(console, newarr);}};

// make it safe to use console.log always
(function(a){function b(){}for(var c="assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,markTimeline,profile,profileEnd,time,timeEnd,trace,warn".split(","),d;!!(d=c.pop());){a[d]=a[d]||b;}})
(function(){try{console.log();return window.console;}catch(a){return (window.console={});}}());


// place any jQuery/helper plugins in here, instead of separate, slower script files.

4 changes: 2 additions & 2 deletions spec/models/file_attachment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ class Event; extend ActiveModel::Naming; def self.base_class; Event; end end
end

it "should know whether its file actually exists" do
File.stub(:exists?).with("#{@path}/somefile.txt"){ true }
File.stub(:exists?).with(@file_attachment.full_path){ true }
@file_attachment.file_saved?.should be_true
File.stub(:exists?).with("#{@path}/somefile.txt"){ false }
File.stub(:exists?).with(@file_attachment.full_path){ false }
@file_attachment.file_saved?.should be_false
end

Expand Down
1 change: 1 addition & 0 deletions spec/models/site_setting_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

describe SiteSetting do
before(:each) do
Rails.cache.clear
@valid_attributes = {
:setting_name => "value for setting_name",
:setting_string_value => "value for setting_string_value",
Expand Down

0 comments on commit 18aba14

Please sign in to comment.