From e964669932b912cc9daa30658c4a04d415da1d29 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Thu, 6 Sep 2012 16:00:06 -0700 Subject: [PATCH] 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. --- app/controllers/site_controller.rb | 4 ---- app/views/layouts/site.html.erb | 2 +- app/views/site/index.html.erb | 2 +- config/routes.rb | 1 - test/functional/site_controller_test.rb | 16 ---------------- 5 files changed, 2 insertions(+), 23 deletions(-) diff --git a/app/controllers/site_controller.rb b/app/controllers/site_controller.rb index fa33deeeee..356af9879e 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/layouts/site.html.erb b/app/views/layouts/site.html.erb index 9346b56702..da27a35c05 100644 --- a/app/views/layouts/site.html.erb +++ b/app/views/layouts/site.html.erb @@ -41,7 +41,7 @@ :title => t('javascripts.site.history_tooltip'), :class => 'geolink bbox' } %> -
  • <%= link_to t('layouts.export'), export_path, { +
  • <%= link_to t('layouts.export'), root_path(:export => true), { :id => 'exportanchor', :title => t('layouts.export_tooltip'), :class => 'geolink llz layers' diff --git a/app/views/site/index.html.erb b/app/views/site/index.html.erb index 877bc17719..4e725f9067 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 955c5706f9..c524ecd8c1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -102,7 +102,6 @@ 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 '/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 55dff2d965..a29726f002 100644 --- a/test/functional/site_controller_test.rb +++ b/test/functional/site_controller_test.rb @@ -34,14 +34,6 @@ def test_routes { :path => "/copyright/locale", :method => :get }, { :controller => "site", :action => "copyright", :copyright_locale => "locale" } ) - assert_routing( - { :path => "/export", :method => :get }, - { :controller => "site", :action => "export" } - ) - assert_recognizes( - { :controller => "site", :action => "export", :format => "html" }, - { :path => "/export.html", :method => :get } - ) assert_routing( { :path => "/offline", :method => :get }, { :controller => "site", :action => "offline" } @@ -76,14 +68,6 @@ def test_edit 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