1 # frozen_string_literal: true
 
   5 class ExportControllerTest < ActionDispatch::IntegrationTest
 
   7   # test all routes which lead to this controller
 
  10       { :path => "/export/finish", :method => :post },
 
  11       { :controller => "export", :action => "finish" }
 
  14       { :path => "/export/embed", :method => :get },
 
  15       { :controller => "export", :action => "embed" }
 
  20   # test the finish action for raw OSM data
 
  22     post export_finish_path(:minlon => 0, :minlat => 50, :maxlon => 1, :maxlat => 51, :format => "osm")
 
  23     assert_redirected_to api_map_path(:bbox => "0.0,50.0,1.0,51.0")
 
  27   # test the finish action for mapnik images
 
  28   def test_finish_mapnik
 
  29     post export_finish_path(:minlon => 0, :minlat => 50, :maxlon => 1, :maxlat => 51, :format => "mapnik", :mapnik_format => "test", :mapnik_scale => "12")
 
  30     assert_redirected_to "https://render.openstreetmap.org/cgi-bin/export?bbox=0.0,50.0,1.0,51.0&scale=12&format=test&token="
 
  34   # test the finish action for cyclemap images
 
  35   def test_finish_cyclemap
 
  36     post export_finish_path(:minlon => 0, :minlat => 50, :maxlon => 1, :maxlat => 51, :format => "cyclemap", :mapnik_scale => 12, :mapnik_format => "png", :zoom => 17, :lat => 1, :lon => 2, :width => 400, :height => 300)
 
  37     assert_redirected_to "https://tile.thunderforest.com/static/cycle/2,1,17/400x300.png?apikey=#{Settings.thunderforest_key}"
 
  41   # test the finish action for transport images
 
  42   def test_finish_transport
 
  43     post export_finish_path(:minlon => 0, :minlat => 50, :maxlon => 1, :maxlat => 51, :format => "transportmap", :mapnik_scale => 12, :mapnik_format => "png", :zoom => 17, :lat => 1, :lon => 2, :width => 400, :height => 300)
 
  44     assert_redirected_to "https://tile.thunderforest.com/static/transport/2,1,17/400x300.png?apikey=#{Settings.thunderforest_key}"
 
  48   # test the embed action
 
  51     assert_response :success
 
  52     assert_template "export/embed"