Rework application configuration

Use a preinitializer to load the settings from application.yml so
that they are available as early as possible. All settings can also
be overridden using environment variables.

The ad-hoc settins in environment.rb are then moved to this new
system so we have one consistent location for settings.
This commit is contained in:
Tom Hughes 2010-08-04 22:06:05 +01:00
parent 8b9cacd3c2
commit f07819d81a
33 changed files with 100 additions and 99 deletions

View file

@ -172,7 +172,7 @@ class AmfController < ApplicationController
def amf_handle_error_with_timeout(call,rootobj,rootid)
amf_handle_error(call,rootobj,rootid) do
Timeout::timeout(APP_CONFIG['api_timeout'], OSM::APITimeoutError) do
Timeout::timeout(API_TIMEOUT, OSM::APITimeoutError) do
yield
end
end

View file

@ -18,7 +18,7 @@ class ApiController < ApplicationController
return
end
offset = page * APP_CONFIG['tracepoints_per_page']
offset = page * TRACEPOINTS_PER_PAGE
# Figure out the bbox
bbox = params['bbox']
@ -39,7 +39,7 @@ class ApiController < ApplicationController
end
# get all the points
points = Tracepoint.find_by_area(min_lat, min_lon, max_lat, max_lon, :offset => offset, :limit => APP_CONFIG['tracepoints_per_page'], :order => "gpx_id DESC, trackid ASC, timestamp ASC" )
points = Tracepoint.find_by_area(min_lat, min_lon, max_lat, max_lon, :offset => offset, :limit => TRACEPOINTS_PER_PAGE, :order => "gpx_id DESC, trackid ASC, timestamp ASC" )
doc = XML::Document.new
doc.encoding = XML::Encoding::UTF_8
@ -145,14 +145,14 @@ class ApiController < ApplicationController
end
# FIXME um why is this area using a different order for the lat/lon from above???
@nodes = Node.find_by_area(min_lat, min_lon, max_lat, max_lon, :conditions => {:visible => true}, :include => :node_tags, :limit => APP_CONFIG['max_number_of_nodes']+1)
@nodes = Node.find_by_area(min_lat, min_lon, max_lat, max_lon, :conditions => {:visible => true}, :include => :node_tags, :limit => MAX_NUMBER_OF_NODES+1)
# get all the nodes, by tag not yet working, waiting for change from NickB
# need to be @nodes (instance var) so tests in /spec can be performed
#@nodes = Node.search(bbox, params[:tag])
node_ids = @nodes.collect(&:id)
if node_ids.length > APP_CONFIG['max_number_of_nodes']
report_error("You requested too many nodes (limit is #{APP_CONFIG['max_number_of_nodes']}). Either request a smaller area, or use planet.osm")
if node_ids.length > MAX_NUMBER_OF_NODES
report_error("You requested too many nodes (limit is #{MAX_NUMBER_OF_NODES}). Either request a smaller area, or use planet.osm")
return
end
if node_ids.length == 0
@ -295,19 +295,19 @@ class ApiController < ApplicationController
version['maximum'] = "#{API_VERSION}";
api << version
area = XML::Node.new 'area'
area['maximum'] = APP_CONFIG['max_request_area'].to_s;
area['maximum'] = MAX_REQUEST_AREA.to_s;
api << area
tracepoints = XML::Node.new 'tracepoints'
tracepoints['per_page'] = APP_CONFIG['tracepoints_per_page'].to_s
tracepoints['per_page'] = TRACEPOINTS_PER_PAGE.to_s
api << tracepoints
waynodes = XML::Node.new 'waynodes'
waynodes['maximum'] = APP_CONFIG['max_number_of_way_nodes'].to_s
waynodes['maximum'] = MAX_NUMBER_OF_WAY_NODES.to_s
api << waynodes
changesets = XML::Node.new 'changesets'
changesets['maximum_elements'] = Changeset::MAX_ELEMENTS.to_s
api << changesets
timeout = XML::Node.new 'timeout'
timeout['seconds'] = APP_CONFIG['api_timeout'].to_s
timeout['seconds'] = API_TIMEOUT.to_s
api << timeout
doc.root << api

