Skip to content

Commit

Permalink
Only geocode for rspec contexts where geocoding: true
Browse files Browse the repository at this point in the history
Ameliorates #59

Also don't link IDL script in test env
  • Loading branch information
Gabe Kopley committed Sep 10, 2014
1 parent f8beea5 commit 446b71a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
5 changes: 3 additions & 2 deletions app/views/layouts/application.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@
= render :partial => "devise/login_modal"

=yield :scripts
:javascript
window._idl={};_idl.variant="banner";(function(){var e=document.createElement("script");e.type="text/javascript";e.async=true;e.src=("https:"==document.location.protocol?"https://":"http://")+"members.internetdefenseleague.org/include/?url="+(_idl.url||"")+"&campaign="+(_idl.campaign||"")+"&variant="+(_idl.variant||"banner");document.getElementsByTagName("body")[0].appendChild(e)})()
- unless Rails.env.test?
:javascript
window._idl={};_idl.variant="banner";(function(){var e=document.createElement("script");e.type="text/javascript";e.async=true;e.src=("https:"==document.location.protocol?"https://":"http://")+"members.internetdefenseleague.org/include/?url="+(_idl.url||"")+"&campaign="+(_idl.campaign||"")+"&variant="+(_idl.variant||"banner");document.getElementsByTagName("body")[0].appendChild(e)})()
2 changes: 1 addition & 1 deletion spec/controllers/application_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def nyc_location

mock_location
end
describe "current_school" do
describe "current_school with geocoding on", geocode: true do

it "defaults to school for the nearest venue" do
school1 = create(:school)
Expand Down
9 changes: 9 additions & 0 deletions spec/support/gmaps4rails.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
RSpec.configure do |config|
config.before(:each) do |example|
unless self.class.metadata[:geocode] == true
Gmaps4rails::ModelHandler.any_instance.stub(:prevent_geocoding?) do
true
end
end
end
end

0 comments on commit 446b71a

Please sign in to comment.