From: John Firebaugh Date: Fri, 7 Sep 2012 08:26:44 +0000 (+0100) Subject: Use a param to trigger export rather than a separate action X-Git-Tag: live~5352 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/8ec415b060c4321fad3fa42f3038148aa94c9b90?hp=6358f8190d3952a3d7664e5db774ceaae5ce0447 Use a param to trigger export rather than a separate action 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. --- diff --git a/app/controllers/site_controller.rb b/app/controllers/site_controller.rb index fa33deeee..356af9879 100644 --- a/app/controllers/site_controller.rb +++ b/app/controllers/site_controller.rb @@ -6,10 +6,6 @@ class SiteController < ApplicationController 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 diff --git a/app/views/site/index.html.erb b/app/views/site/index.html.erb index 877bc1771..4e725f906 100644 --- a/app/views/site/index.html.erb +++ b/app/views/site/index.html.erb @@ -291,7 +291,7 @@ end e.preventDefault(); }); - <% if params[:action] == 'export' -%> + <% if params[:export] -%> $("#exportanchor").click(); <% end -%> diff --git a/config/routes.rb b/config/routes.rb index 955c5706f..b84d27243 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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 '/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 diff --git a/test/functional/site_controller_test.rb b/test/functional/site_controller_test.rb index 55dff2d96..67d020b74 100644 --- a/test/functional/site_controller_test.rb +++ b/test/functional/site_controller_test.rb @@ -36,10 +36,10 @@ class SiteControllerTest < ActionController::TestCase ) assert_routing( { :path => "/export", :method => :get }, - { :controller => "site", :action => "export" } + { :controller => "site", :action => "index", :export => true } ) assert_recognizes( - { :controller => "site", :action => "export", :format => "html" }, + { :controller => "site", :action => "index", :export => true, :format => "html" }, { :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 - # 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