View file

@ -2,7 +2,7 @@
# Likewise, all the methods added will be available for all controllers.
class ApplicationController < ActionController::Base
if OSM_STATUS == :database_readonly or OSM_STATUS == :database_offline
if STATUS == :database_readonly or STATUS == :database_offline
session :off
end
@ -120,20 +120,20 @@ class ApplicationController < ActionController::Base
end
def check_database_readable(need_api = false)
if OSM_STATUS == :database_offline or (need_api and OSM_STATUS == :api_offline)
if STATUS == :database_offline or (need_api and STATUS == :api_offline)
redirect_to :controller => 'site', :action => 'offline'
end
end
def check_database_writable(need_api = false)
if OSM_STATUS == :database_offline or OSM_STATUS == :database_readonly or
(need_api and (OSM_STATUS == :api_offline or OSM_STATUS == :api_readonly))
if STATUS == :database_offline or STATUS == :database_readonly or
(need_api and (STATUS == :api_offline or STATUS == :api_readonly))
redirect_to :controller => 'site', :action => 'offline'
end
end
def check_api_readable
if OSM_STATUS == :database_offline or OSM_STATUS == :api_offline
if STATUS == :database_offline or STATUS == :api_offline
response.headers['Error'] = "Database offline for maintenance"
render :nothing => true, :status => :service_unavailable
return false
@ -141,8 +141,8 @@ class ApplicationController < ActionController::Base
end
def check_api_writable
if OSM_STATUS == :database_offline or OSM_STATUS == :database_readonly or
OSM_STATUS == :api_offline or OSM_STATUS == :api_readonly
if STATUS == :database_offline or STATUS == :database_readonly or
STATUS == :api_offline or STATUS == :api_readonly
response.headers['Error'] = "Database offline for maintenance"
render :nothing => true, :status => :service_unavailable
return false
@ -219,7 +219,7 @@ class ApplicationController < ActionController::Base
##
# wrap an api call in a timeout
def api_call_timeout
SystemTimer.timeout_after(APP_CONFIG['api_timeout']) do
SystemTimer.timeout_after(API_TIMEOUT) do
yield
end
rescue Timeout::Error
@ -229,7 +229,7 @@ class ApplicationController < ActionController::Base
##
# wrap a web page in a timeout
def web_timeout
SystemTimer.timeout_after(APP_CONFIG['web_timeout']) do
SystemTimer.timeout_after(WEB_TIMEOUT) do
yield
end
rescue ActionView::TemplateError => ex

View file

@ -10,7 +10,7 @@ class DiaryEntryController < ApplicationController
caches_action :list, :view, :layout => false
caches_action :rss, :layout => true
cache_sweeper :diary_sweeper, :only => [:new, :edit, :comment, :hide, :hidecomment], :unless => OSM_STATUS == :database_offline
cache_sweeper :diary_sweeper, :only => [:new, :edit, :comment, :hide, :hidecomment], :unless => STATUS == :database_offline
def new
@title = t 'diary_entry.new.title'

View file

