]> git.openstreetmap.org Git - rails.git/commitdiff
Use a param to trigger export rather than a separate action
authorJohn Firebaugh <john.firebaugh@gmail.com>
Fri, 7 Sep 2012 08:26:44 +0000 (09:26 +0100)
committerTom Hughes <tom@compton.nu>
Fri, 7 Sep 2012 08:27:59 +0000 (09:27 +0100)
In site/_resize.html.erb and site/_search.html.erb, a
params[:action] conditional is used to include code that
should only run on the index action -- but it should be run
on the export action too. Cleanest fix is to eliminate that
action entirely.

app/controllers/site_controller.rb
app/views/site/index.html.erb
config/routes.rb
test/functional/site_controller_test.rb

index fa33deeeeead9b95cca0368de32886529bf557ff..356af9879e029d5cf80083b47699fc8333fb93f5 100644 (file)
@@ -6,10 +6,6 @@ class SiteController < ApplicationController
   before_filter :set_locale
   before_filter :require_user, :only => [:edit]
 
   before_filter :set_locale
   before_filter :require_user, :only => [:edit]
 
-  def export
-    render :action => 'index'
-  end
-
   def permalink
     lon, lat, zoom = ShortLink::decode(params[:code])
     new_params = params.clone
   def permalink
     lon, lat, zoom = ShortLink::decode(params[:code])
     new_params = params.clone
index 877bc177190a471cd747a52ceb4c21031783b274..4e725f90679efc680e1bbaabe112aa52595f4de8 100644 (file)
@@ -291,7 +291,7 @@ end
       e.preventDefault();
     });
 
       e.preventDefault();
     });
 
-    <% if params[:action] == 'export' -%>
+    <% if params[:export] -%>
     $("#exportanchor").click();
     <% end -%>
 
     $("#exportanchor").click();
     <% end -%>
 
index 955c5706f924677588d225e5cc7c8b90674f3b79..b84d27243f3f31750f5511ba0941e0276f9a4c86 100644 (file)
@@ -102,7 +102,7 @@ OpenStreetMap::Application.routes.draw do
   match '/copyright' => 'site#copyright', :via => :get
   match '/history' => 'changeset#list', :via => :get
   match '/history/feed' => 'changeset#feed', :via => :get, :format => :atom
   match '/copyright' => 'site#copyright', :via => :get
   match '/history' => 'changeset#list', :via => :get
   match '/history/feed' => 'changeset#feed', :via => :get, :format => :atom
-  match '/export' => 'site#export', :via => :get
+  match '/export' => 'site#index', :export => true, :via => :get
   match '/login' => 'user#login', :via => [:get, :post]
   match '/logout' => 'user#logout', :via => [:get, :post]
   match '/offline' => 'site#offline', :via => :get
   match '/login' => 'user#login', :via => [:get, :post]
   match '/logout' => 'user#logout', :via => [:get, :post]
   match '/offline' => 'site#offline', :via => :get
index 55dff2d96563a5ad25b1c7733a549669f2f1f4fe..67d020b74443d0adceecd485b81a3a9b3af2ca30 100644 (file)
@@ -36,10 +36,10 @@ class SiteControllerTest < ActionController::TestCase
     )
     assert_routing(
       { :path => "/export", :method => :get },
     )
     assert_routing(
       { :path => "/export", :method => :get },
-      { :controller => "site", :action => "export" }
+      { :controller => "site", :action => "index", :export => true }
     )
     assert_recognizes(
     )
     assert_recognizes(
-      { :controller => "site", :action => "export", :format => "html" },
+      { :controller => "site", :action => "index", :export => true, :format => "html" },
       { :path => "/export.html", :method => :get }
     )
     assert_routing(
       { :path => "/export.html", :method => :get }
     )
     assert_routing(
@@ -76,14 +76,6 @@ class SiteControllerTest < ActionController::TestCase
     assert_redirected_to :controller => :user, :action => 'login', :referer => "/edit"
   end
   
     assert_redirected_to :controller => :user, :action => 'login', :referer => "/edit"
   end
   
-  # Get the export page
-  def test_export
-    get :export
-    assert_response :success
-    assert_template 'index'
-    assert_site_partials
-  end
-  
   # Offline page
   def test_offline
     get :offline
   # Offline page
   def test_offline
     get :offline