Skip to content
This repository has been archived by the owner on Aug 10, 2020. It is now read-only.

Commit

Permalink
Make javascript_helpers mandatory
Browse files Browse the repository at this point in the history
  • Loading branch information
Duarte Henriques committed Oct 8, 2012
1 parent 050e513 commit c2e5ad1
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 25 deletions.
4 changes: 0 additions & 4 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,6 @@ You call these analytical commands like this:

When you call these commands, it will pass the track/event name & data on to each of the modules. (Take a look at the simple javascript helpers in your <head> for more information.)

To disable this functionality, use

analytical :javascript_helpers => false


== Note on Patches/Pull Requests

Expand Down
12 changes: 5 additions & 7 deletions lib/analytical/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,11 @@ def head_append_javascript
tracking_javascript(:head_append),
]

if options[:javascript_helpers]
if Gem::Version.new(::Rails::VERSION::STRING) >= Gem::Version.new('3.1.0') # Rails 3.1 lets us override views in engines
js << options[:controller].send(:render_to_string, :partial=>'analytical_javascript') if options[:controller]
else # All other rails
_partial_path = Pathname.new(__FILE__).dirname.join('..', '..', 'app/views/application', '_analytical_javascript.html.erb').to_s
js << options[:controller].send(:render_to_string, :file=>_partial_path, :layout=>false) if options[:controller]
end
if Gem::Version.new(::Rails::VERSION::STRING) >= Gem::Version.new('3.1.0') # Rails 3.1 lets us override views in engines
js << options[:controller].send(:render_to_string, :partial=>'analytical_javascript') if options[:controller]
else # All other rails
_partial_path = Pathname.new(__FILE__).dirname.join('..', '..', 'app/views/application', '_analytical_javascript.html.erb').to_s
js << options[:controller].send(:render_to_string, :file=>_partial_path, :layout=>false) if options[:controller]
end

js.delete_if{|s| s.blank?}.join("\n")
Expand Down
6 changes: 0 additions & 6 deletions spec/analytical/api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,9 @@
@api.head_append_javascript.should == "console_agoogle_a"
end
it 'should render an existing template for Rails 3.0' do
@api.options[:javascript_helpers] = true
(@api.options[:controller] ||= Object.new).stub!(:render_to_string) { |param| param[:file] }
File.exist?(@api.head_append_javascript).should be_true
end
it 'should not render an existing template if javascript_helpers is false' do
@api.options[:javascript_helpers] = false
(@api.options[:controller] ||= Object.new).should_not_receive(:render_to_string)
@api.head_append_javascript.should be_blank
end
end

describe '#body_prepend_javascript' do
Expand Down
7 changes: 0 additions & 7 deletions spec/analytical_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,6 @@ def request
d.options[:string_option].should == "string"
end

it 'should preserve :javascript_helpers option' do
options = { :javascript_helpers => false, :modules => [] }
DummyForInit.analytical options
a = DummyForInit.new.analytical
a.options[:javascript_helpers].should be_false
end

it 'should use the supplied options' do
DummyForInit.analytical :modules=>[:google]
d = DummyForInit.new.analytical
Expand Down
1 change: 0 additions & 1 deletion spec/config/analytical.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
test:
javascript_helpers: true
false_option: false
true_option: true
string_option: "string"
Expand Down

0 comments on commit c2e5ad1

Please sign in to comment.