@ -57,7 +57,7 @@ class GeocoderController < ApplicationController
render :action => "error"
else
@results.push({:lat => lat, :lon => lon,
:zoom => APP_CONFIG['postcode_zoom'],
:zoom => POSTCODE_ZOOM,
:name => "#{lat}, #{lon}"})
render :action => "results"
@ -78,7 +78,7 @@ class GeocoderController < ApplicationController
unless response.match(/couldn't find this zip/)
data = response.split(/\s*,\s+/) # lat,long,town,state,zip
@results.push({:lat => data[0], :lon => data[1],
:zoom => APP_CONFIG['postcode_zoom'],
:zoom => POSTCODE_ZOOM,
:prefix => "#{data[2]}, #{data[3]},",
:name => data[4]})
end
@ -104,7 +104,7 @@ class GeocoderController < ApplicationController
dataline = response.split(/\n/)[1]
data = dataline.split(/,/) # easting,northing,postcode,lat,long
postcode = data[2].gsub(/'/, "")
zoom = APP_CONFIG['postcode_zoom'] - postcode.count("#")
zoom = POSTCODE_ZOOM - postcode.count("#")
@results.push({:lat => data[3], :lon => data[4], :zoom => zoom,
:name => postcode})
end
@ -127,7 +127,7 @@ class GeocoderController < ApplicationController
if response.get_elements("geodata/error").empty?
@results.push({:lat => response.get_text("geodata/latt").to_s,
:lon => response.get_text("geodata/longt").to_s,
:zoom => APP_CONFIG['postcode_zoom'],
:zoom => POSTCODE_ZOOM,
:name => query.upcase})
end
@ -286,7 +286,7 @@ class GeocoderController < ApplicationController
name = geoname.get_text("name").to_s
country = geoname.get_text("countryName").to_s
@results.push({:lat => lat, :lon => lon,
:zoom => APP_CONFIG['geonames_zoom'],
:zoom => GEONAMES_ZOOM,
:name => name,
:suffix => ", #{country}"})
end

View file

@ -15,7 +15,7 @@ class MessageController < ApplicationController
@to_user = User.find_by_display_name(params[:display_name])
if @to_user
if params[:message]
if @user.sent_messages.count(:conditions => ["sent_on >= ?", Time.now.getutc - 1.hour]) >= APP_CONFIG['max_messages_per_hour']
if @user.sent_messages.count(:conditions => ["sent_on >= ?", Time.now.getutc - 1.hour]) >= MAX_MESSAGES_PER_HOUR
flash[:error] = t 'message.new.limit_exceeded'
else
@message = Message.new(params[:message])

View file

@ -17,8 +17,8 @@ class TraceController < ApplicationController
caches_action :list, :view, :layout => false
caches_action :georss, :layout => true
cache_sweeper :trace_sweeper, :only => [:create, :edit, :delete, :api_create], :unless => OSM_STATUS == :database_offline
cache_sweeper :tracetag_sweeper, :only => [:create, :edit, :delete, :api_create], :unless => OSM_STATUS == :database_offline
cache_sweeper :trace_sweeper, :only => [:create, :edit, :delete, :api_create], :unless => STATUS == :database_offline
cache_sweeper :tracetag_sweeper, :only => [:create, :edit, :delete, :api_create], :unless => STATUS == :database_offline
# Counts and selects pages of GPX traces for various criteria (by user, tags, public etc.).
# target_user - if set, specifies the user to fetch traces for. if not set will fetch all traces
@ -395,11 +395,11 @@ private
end
def offline_warning
flash.now[:warning] = t 'trace.offline_warning.message' if OSM_STATUS == :gpx_offline
flash.now[:warning] = t 'trace.offline_warning.message' if STATUS == :gpx_offline
end
def offline_redirect
redirect_to :action => :offline if OSM_STATUS == :gpx_offline
redirect_to :action => :offline if STATUS == :gpx_offline
end
def default_visibility

View file

@ -16,13 +16,13 @@ class UserController < ApplicationController
filter_parameter_logging :password, :pass_crypt, :pass_crypt_confirmation
cache_sweeper :user_sweeper, :only => [:account, :set_status, :delete], :unless => OSM_STATUS == :database_offline
cache_sweeper :user_sweeper, :only => [:account, :set_status, :delete], :unless => STATUS == :database_offline
def terms
@title = t 'user.new.title'
@user = User.new(params[:user])
@legale = params[:legale] || OSM.IPToCountry(request.remote_ip) || APP_CONFIG['default_legale']
@legale = params[:legale] || OSM.IPToCountry(request.remote_ip) || DEFAULT_LEGALE
@text = OSM.legal_text_for_country(@legale)
if request.xhr?

View file

@ -58,7 +58,7 @@ class Node < ActiveRecord::Base
find_by_area(min_lat, min_lon, max_lat, max_lon,
:conditions => {:visible => true},
:limit => APP_CONFIG['max_number_of_nodes']+1)
:limit => MAX_NUMBER_OF_NODES+1)
end
# Read in xml as text and return it's Node object representation

View file

@ -105,7 +105,7 @@ private
end
def from_header(name, type, id, digest)
if domain = APP_CONFIG['messages_domain']
if domain = MESSAGES_DOMAIN
from quote_address_if_necessary("#{name} <#{type}-#{id}-#{digest[0,6]}@#{domain}>", "utf-8")
end
end

View file

@ -8,7 +8,7 @@ class SpamObserver < ActiveRecord::Observer
when record.is_a?(DiaryComment): user = record.user
end
if user.status == "active" and user.spam_score > APP_CONFIG['spam_threshold']
if user.status == "active" and user.spam_score > SPAM_THRESHOLD
user.update_attributes(:status => "suspended")
end
end

View file

@ -5,7 +5,7 @@ class UserBlock < ActiveRecord::Base
belongs_to :creator, :class_name => "User", :foreign_key => :creator_id
belongs_to :revoker, :class_name => "User", :foreign_key => :revoker_id
PERIODS = APP_CONFIG['user_block_periods']
PERIODS = USER_BLOCK_PERIODS
##
# returns true if the block is currently active (i.e: the user can't

View file

@ -234,8 +234,8 @@ class Way < ActiveRecord::Base
def preconditions_ok?(old_nodes = [])
return false if self.nds.empty?
if self.nds.length > APP_CONFIG['max_number_of_way_nodes']
raise OSM::APITooManyWayNodesError.new(self.id, self.nds.length, APP_CONFIG['max_number_of_way_nodes'])
if self.nds.length > MAX_NUMBER_OF_WAY_NODES
raise OSM::APITooManyWayNodesError.new(self.id, self.nds.length, MAX_NUMBER_OF_WAY_NODES)
end
# check only the new nodes, for efficiency - old nodes having been checked last time and can't

View file

@ -185,8 +185,8 @@ page << <<EOJ
var projected = bounds.clone().transform(new OpenLayers.Projection("EPSG:900913"), new OpenLayers.Projection("EPSG:4326"));
var size = projected.getWidth() * projected.getHeight();
if (size > #{APP_CONFIG['max_request_area']}) {
setStatus(i18n("#{I18n.t('browse.start_rjs.unable_to_load_size', :max_bbox_size => APP_CONFIG['max_request_area'])}", { bbox_size: size }));
if (size > #{MAX_REQUEST_AREA}) {
setStatus(i18n("#{I18n.t('browse.start_rjs.unable_to_load_size', :max_bbox_size => MAX_REQUEST_AREA)}", { bbox_size: size }));
} else {
loadGML("/api/#{API_VERSION}/map?bbox=" + projected.toBBOX());
}

View file

@ -190,7 +190,7 @@ page << <<EOJ
function validateControls() {
var bounds = new OpenLayers.Bounds($("minlon").value, $("minlat").value, $("maxlon").value, $("maxlat").value);
if (bounds.getWidth() * bounds.getHeight() > #{APP_CONFIG['max_request_area']}) {
if (bounds.getWidth() * bounds.getHeight() > #{MAX_REQUEST_AREA}) {
$("export_osm_too_large").style.display = "block";
} else {
$("export_osm_too_large").style.display = "none";
@ -198,7 +198,7 @@ page << <<EOJ
var max_scale = maxMapnikScale();
if ($("format_osm").checked && bounds.getWidth() * bounds.getHeight() > #{APP_CONFIG['max_request_area']}) {
if ($("format_osm").checked && bounds.getWidth() * bounds.getHeight() > #{MAX_REQUEST_AREA}) {
$("export_commit").disabled = true;
} else if ($("format_mapnik").checked && $("mapnik_scale").value < max_scale) {
$("export_commit").disabled = true;

View file

@ -100,11 +100,11 @@
</div>
<% end %>
<% if OSM_STATUS == :database_offline or OSM_STATUS == :api_offline %>
<% if STATUS == :database_offline or STATUS == :api_offline %>
<div id="alert">
<%= t 'layouts.osm_offline' %>
</div>
<% elsif OSM_STATUS == :database_readonly or OSM_STATUS == :api_readonly %>
<% elsif STATUS == :database_readonly or STATUS == :api_readonly %>
<div id="alert">
<%= t 'layouts.osm_read_only' %>
</div>

View file

@ -1,7 +1,7 @@
<% if OSM_STATUS == :database_offline or OSM_STATUS == :api_offline %>
<% if STATUS == :database_offline or STATUS == :api_offline %>
<p><%= t 'layouts.osm_offline' %>
</p>
<% elsif OSM_STATUS == :database_readonly or OSM_STATUS == :api_readonly %>
<% elsif STATUS == :database_readonly or STATUS == :api_readonly %>
<p><%= t 'layouts.osm_read_only' %>
</p>
<% elsif !@user.data_public? %>

View file

@ -125,7 +125,7 @@ end
function mapInit(){
map = createMap("map");
<% unless OSM_STATUS == :api_offline or OSM_STATUS == :database_offline %>
<% unless STATUS == :api_offline or STATUS == :database_offline %>
map.dataLayer = new OpenLayers.Layer("<%= I18n.t 'browse.start_rjs.data_layer_name' %>", { "visibility": false });
map.dataLayer.events.register("visibilitychanged", map.dataLayer, toggleData);
map.addLayer(map.dataLayer);

View file

@ -1,4 +1,4 @@
<% if OSM_STATUS == :database_offline %>
<% if STATUS == :database_offline %>
<p><%= t 'layouts.osm_offline' %>
</p>
<% else %>

View file

@ -1,7 +1,7 @@
<tr>
<% cl = cycle('table0', 'table1') %>
<td class="<%= cl %>">
<% if OSM_STATUS != :gpx_offline %>
<% if STATUS != :gpx_offline %>
<% if trace.inserted %>
<a href="<%= url_for :controller => 'trace', :action => 'view', :id => trace.id, :display_name => trace.user.display_name %>"><img src="<%= url_for :controller => 'trace', :action => 'icon', :id => trace.id, :display_name => trace.user.display_name %>" border="0" alt="" /></a>
<% else %>

View file

@ -1,6 +1,6 @@
<h2><%= t 'trace.view.heading', :name => h(@trace.name) %></h2>
<% if OSM_STATUS != :gpx_offline %>
<% if STATUS != :gpx_offline %>
<% if @trace.inserted %>
<img src="<%= url_for :controller => 'trace', :action => 'picture', :id => @trace.id, :display_name => @trace.user.display_name %>">
<% else %>

View file

@ -1,4 +1,21 @@
standard_settings: &standard_settings
# The server URL
server_url: "www.openstreetmap.org"
# The generator
generator: "OpenStreetMap server"
# Sender addresses for emails
email_from: "OpenStreetMap <webmaster@openstreetmap.org>"
email_return_path: "bounces@openstreetmap.org"
# API version
api_version: "0.6"
# Application status - posstible values are:
# :online - online and operating normally
# :api_readonly - site online but API in read-only mode
# :api_offline - site online but API offline
# :database_readonly - database and site in read-only mode
# :database_offline - database offline with site in emergency mode
# :gpx_offline - gpx storage offline
status: :online
# The maximum area you're allowed to request, in square degrees
max_request_area: 0.25
# Number of GPS trace/trackpoints returned per-page

View file

@ -1,36 +1,8 @@
# Be sure to restart your server when you modify this file
# Uncomment below to force Rails into production mode when
# you don't control web/app server and can't set it the proper way
ENV['RAILS_ENV'] ||= 'production'
# Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION = '2.3.8' unless defined? RAILS_GEM_VERSION
# Set the server URL
SERVER_URL = ENV['OSM_SERVER_URL'] || 'www.openstreetmap.org'
# Set the generator
GENERATOR = ENV['OSM_SERVER_GENERATOR'] || 'OpenStreetMap server'
# Settings for generated emails (e.g. signup confirmation
EMAIL_FROM = ENV['OSM_EMAIL_FROM'] || 'OpenStreetMap <webmaster@openstreetmap.org>'
EMAIL_RETURN_PATH = ENV['OSM_EMAIL_RETURN_PATH'] || 'bounces@openstreetmap.org'
# Application constants needed for routes.rb - must go before Initializer call
API_VERSION = ENV['OSM_API_VERSION'] || '0.6'
# Set application status - possible settings are:
#
# :online - online and operating normally
# :api_readonly - site online but API in read-only mode
# :api_offline - site online but API offline
# :database_readonly - database and site in read-only mode
# :database_offline - database offline with site in emergency mode
# :gpx_offline - gpx storage offline
#
OSM_STATUS = :online
# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')
@ -43,7 +15,7 @@ Rails::Initializer.run do |config|
# config.load_paths += %W( #{RAILS_ROOT}/extras )
# Specify gems that this application depends on and have them installed with rake gems:install
unless OSM_STATUS == :database_offline
unless STATUS == :database_offline
config.gem 'composite_primary_keys', :version => '2.2.2'
end
config.gem 'libxml-ruby', :version => '>= 1.1.1', :lib => 'libxml'
@ -59,7 +31,7 @@ Rails::Initializer.run do |config|
# Skip frameworks you're not going to use. To use Rails without a database,
# you must remove the Active Record framework.
if OSM_STATUS == :database_offline
if STATUS == :database_offline
config.frameworks -= [ :active_record ]
config.eager_load_paths = []
end

View file

@ -1,4 +0,0 @@
# This file loads various yml configuration files
# Load application config
APP_CONFIG = YAML.load(File.read(RAILS_ROOT + "/config/application.yml"))[RAILS_ENV]

View file

@ -1,11 +1,11 @@
# Setup any specified hard limit on the virtual size of the process
if APP_CONFIG.include?('hard_memory_limit') and Process.const_defined?(:RLIMIT_AS)
Process.setrlimit Process::RLIMIT_AS, APP_CONFIG['hard_memory_limit']*1024*1024, Process::RLIM_INFINITY
if defined?(HARD_MEMORY_LIMIT) and Process.const_defined?(:RLIMIT_AS)
Process.setrlimit Process::RLIMIT_AS, HARD_MEMORY_LIMIT*1024*1024, Process::RLIM_INFINITY
end
# If we're running under passenger and a soft memory limit is
# configured then setup some rack middleware to police the limit
if APP_CONFIG.include?('soft_memory_limit') and defined?(PhusionPassenger)
if defined?(SOFT_MEMORY_LIMIT) and defined?(PhusionPassenger)
# Define some rack middleware to police the soft memory limit
class MemoryLimit
def initialize(app)
@ -17,7 +17,7 @@ if APP_CONFIG.include?('soft_memory_limit') and defined?(PhusionPassenger)
status, headers, body = @app.call(env)
# Restart if we've hit our memory limit
if resident_size > APP_CONFIG['soft_memory_limit']
if resident_size > SOFT_MEMORY_LIMIT
Process.kill("USR1", 0)
end

View file

@ -12,6 +12,6 @@ ActionController::Base.session = {
# Use the database for sessions instead of the cookie-based default,
# which shouldn't be used to store highly confidential information
# (create the session table with "rake db:sessions:create")
unless OSM_STATUS == :database_offline or OSM_STATUS == :database_readonly
unless STATUS == :database_offline or STATUS == :database_readonly
ActionController::Base.session_store = :sql_session_store
end

View file

@ -4,6 +4,6 @@ adapter = Rails.configuration.database_configuration[environment]["adapter"]
session_class = adapter + "_session"
# Configure SqlSessionStore
unless OSM_STATUS == :database_offline
unless STATUS == :database_offline
SqlSessionStore.session_class = session_class.camelize.constantize
end

16
config/preinitializer.rb Normal file
View file

@ -0,0 +1,16 @@
require 'yaml'
config = YAML.load_file("#{RAILS_ROOT}/config/application.yml")
env = ENV['RAILS_ENV'] || 'development'
ENV.each do |key,value|
if key.match(/^OSM_(.*)$/)
Object.const_set(Regexp.last_match(1).upcase, value)
end
end
config[env].each do |key,value|
unless Object.const_defined?(key.upcase)
Object.const_set(key.upcase, value)
end
end

View file

@ -24,8 +24,8 @@ module MapBoundary
# check the bbox isn't too large
requested_area = (max_lat-min_lat)*(max_lon-min_lon)
if requested_area > APP_CONFIG['max_request_area']
raise OSM::APIBadBoundingBox.new("The maximum bbox size is " + APP_CONFIG['max_request_area'].to_s +
if requested_area > MAX_REQUEST_AREA
raise OSM::APIBadBoundingBox.new("The maximum bbox size is " + MAX_REQUEST_AREA.to_s +
", and your request was too large. Either request a smaller area, or use planet.osm")
end
end

View file

@ -530,7 +530,7 @@ module OSM
def self.legal_text_for_country(country_code)
file_name = File.join(RAILS_ROOT, "config", "legales", country_code.to_s + ".yml")
file_name = File.join(RAILS_ROOT, "config", "legales", APP_CONFIG['default_legale'] + ".yml") unless File.exist? file_name
file_name = File.join(RAILS_ROOT, "config", "legales", DEFAULT_LEGALE + ".yml") unless File.exist? file_name
YAML::load_file(file_name)
end
end

View file

@ -17,8 +17,8 @@ module Quova
##
# Access details for WSDL description
WSDL_URL="https://webservices.quova.com/OnDemand/GeoPoint/v1/default.asmx?WSDL"
WSDL_USER = APP_CONFIG['quova_username']
WSDL_PASS = APP_CONFIG['quova_password']
WSDL_USER = QUOVA_USERNAME
WSDL_PASS = QUOVA_PASSWORD
##
# Status codes

View file

@ -147,7 +147,7 @@ class ApiControllerTest < ActionController::TestCase
[ "trackpoints", "map" ].each do |tq|
get tq, :bbox => bbox
assert_response :bad_request, "The bbox:#{bbox} was expected to be too big"
assert_equal "The maximum bbox size is #{APP_CONFIG['max_request_area']}, and your request was too large. Either request a smaller area, or use planet.osm", @response.body, "bbox: #{bbox}"
assert_equal "The maximum bbox size is #{MAX_REQUEST_AREA}, and your request was too large. Either request a smaller area, or use planet.osm", @response.body, "bbox: #{bbox}"
end
end
end
@ -264,8 +264,8 @@ class ApiControllerTest < ActionController::TestCase
assert_select "osm:root[version='#{API_VERSION}'][generator='#{GENERATOR}']", :count => 1 do
assert_select "api", :count => 1 do
assert_select "version[minimum=#{API_VERSION}][maximum=#{API_VERSION}]", :count => 1
assert_select "area[maximum=#{APP_CONFIG['max_request_area']}]", :count => 1
assert_select "tracepoints[per_page=#{APP_CONFIG['tracepoints_per_page']}]", :count => 1
assert_select "area[maximum=#{MAX_REQUEST_AREA}]", :count => 1
assert_select "tracepoints[per_page=#{TRACEPOINTS_PER_PAGE}]", :count => 1
assert_select "changesets[maximum_elements=#{Changeset::MAX_ELEMENTS}]", :count => 1
end
end

View file

@ -26,7 +26,7 @@ class WayTest < ActiveSupport::TestCase
way = Way.find(current_ways(:visible_way).id)
assert way.valid?
# it already has 1 node
1.upto((APP_CONFIG['max_number_of_way_nodes']) / 2) {
1.upto((MAX_NUMBER_OF_WAY_NODES) / 2) {
way.add_nd_num(current_nodes(:used_node_1).id)
way.add_nd_num(current_nodes(:used_node_2).id)
}