# calls each action (private method) accordingly.
def amf_read
- if request.post?
- self.status = :ok
- self.content_type = Mime::AMF
- self.response_body = Dispatcher.new(request.raw_post) do |message,*args|
- logger.info("Executing AMF #{message}(#{args.join(',')})")
-
- case message
- when 'getpresets'; result = getpresets(*args)
- when 'whichways'; result = whichways(*args)
- when 'whichways_deleted'; result = whichways_deleted(*args)
- when 'getway'; result = getway(args[0].to_i)
- when 'getrelation'; result = getrelation(args[0].to_i)
- when 'getway_old'; result = getway_old(args[0].to_i,args[1])
- when 'getway_history'; result = getway_history(args[0].to_i)
- when 'getnode_history'; result = getnode_history(args[0].to_i)
- when 'findgpx'; result = findgpx(*args)
- when 'findrelations'; result = findrelations(*args)
- when 'getpoi'; result = getpoi(*args)
- end
-
- result
+ self.status = :ok
+ self.content_type = Mime::AMF
+ self.response_body = Dispatcher.new(request.raw_post) do |message,*args|
+ logger.info("Executing AMF #{message}(#{args.join(',')})")
+
+ case message
+ when 'getpresets'; result = getpresets(*args)
+ when 'whichways'; result = whichways(*args)
+ when 'whichways_deleted'; result = whichways_deleted(*args)
+ when 'getway'; result = getway(args[0].to_i)
+ when 'getrelation'; result = getrelation(args[0].to_i)
+ when 'getway_old'; result = getway_old(args[0].to_i,args[1])
+ when 'getway_history'; result = getway_history(args[0].to_i)
+ when 'getnode_history'; result = getnode_history(args[0].to_i)
+ when 'findgpx'; result = findgpx(*args)
+ when 'findrelations'; result = findrelations(*args)
+ when 'getpoi'; result = getpoi(*args)
end
- else
- render :nothing => true, :status => :method_not_allowed
+
+ result
end
end
def amf_write
- if request.post?
- renumberednodes = {} # Shared across repeated putways
- renumberedways = {} # Shared across repeated putways
- err = false # Abort batch on error
-
- self.status = :ok
- self.content_type = Mime::AMF
- self.response_body = Dispatcher.new(request.raw_post) do |message,*args|
- logger.info("Executing AMF #{message}")
-
- if err
- result = [-5, nil]
- else
- case message
- when 'putway'; orn = renumberednodes.dup
- result = putway(renumberednodes, *args)
- result[4] = renumberednodes.reject { |k,v| orn.has_key?(k) }
- if result[0] == 0 and result[2] != result[3] then renumberedways[result[2]] = result[3] end
- when 'putrelation'; result = putrelation(renumberednodes, renumberedways, *args)
- when 'deleteway'; result = deleteway(*args)
- when 'putpoi'; result = putpoi(*args)
- if result[0] == 0 and result[2] != result[3] then renumberednodes[result[2]] = result[3] end
- when 'startchangeset'; result = startchangeset(*args)
- end
+ renumberednodes = {} # Shared across repeated putways
+ renumberedways = {} # Shared across repeated putways
+ err = false # Abort batch on error
+
+ self.status = :ok
+ self.content_type = Mime::AMF
+ self.response_body = Dispatcher.new(request.raw_post) do |message,*args|
+ logger.info("Executing AMF #{message}")
- err = true if result[0] == -3 # If a conflict is detected, don't execute any more writes
+ if err
+ result = [-5, nil]
+ else
+ case message
+ when 'putway'; orn = renumberednodes.dup
+ result = putway(renumberednodes, *args)
+ result[4] = renumberednodes.reject { |k,v| orn.has_key?(k) }
+ if result[0] == 0 and result[2] != result[3] then renumberedways[result[2]] = result[3] end
+ when 'putrelation'; result = putrelation(renumberednodes, renumberedways, *args)
+ when 'deleteway'; result = deleteway(*args)
+ when 'putpoi'; result = putpoi(*args)
+ if result[0] == 0 and result[2] != result[3] then renumberednodes[result[2]] = result[3] end
+ when 'startchangeset'; result = startchangeset(*args)
end
- result
+ err = true if result[0] == -3 # If a conflict is detected, don't execute any more writes
end
- else
- render :nothing => true, :status => :method_not_allowed
+
+ result
end
end
if gpx_file.identifiable?
track << (XML::Node.new("name") << gpx_file.name)
track << (XML::Node.new("desc") << gpx_file.description)
- track << (XML::Node.new("url") << url_for(:controller => 'trace', :action => 'view', :id => gpx_file.id))
+ track << (XML::Node.new("url") << url_for(:controller => 'trace', :action => 'view', :display_name => gpx_file.user.display_name, :id => gpx_file.id))
end
else
# use the anonymous track segment if the user hasn't allowed
@trace.tagstring = params[:trace][:tagstring]
@trace.visibility = params[:trace][:visibility]
if @trace.save
- redirect_to :action => 'view'
+ redirect_to :action => 'view', :display_name => @user.display_name
end
end
else
trace = Trace.find(params[:id])
if @user and trace.user == @user
- if request.post? and trace.visible?
+ if trace.visible?
trace.visible = false
trace.save
flash[:notice] = t 'trace.delete.scheduled_for_deletion'
redirect_to :action => :list, :display_name => @user.display_name
else
- render :nothing => true, :status => :bad_request
+ render :nothing => true, :status => :not_found
end
else
render :nothing => true, :status => :forbidden
end
def api_create
- if request.post?
- tags = params[:tags] || ""
- description = params[:description] || ""
- visibility = params[:visibility]
-
- if visibility.nil?
- if params[:public] && params[:public].to_i.nonzero?
- visibility = "public"
- else
- visibility = "private"
- end
+ tags = params[:tags] || ""
+ description = params[:description] || ""
+ visibility = params[:visibility]
+
+ if visibility.nil?
+ if params[:public] && params[:public].to_i.nonzero?
+ visibility = "public"
+ else
+ visibility = "private"
end
+ end
- if params[:file].respond_to?(:read)
- do_create(params[:file], tags, description, visibility)
+ if params[:file].respond_to?(:read)
+ do_create(params[:file], tags, description, visibility)
- if @trace.id
- render :text => @trace.id.to_s, :content_type => "text/plain"
- elsif @trace.valid?
- render :nothing => true, :status => :internal_server_error
- else
- render :nothing => true, :status => :bad_request
- end
+ if @trace.id
+ render :text => @trace.id.to_s, :content_type => "text/plain"
+ elsif @trace.valid?
+ render :nothing => true, :status => :internal_server_error
else
render :nothing => true, :status => :bad_request
end
else
- render :nothing => true, :status => :method_not_allowed
+ render :nothing => true, :status => :bad_request
end
end
return
end
- @user_block = UserBlock.new(:user_id => @this_user.id,
- :creator_id => @user.id,
- :reason => params[:user_block][:reason],
- :ends_at => Time.now.getutc() + @block_period.hours,
- :needs_view => params[:user_block][:needs_view])
+ @user_block = UserBlock.new({
+ :user_id => @this_user.id,
+ :creator_id => @user.id,
+ :reason => params[:user_block][:reason],
+ :ends_at => Time.now.getutc() + @block_period.hours,
+ :needs_view => params[:user_block][:needs_view]
+ }, :without_protection => true)
if @user_block.save
flash[:notice] = t('user_block.create.flash', :name => @this_user.display_name)
if @user_block.update_attributes({ :ends_at => Time.now.getutc() + @block_period.hours,
:reason => params[:user_block][:reason],
- :needs_view => params[:user_block][:needs_view] })
+ :needs_view => params[:user_block][:needs_view] }, :without_protection => true)
flash[:notice] = t('user_block.update.success')
redirect_to(@user_block)
else
##
# sets a user's status
def set_status
- @this_user.update_attributes(:status => params[:status])
+ @this_user.status = params[:status]
+ @this_user.save
redirect_to :controller => 'user', :action => 'view', :display_name => params[:display_name]
end
# Choose the layout to use. See
# https://rails.lighthouseapp.com/projects/8994/tickets/5371-layout-with-onlyexcept-options-makes-other-actions-render-without-layouts
def choose_layout
- oauth_url = url_for(:controller => :oauth, :action => :oauthorize, :only_path => true)
+ oauth_url = url_for(:controller => :oauth, :action => :authorize, :only_path => true)
if [ 'api_details' ].include? action_name
nil
end
if user.status == "active" and user.spam_score > SPAM_THRESHOLD
- user.update_attributes(:status => "suspended")
+ user.update_column(:status, "suspended")
end
end
end
private
def expire_cache_for(record)
- expire_action(:controller => 'trace', :action => 'view', :id => record.id)
expire_action(:controller => 'trace', :action => 'view', :display_name => record.user.display_name, :id => record.id)
expire_action(:controller => 'trace', :action => 'list', :display_name => nil, :tag => nil)
expire_action(:controller => 'diary_entry', :action => 'rss', :format => :rss, :language => nil, :display_name => old_record.display_name)
old_record.traces.each do |trace|
- expire_action(:controller => 'trace', :action => 'view', :id => trace.id)
expire_action(:controller => 'trace', :action => 'view', :display_name => old_record.display_name, :id => trace.id)
trace.tags.each do |tag|
-<!-- Piwik -->
<script type="text/javascript">
-var pkBaseURL = (("https:" == document.location.protocol) ? "https://<%= PIWIK_LOCATION %>/" : "http://<%= PIWIK_LOCATION %>/");
-document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E"));
-</script><script type="text/javascript">
-try {
-var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", <%= PIWIK_SITE %>);
-piwikTracker.trackPageView();
-piwikTracker.enableLinkTracking();
+var _paq = _paq || [];
+(function(){ var u="<%= request.protocol %><%= PIWIK_LOCATION %>/";
+_paq.push(['setSiteId', <%= PIWIK_SITE %>]);
+_paq.push(['setTrackerUrl', u+'piwik.php']);
+_paq.push(['trackPageView']);
+_paq.push(['enableLinkTracking']);
<% if flash[:piwik_goal] -%>
-piwikTracker.trackGoal(<%= flash[:piwik_goal] %>);
+_paq.push(['setSiteId', <%= flash[:piwik_goal] %>);
<% end -%>
-} catch( err ) {}
-</script><noscript><p><img src="http://<%= PIWIK_LOCATION %>/piwik.php?idsite=<%= PIWIK_SITE %>" style="border:0" alt="" /></p></noscript>
-<!-- End Piwik Tracking Code -->
+var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.type='text/javascript'; g.defer=true; g.async=true; g.src=u+'piwik.js';
+s.parentNode.insertBefore(g,s); })();
+</script>
+<noscript><p><img src="<%= request.protocol %><%= PIWIK_LOCATION %>/piwik.php?idsite=<%= PIWIK_SITE %>" style="border:0" alt="" /></p></noscript>
<% this_colour = cycle('lightgrey', 'white') %>
<tr id="inbox-<%= message_summary.id %>" class="inbox-row<%= "-unread" if not message_summary.message_read? %>">
- <td class="inbox-sender" bgcolor="<%= this_colour %>"><%= link_to h(message_summary.sender.display_name), :controller => 'user', :action => message_summary.sender.display_name %></td>
+ <td class="inbox-sender" bgcolor="<%= this_colour %>"><%= link_to h(message_summary.sender.display_name), :controller => 'user', :action => 'view', :display_name => message_summary.sender.display_name %></td>
<td class="inbox-subject" bgcolor="<%= this_colour %>"><%= link_to h(message_summary.title), :controller => 'message', :action => 'read', :message_id => message_summary.id %></td>
<td class="inbox-sent nowrap" bgcolor="<%= this_colour %>"><%= l message_summary.sent_on, :format => :friendly %></td>
<% if message_summary.message_read? %>
-<h2><%= t'message.inbox.my_inbox'%>/<%= link_to t('message.inbox.outbox'), url_for(:controller => "user", :action => "outbox", :id => @user.display_name) %></h2>
+<h2><%= t'message.inbox.my_inbox'%>/<%= link_to t('message.inbox.outbox'), outbox_path(@user.display_name) %></h2>
<%= render :partial => "message_count" %>
-<h2><%= raw(t'message.outbox.my_inbox', :inbox_link => link_to(t('message.outbox.inbox'), url_for(:controller => "user", :action => "inbox", :id => @user.display_name))) %>/<%= t'message.outbox.outbox' %></h2>
+<h2><%= raw(t'message.outbox.my_inbox', :inbox_link => link_to(t('message.outbox.inbox'), inbox_path(@user.display_name))) %>/<%= t'message.outbox.outbox' %></h2>
<p><%= t'message.outbox.messages', :count => @user.sent_messages.size %>
<!-- Displaying user's own profile page -->
<%= link_to t('user.view.my diary'), :controller => 'diary_entry', :action => 'list', :display_name => @user.display_name %>
|
- <%= link_to t('user.view.new diary entry'), :controller => 'diary_entry', :action => 'new', :display_name => @user.display_name %>
+ <%= link_to t('user.view.new diary entry'), :controller => 'diary_entry', :action => 'new' %>
|
<%= link_to t('user.view.my comments' ), :controller => 'diary_entry', :action => 'comments', :display_name => @this_user.display_name %>
|
<% if friends.empty? %>
<%= t 'user.view.no friends' %>
<% else %>
- <%= link_to t('user.view.friends_changesets'), {:controller => 'browse', :action => 'friends'} %><br/>
- <%= link_to t('user.view.friends_diaries'), {:controller => 'diary', :action => 'friends'} %><br/><br/>
+ <%= link_to t('user.view.friends_changesets'), friend_changesets_path %><br/>
+ <%= link_to t('user.view.friends_diaries'), friend_diaries_path %><br/><br/>
<table id="friends">
<%= render :partial => "contact", :collection => friends %>
</table>
<% if nearby.empty? %>
<%= t 'user.view.no nearby users' %>
<% else %>
- <%= link_to t('user.view.nearby_changesets'), {:controller => 'browse', :action => 'nearby'} %><br/>
- <%= link_to t('user.view.nearby_diaries'), {:controller => 'diary', :action => 'nearby'} %><br/><br/>
+ <%= link_to t('user.view.nearby_changesets'), nearby_changesets_path %><br/>
+ <%= link_to t('user.view.nearby_diaries'), nearby_diaries_path %><br/><br/>
<table id="nearbyusers">
<%= render :partial => "contact", :collection => nearby %>
</table>
<td class="<%= c1 %>"><%= link_to t('user_block.partial.show'), block %></td>
<td class="<%= c1 %>"><% if @user and @user.id == block.creator_id and block.active? %><%= link_to t('user_block.partial.edit'), edit_user_block_path(block) %><% end %></td>
<% if show_revoke_link %>
- <td class="<%= c1 %>"><% if block.active? %><%= link_to t('user_block.partial.revoke'), block, :confirm => t('user_block.partial.confirm'), :action => :revoke %><% end %></td>
+ <td class="<%= c1 %>"><% if block.active? %><%= link_to t('user_block.partial.revoke'), :controller => 'user_blocks', :action => 'revoke', :id => block.id %><% end %></td>
<% end %>
</tr>
<% @title = t 'user_block.edit.title', :name => h(@user_block.user.display_name) %>
-<h1><%= t('user_block.edit.title',
- :name => link_to(
- h(@user_block.user.display_name),
- {:controller => 'user', :action => 'view', :display_name => @user_block.user.display_name})) %></h1>
+<h1><%= raw t('user_block.edit.title',
+ :name => link_to(
+ h(@user_block.user.display_name),
+ {:controller => 'user', :action => 'view', :display_name => @user_block.user.display_name})) %></h1>
<%= form_for(@user_block) do |f| %>
<%= f.error_messages %>
<% @title = t('user_block.revoke.title',
:block_on => h(@user_block.user.display_name),
:block_by => h(@user_block.creator.display_name)) %>
-<h1><%= t('user_block.revoke.heading',
- :block_on => link_to(
- h(@user_block.user.display_name),
- {:controller => 'user', :action => 'view', :display_name => @user_block.user.display_name}),
- :block_by => link_to(
- h(@user_block.creator.display_name),
- {:controller => 'user', :action => 'view', :display_name => @user_block.creator.display_name})) %></h1>
+<h1><%= raw t('user_block.revoke.heading',
+ :block_on => link_to(
+ h(@user_block.user.display_name),
+ {:controller => 'user', :action => 'view', :display_name => @user_block.user.display_name}),
+ :block_by => link_to(
+ h(@user_block.creator.display_name),
+ {:controller => 'user', :action => 'view', :display_name => @user_block.creator.display_name})) %></h1>
<% if @user_block.ends_at > Time.now %>
<p><b>
OpenStreetMap::Application.routes.draw do
# API
- match 'api/capabilities' => 'api#capabilities'
- match 'api/0.6/capabilities' => 'api#capabilities'
-
- match 'api/0.6/changeset/create' => 'changeset#create'
- match 'api/0.6/changeset/:id/upload' => 'changeset#upload', :id => /\d+/
- match 'api/0.6/changeset/:id/download' => 'changeset#download', :as => :changeset_download, :id => /\d+/
- match 'api/0.6/changeset/:id/expand_bbox' => 'changeset#expand_bbox', :id => /\d+/
- match 'api/0.6/changeset/:id' => 'changeset#read', :as => :changeset_read, :via => :get, :id => /\d+/
+ match 'api/capabilities' => 'api#capabilities', :via => :get
+ match 'api/0.6/capabilities' => 'api#capabilities', :via => :get
+
+ match 'api/0.6/changeset/create' => 'changeset#create', :via => :put
+ match 'api/0.6/changeset/:id/upload' => 'changeset#upload', :via => :post, :id => /\d+/
+ match 'api/0.6/changeset/:id/download' => 'changeset#download', :via => :get, :as => :changeset_download, :id => /\d+/
+ match 'api/0.6/changeset/:id/expand_bbox' => 'changeset#expand_bbox', :via => :post, :id => /\d+/
+ match 'api/0.6/changeset/:id' => 'changeset#read', :via => :get, :as => :changeset_read, :via => :get, :id => /\d+/
match 'api/0.6/changeset/:id' => 'changeset#update', :via => :put, :id => /\d+/
- match 'api/0.6/changeset/:id/close' => 'changeset#close', :id => /\d+/
- match 'api/0.6/changesets' => 'changeset#query', :id => nil
-
- match 'api/0.6/node/create' => 'node#create'
- match 'api/0.6/node/:id/ways' => 'way#ways_for_node', :id => /\d+/
- match 'api/0.6/node/:id/relations' => 'relation#relations_for_node', :id => /\d+/
- match 'api/0.6/node/:id/history' => 'old_node#history', :id => /\d+/
- match 'api/0.6/node/:id/:version' => 'old_node#version', :version => /\d+/, :id => /\d+/
+ match 'api/0.6/changeset/:id/close' => 'changeset#close', :via => :put, :id => /\d+/
+ match 'api/0.6/changesets' => 'changeset#query', :via => :get
+
+ match 'api/0.6/node/create' => 'node#create', :via => :put
+ match 'api/0.6/node/:id/ways' => 'way#ways_for_node', :via => :get, :id => /\d+/
+ match 'api/0.6/node/:id/relations' => 'relation#relations_for_node', :via => :get, :id => /\d+/
+ match 'api/0.6/node/:id/history' => 'old_node#history', :via => :get, :id => /\d+/
+ match 'api/0.6/node/:id/:version' => 'old_node#version', :via => :get, :id => /\d+/, :version => /\d+/
match 'api/0.6/node/:id' => 'node#read', :via => :get, :id => /\d+/
match 'api/0.6/node/:id' => 'node#update', :via => :put, :id => /\d+/
match 'api/0.6/node/:id' => 'node#delete', :via => :delete, :id => /\d+/
- match 'api/0.6/nodes' => 'node#nodes', :id => nil
+ match 'api/0.6/nodes' => 'node#nodes', :via => :get
- match 'api/0.6/way/create' => 'way#create'
- match 'api/0.6/way/:id/history' => 'old_way#history', :id => /\d+/
- match 'api/0.6/way/:id/full' => 'way#full', :id => /\d+/
- match 'api/0.6/way/:id/relations' => 'relation#relations_for_way', :id => /\d+/
- match 'api/0.6/way/:id/:version' => 'old_way#version', :version => /\d+/, :id => /\d+/
+ match 'api/0.6/way/create' => 'way#create', :via => :put
+ match 'api/0.6/way/:id/history' => 'old_way#history', :via => :get, :id => /\d+/
+ match 'api/0.6/way/:id/full' => 'way#full', :via => :get, :id => /\d+/
+ match 'api/0.6/way/:id/relations' => 'relation#relations_for_way', :via => :get, :id => /\d+/
+ match 'api/0.6/way/:id/:version' => 'old_way#version', :via => :get, :id => /\d+/, :version => /\d+/
match 'api/0.6/way/:id' => 'way#read', :via => :get, :id => /\d+/
match 'api/0.6/way/:id' => 'way#update', :via => :put, :id => /\d+/
match 'api/0.6/way/:id' => 'way#delete', :via => :delete, :id => /\d+/
- match 'api/0.6/ways' => 'way#ways', :id => nil
+ match 'api/0.6/ways' => 'way#ways', :via => :get
- match 'api/0.6/relation/create' => 'relation#create'
- match 'api/0.6/relation/:id/relations' => 'relation#relations_for_relation', :id => /\d+/
- match 'api/0.6/relation/:id/history' => 'old_relation#history', :id => /\d+/
- match 'api/0.6/relation/:id/full' => 'relation#full', :id => /\d+/
- match 'api/0.6/relation/:id/:version' => 'old_relation#version', :version => /\d+/, :id => /\d+/
+ match 'api/0.6/relation/create' => 'relation#create', :via => :put
+ match 'api/0.6/relation/:id/relations' => 'relation#relations_for_relation', :via => :get, :id => /\d+/
+ match 'api/0.6/relation/:id/history' => 'old_relation#history', :via => :get, :id => /\d+/
+ match 'api/0.6/relation/:id/full' => 'relation#full', :via => :get, :id => /\d+/
+ match 'api/0.6/relation/:id/:version' => 'old_relation#version', :via => :get, :id => /\d+/, :version => /\d+/
match 'api/0.6/relation/:id' => 'relation#read', :via => :get, :id => /\d+/
match 'api/0.6/relation/:id' => 'relation#update', :via => :put, :id => /\d+/
match 'api/0.6/relation/:id' => 'relation#delete', :via => :delete, :id => /\d+/
- match 'api/0.6/relations' => 'relation#relations'
+ match 'api/0.6/relations' => 'relation#relations', :via => :get
- match 'api/0.6/map' => 'api#map'
+ match 'api/0.6/map' => 'api#map', :via => :get
- match 'api/0.6/trackpoints' => 'api#trackpoints'
+ match 'api/0.6/trackpoints' => 'api#trackpoints', :via => :get
- match 'api/0.6/changes' => 'api#changes'
+ match 'api/0.6/changes' => 'api#changes', :via => :get
- match 'api/0.6/search' => 'search#search_all'
- match 'api/0.6/ways/search' => 'search#search_ways'
- match 'api/0.6/relations/search' => 'search#search_relations'
- match 'api/0.6/nodes/search' => 'search#search_nodes'
+ match 'api/0.6/search' => 'search#search_all', :via => :get
+ match 'api/0.6/ways/search' => 'search#search_ways', :via => :get
+ match 'api/0.6/relations/search' => 'search#search_relations', :via => :get
+ match 'api/0.6/nodes/search' => 'search#search_nodes', :via => :get
- match 'api/0.6/user/details' => 'user#api_details'
+ match 'api/0.6/user/details' => 'user#api_details', :via => :get
match 'api/0.6/user/preferences' => 'user_preference#read', :via => :get
match 'api/0.6/user/preferences/:preference_key' => 'user_preference#read_one', :via => :get
match 'api/0.6/user/preferences' => 'user_preference#update', :via => :put
match 'api/0.6/user/preferences/:preference_key' => 'user_preference#update_one', :via => :put
match 'api/0.6/user/preferences/:preference_key' => 'user_preference#delete_one', :via => :delete
- match 'api/0.6/user/gpx_files' => 'user#api_gpx_files'
+ match 'api/0.6/user/gpx_files' => 'user#api_gpx_files', :via => :get
- match 'api/0.6/gpx/create' => 'trace#api_create'
+ match 'api/0.6/gpx/create' => 'trace#api_create', :via => :post
match 'api/0.6/gpx/:id' => 'trace#api_read', :via => :get, :id => /\d+/
match 'api/0.6/gpx/:id' => 'trace#api_update', :via => :put, :id => /\d+/
match 'api/0.6/gpx/:id' => 'trace#api_delete', :via => :delete, :id => /\d+/
- match 'api/0.6/gpx/:id/details' => 'trace#api_read', :id => /\d+/
- match 'api/0.6/gpx/:id/data' => 'trace#api_data'
- match 'api/0.6/gpx/:id/data.:format' => 'trace#api_data'
+ match 'api/0.6/gpx/:id/details' => 'trace#api_read', :via => :get, :id => /\d+/
+ match 'api/0.6/gpx/:id/data' => 'trace#api_data', :via => :get
# AMF (ActionScript) API
- match 'api/0.6/amf/read' => 'amf#amf_read'
- match 'api/0.6/amf/write' => 'amf#amf_write'
- match 'api/0.6/swf/trackpoints' => 'swf#trackpoints'
+ match 'api/0.6/amf/read' => 'amf#amf_read', :via => :post
+ match 'api/0.6/amf/write' => 'amf#amf_write', :via => :post
+ match 'api/0.6/swf/trackpoints' => 'swf#trackpoints', :via => :get
# Map notes API
match 'api/0.6/notes' => 'note#list', :format => :xml
match 'api/0.6/notes/getRSSfeed' => 'note#rss', :format => :rss
# Data browsing
- match '/browse/start' => 'browse#start'
- match '/browse/way/:id' => 'browse#way', :id => /\d+/
- match '/browse/way/:id/history' => 'browse#way_history', :id => /\d+/
- match '/browse/node/:id' => 'browse#node', :id => /\d+/
- match '/browse/node/:id/history' => 'browse#node_history', :id => /\d+/
- match '/browse/relation/:id' => 'browse#relation', :id => /\d+/
- match '/browse/relation/:id/history' => 'browse#relation_history', :id => /\d+/
- match '/browse/changeset/:id' => 'browse#changeset', :as => :changeset, :id => /\d+/
- match '/user/:display_name/edits' => 'changeset#list'
- match '/user/:display_name/edits/feed' => 'changeset#feed', :format => :atom
- match '/browse/friends' => 'changeset#list', :friends => true
- match '/browse/nearby' => 'changeset#list', :nearby => true
- match '/browse/changesets' => 'changeset#list'
- match '/browse/changesets/feed' => 'changeset#feed', :format => :atom
- match '/browse/note/:id' => 'browse#note', :id => /\d+/
- match '/user/:display_name/notes' => 'note#mine'
- match '/browse' => 'changeset#list'
+ match '/browse/start' => 'browse#start', :via => :get
+ match '/browse/way/:id' => 'browse#way', :via => :get, :id => /\d+/
+ match '/browse/way/:id/history' => 'browse#way_history', :via => :get, :id => /\d+/
+ match '/browse/node/:id' => 'browse#node', :via => :get, :id => /\d+/
+ match '/browse/node/:id/history' => 'browse#node_history', :via => :get, :id => /\d+/
+ match '/browse/relation/:id' => 'browse#relation', :via => :get, :id => /\d+/
+ match '/browse/relation/:id/history' => 'browse#relation_history', :via => :get, :id => /\d+/
+ match '/browse/changeset/:id' => 'browse#changeset', :via => :get, :as => :changeset, :id => /\d+/
+ match '/browse/note/:id' => 'browse#note', :via => :get, :id => /\d+/
+ match '/user/:display_name/edits' => 'changeset#list', :via => :get
+ match '/user/:display_name/edits/feed' => 'changeset#feed', :via => :get, :format => :atom
+ match '/user/:display_name/notes' => 'note#mine', :via => :get
+ match '/browse/friends' => 'changeset#list', :via => :get, :friends => true, :as => "friend_changesets"
+ match '/browse/nearby' => 'changeset#list', :via => :get, :nearby => true, :as => "nearby_changesets"
+ match '/browse/changesets' => 'changeset#list', :via => :get
+ match '/browse/changesets/feed' => 'changeset#feed', :via => :get, :format => :atom
+ match '/browse' => 'changeset#list', :via => :get
# web site
- root :to => 'site#index'
- match '/edit' => 'site#edit'
- match '/copyright/:copyright_locale' => 'site#copyright'
- match '/copyright' => 'site#copyright'
- match '/history' => 'changeset#list'
- match '/history/feed' => 'changeset#feed', :format => :atom
- match '/export' => 'site#export'
- match '/login' => 'user#login'
- match '/logout' => 'user#logout'
- match '/offline' => 'site#offline'
- match '/key' => 'site#key'
- match '/user/new' => 'user#new'
- match '/user/terms' => 'user#terms'
- match '/user/save' => 'user#save'
- match '/user/:display_name/confirm/resend' => 'user#confirm_resend'
- match '/user/:display_name/confirm' => 'user#confirm'
- match '/user/confirm' => 'user#confirm'
- match '/user/confirm-email' => 'user#confirm_email'
- match '/user/go_public' => 'user#go_public'
- match '/user/reset-password' => 'user#reset_password'
- match '/user/forgot-password' => 'user#lost_password'
- match '/user/suspended' => 'user#suspended'
-
- match '/index.html' => 'site#index'
- match '/edit.html' => 'site#edit'
- match '/export.html' => 'site#export'
- match '/login.html' => 'user#login'
- match '/logout.html' => 'user#logout'
- match '/create-account.html' => 'user#new'
- match '/forgot-password.html' => 'user#lost_password'
+ root :to => 'site#index', :via => :get
+ match '/edit' => 'site#edit', :via => :get
+ match '/copyright/:copyright_locale' => 'site#copyright', :via => :get
+ 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
+ match '/key' => 'site#key', :via => :post
+ match '/user/new' => 'user#new', :via => :get
+ match '/user/terms' => 'user#terms', :via => [:get, :post]
+ match '/user/save' => 'user#save', :via => :post
+ match '/user/:display_name/confirm/resend' => 'user#confirm_resend', :via => :get
+ match '/user/:display_name/confirm' => 'user#confirm', :via => [:get, :post]
+ match '/user/confirm' => 'user#confirm', :via => [:get, :post]
+ match '/user/confirm-email' => 'user#confirm_email', :via => [:get, :post]
+ match '/user/go_public' => 'user#go_public', :via => :post
+ match '/user/reset-password' => 'user#reset_password', :via => [:get, :post]
+ match '/user/forgot-password' => 'user#lost_password', :via => [:get, :post]
+ match '/user/suspended' => 'user#suspended', :via => :get
+
+ match '/index.html' => 'site#index', :via => :get
+ match '/create-account.html' => 'user#new', :via => :get
+ match '/forgot-password.html' => 'user#lost_password', :via => :get
# permalink
- match '/go/:code' => 'site#permalink', :code => /[a-zA-Z0-9_@~]+[=-]*/
+ match '/go/:code' => 'site#permalink', :via => :get, :code => /[a-zA-Z0-9_@~]+[=-]*/
# traces
- match '/user/:display_name/traces/tag/:tag/page/:page' => 'trace#list'
- match '/user/:display_name/traces/tag/:tag' => 'trace#list'
- match '/user/:display_name/traces/page/:page' => 'trace#list'
- match '/user/:display_name/traces' => 'trace#list'
- match '/user/:display_name/traces/tag/:tag/rss' => 'trace#georss'
- match '/user/:display_name/traces/rss' => 'trace#georss'
- match '/user/:display_name/traces/:id' => 'trace#view'
- match '/user/:display_name/traces/:id/picture' => 'trace#picture'
- match '/user/:display_name/traces/:id/icon' => 'trace#icon'
- match '/traces/tag/:tag/page/:page' => 'trace#list'
- match '/traces/tag/:tag' => 'trace#list'
- match '/traces/page/:page' => 'trace#list'
- match '/traces' => 'trace#list'
- match '/traces/tag/:tag/rss' => 'trace#georss'
- match '/traces/rss' => 'trace#georss'
- match '/traces/mine/tag/:tag/page/:page' => 'trace#mine'
- match '/traces/mine/tag/:tag' => 'trace#mine'
- match '/traces/mine/page/:page' => 'trace#mine'
- match '/traces/mine' => 'trace#mine'
- match '/trace/create' => 'trace#create'
- match '/trace/:id/data' => 'trace#data'
- match '/trace/:id/data.:format' => 'trace#data'
- match '/trace/:id/edit' => 'trace#edit'
- match '/trace/:id/delete' => 'trace#delete'
+ match '/user/:display_name/traces/tag/:tag/page/:page' => 'trace#list', :via => :get
+ match '/user/:display_name/traces/tag/:tag' => 'trace#list', :via => :get
+ match '/user/:display_name/traces/page/:page' => 'trace#list', :via => :get
+ match '/user/:display_name/traces' => 'trace#list', :via => :get
+ match '/user/:display_name/traces/tag/:tag/rss' => 'trace#georss', :via => :get
+ match '/user/:display_name/traces/rss' => 'trace#georss', :via => :get
+ match '/user/:display_name/traces/:id' => 'trace#view', :via => :get
+ match '/user/:display_name/traces/:id/picture' => 'trace#picture', :via => :get
+ match '/user/:display_name/traces/:id/icon' => 'trace#icon', :via => :get
+ match '/traces/tag/:tag/page/:page' => 'trace#list', :via => :get
+ match '/traces/tag/:tag' => 'trace#list', :via => :get
+ match '/traces/page/:page' => 'trace#list', :via => :get
+ match '/traces' => 'trace#list', :via => :get
+ match '/traces/tag/:tag/rss' => 'trace#georss', :via => :get
+ match '/traces/rss' => 'trace#georss', :via => :get
+ match '/traces/mine/tag/:tag/page/:page' => 'trace#mine', :via => :get
+ match '/traces/mine/tag/:tag' => 'trace#mine', :via => :get
+ match '/traces/mine/page/:page' => 'trace#mine', :via => :get
+ match '/traces/mine' => 'trace#mine', :via => :get
+ match '/trace/create' => 'trace#create', :via => [:get, :post]
+ match '/trace/:id/data' => 'trace#data', :via => :get
+ match '/trace/:id/edit' => 'trace#edit', :via => [:get, :post, :put]
+ match '/trace/:id/delete' => 'trace#delete', :via => :post
# diary pages
- match '/diary/new' => 'diary_entry#new'
- match '/diary/friends' => 'diary_entry#list', :friends => true
- match '/diary/nearby' => 'diary_entry#list', :nearby => true
- match '/user/:display_name/diary/rss' => 'diary_entry#rss', :format => :rss
- match '/diary/:language/rss' => 'diary_entry#rss', :format => :rss
- match '/diary/rss' => 'diary_entry#rss', :format => :rss
- match '/user/:display_name/diary/comments/:page' => 'diary_entry#comments', :page => /\d+/
- match '/user/:display_name/diary/comments/' => 'diary_entry#comments'
- match '/user/:display_name/diary' => 'diary_entry#list'
- match '/diary/:language' => 'diary_entry#list'
- match '/diary' => 'diary_entry#list'
- match '/user/:display_name/diary/:id' => 'diary_entry#view', :id => /\d+/
- match '/user/:display_name/diary/:id/newcomment' => 'diary_entry#comment', :id => /\d+/
- match '/user/:display_name/diary/:id/edit' => 'diary_entry#edit', :id => /\d+/
- match '/user/:display_name/diary/:id/hide' => 'diary_entry#hide', :id => /\d+/
- match '/user/:display_name/diary/:id/hidecomment/:comment' => 'diary_entry#hidecomment', :id => /\d+/, :comment => /\d+/
+ match '/diary/new' => 'diary_entry#new', :via => [:get, :post]
+ match '/diary/friends' => 'diary_entry#list', :friends => true, :via => :get, :as => "friend_diaries"
+ match '/diary/nearby' => 'diary_entry#list', :nearby => true, :via => :get, :as => "nearby_diaries"
+ match '/user/:display_name/diary/rss' => 'diary_entry#rss', :via => :get, :format => :rss
+ match '/diary/:language/rss' => 'diary_entry#rss', :via => :get, :format => :rss
+ match '/diary/rss' => 'diary_entry#rss', :via => :get, :format => :rss
+ match '/user/:display_name/diary/comments/:page' => 'diary_entry#comments', :via => :get, :page => /\d+/
+ match '/user/:display_name/diary/comments/' => 'diary_entry#comments', :via => :get
+ match '/user/:display_name/diary' => 'diary_entry#list', :via => :get
+ match '/diary/:language' => 'diary_entry#list', :via => :get
+ match '/diary' => 'diary_entry#list', :via => :get
+ match '/user/:display_name/diary/:id' => 'diary_entry#view', :via => :get, :id => /\d+/
+ match '/user/:display_name/diary/:id/newcomment' => 'diary_entry#comment', :via => :post, :id => /\d+/
+ match '/user/:display_name/diary/:id/edit' => 'diary_entry#edit', :via => [:get, :post], :id => /\d+/
+ match '/user/:display_name/diary/:id/hide' => 'diary_entry#hide', :via => :post, :id => /\d+/
+ match '/user/:display_name/diary/:id/hidecomment/:comment' => 'diary_entry#hidecomment', :via => :post, :id => /\d+/, :comment => /\d+/
# user pages
- match '/user/:display_name' => 'user#view'
- match '/user/:display_name/make_friend' => 'user#make_friend'
- match '/user/:display_name/remove_friend' => 'user#remove_friend'
- match '/user/:display_name/account' => 'user#account'
- match '/user/:display_name/set_status' => 'user#set_status'
- match '/user/:display_name/delete' => 'user#delete'
+ match '/user/:display_name' => 'user#view', :via => :get
+ match '/user/:display_name/make_friend' => 'user#make_friend', :via => :get
+ match '/user/:display_name/remove_friend' => 'user#remove_friend', :via => :get
+ match '/user/:display_name/account' => 'user#account', :via => [:get, :post]
+ match '/user/:display_name/set_status' => 'user#set_status', :via => :get
+ match '/user/:display_name/delete' => 'user#delete', :via => :get
# user lists
- match '/users' => 'user#list'
- match '/users/:status' => 'user#list'
-
- # test pages
- match '/test/populate/:table/:from/:count' => 'test#populate'
- match '/test/populate/:table/:count' => 'test#populate', :from => 1
+ match '/users' => 'user#list', :via => [:get, :post]
+ match '/users/:status' => 'user#list', :via => [:get, :post]
# geocoder
- match '/geocoder/search' => 'geocoder#search'
- match '/geocoder/search_latlon' => 'geocoder#search_latlon'
- match '/geocoder/search_us_postcode' => 'geocoder#search_us_postcode'
- match '/geocoder/search_uk_postcode' => 'geocoder#search_uk_postcode'
- match '/geocoder/search_ca_postcode' => 'geocoder#search_ca_postcode'
- match '/geocoder/search_osm_namefinder' => 'geocoder#search_osm_namefinder'
- match '/geocoder/search_osm_nominatim' => 'geocoder#search_osm_nominatim'
- match '/geocoder/search_geonames' => 'geocoder#search_geonames'
- match '/geocoder/description' => 'geocoder#description'
- match '/geocoder/description_osm_namefinder' => 'geocoder#description_osm_namefinder'
- match '/geocoder/description_osm_nominatim' => 'geocoder#description_osm_nominatim'
- match '/geocoder/description_geonames' => 'geocoder#description_geonames'
+ match '/geocoder/search' => 'geocoder#search', :via => :post
+ match '/geocoder/search_latlon' => 'geocoder#search_latlon', :via => :get
+ match '/geocoder/search_us_postcode' => 'geocoder#search_us_postcode', :via => :get
+ match '/geocoder/search_uk_postcode' => 'geocoder#search_uk_postcode', :via => :get
+ match '/geocoder/search_ca_postcode' => 'geocoder#search_ca_postcode', :via => :get
+ match '/geocoder/search_osm_namefinder' => 'geocoder#search_osm_namefinder', :via => :get
+ match '/geocoder/search_osm_nominatim' => 'geocoder#search_osm_nominatim', :via => :get
+ match '/geocoder/search_geonames' => 'geocoder#search_geonames', :via => :get
+ match '/geocoder/description' => 'geocoder#description', :via => :post
+ match '/geocoder/description_osm_namefinder' => 'geocoder#description_osm_namefinder', :via => :get
+ match '/geocoder/description_osm_nominatim' => 'geocoder#description_osm_nominatim', :via => :get
+ match '/geocoder/description_geonames' => 'geocoder#description_geonames', :via => :get
# export
- match '/export/start' => 'export#start'
- match '/export/finish' => 'export#finish'
+ match '/export/start' => 'export#start', :via => :get
+ match '/export/finish' => 'export#finish', :via => :post
# messages
- match '/user/:display_name/inbox' => 'message#inbox'
- match '/user/:display_name/outbox' => 'message#outbox'
- match '/message/new/:display_name' => 'message#new'
- match '/message/read/:message_id' => 'message#read'
- match '/message/mark/:message_id' => 'message#mark'
- match '/message/reply/:message_id' => 'message#reply'
- match '/message/delete/:message_id' => 'message#delete'
+ match '/user/:display_name/inbox' => 'message#inbox', :via => :get, :as => "inbox"
+ match '/user/:display_name/outbox' => 'message#outbox', :via => :get, :as => "outbox"
+ match '/message/new/:display_name' => 'message#new', :via => [:get, :post]
+ match '/message/read/:message_id' => 'message#read', :via => :get
+ match '/message/mark/:message_id' => 'message#mark', :via => :post
+ match '/message/reply/:message_id' => 'message#reply', :via => [:get, :post]
+ match '/message/delete/:message_id' => 'message#delete', :via => :post
# oauth admin pages (i.e: for setting up new clients, etc...)
scope "/user/:display_name" do
match '/oauth/test_request' => 'oauth#test_request', :as => :test_request
# roles and banning pages
- match '/user/:display_name/role/:role/grant' => 'user_roles#grant'
- match '/user/:display_name/role/:role/revoke' => 'user_roles#revoke'
- match '/user/:display_name/blocks' => 'user_blocks#blocks_on'
- match '/user/:display_name/blocks_by' => 'user_blocks#blocks_by'
- match '/blocks/new/:display_name' => 'user_blocks#new'
+ match '/user/:display_name/role/:role/grant' => 'user_roles#grant', :via => [:get, :post]
+ match '/user/:display_name/role/:role/revoke' => 'user_roles#revoke', :via => [:get, :post]
+ match '/user/:display_name/blocks' => 'user_blocks#blocks_on', :via => :get
+ match '/user/:display_name/blocks_by' => 'user_blocks#blocks_by', :via => :get
+ match '/blocks/new/:display_name' => 'user_blocks#new', :via => :get
resources :user_blocks
- match '/blocks/:id/revoke' => 'user_blocks#revoke'
-
- # fall through
- match ':controller/:id/:action' => '#index'
- match ':controller/:action' => '#index'
+ match '/blocks/:id/revoke' => 'user_blocks#revoke', :via => [:get, :post]
end
class AmfControllerTest < ActionController::TestCase
api_fixtures
+ ##
+ # test all routes which lead to this controller
+ def test_routes
+ assert_routing(
+ { :path => "/api/0.6/amf/read", :method => :post },
+ { :controller => "amf", :action => "amf_read" }
+ )
+ assert_routing(
+ { :path => "/api/0.6/amf/write", :method => :post },
+ { :controller => "amf", :action => "amf_write" }
+ )
+ end
+
def test_getway
# check a visible way
id = current_ways(:visible_way).id
# reall reject it, however this is to test to see if the api changes.
end
+ ##
+ # test all routes which lead to this controller
+ def test_routes
+ assert_routing(
+ { :path => "/api/capabilities", :method => :get },
+ { :controller => "api", :action => "capabilities" }
+ )
+ assert_recognizes(
+ { :controller => "api", :action => "capabilities" },
+ { :path => "/api/0.6/capabilities", :method => :get }
+ )
+ assert_routing(
+ { :path => "/api/0.6/map", :method => :get },
+ { :controller => "api", :action => "map" }
+ )
+ assert_routing(
+ { :path => "/api/0.6/trackpoints", :method => :get },
+ { :controller => "api", :action => "trackpoints" }
+ )
+ assert_routing(
+ { :path => "/api/0.6/changes", :method => :get },
+ { :controller => "api", :action => "changes" }
+ )
+ end
+
# -------------------------------------
# Test reading a bounding box.
# -------------------------------------
class BrowseControllerTest < ActionController::TestCase
api_fixtures
+ ##
+ # test all routes which lead to this controller
+ def test_routes
+ assert_routing(
+ { :path => "/browse/start", :method => :get },
+ { :controller => "browse", :action => "start" }
+ )
+ assert_routing(
+ { :path => "/browse/node/1", :method => :get },
+ { :controller => "browse", :action => "node", :id => "1" }
+ )
+ assert_routing(
+ { :path => "/browse/node/1/history", :method => :get },
+ { :controller => "browse", :action => "node_history", :id => "1" }
+ )
+ assert_routing(
+ { :path => "/browse/way/1", :method => :get },
+ { :controller => "browse", :action => "way", :id => "1" }
+ )
+ assert_routing(
+ { :path => "/browse/way/1/history", :method => :get },
+ { :controller => "browse", :action => "way_history", :id => "1" }
+ )
+ assert_routing(
+ { :path => "/browse/relation/1", :method => :get },
+ { :controller => "browse", :action => "relation", :id => "1" }
+ )
+ assert_routing(
+ { :path => "/browse/relation/1/history", :method => :get },
+ { :controller => "browse", :action => "relation_history", :id => "1" }
+ )
+ assert_routing(
+ { :path => "/browse/changeset/1", :method => :get },
+ { :controller => "browse", :action => "changeset", :id => "1" }
+ )
+ end
+
def test_start
xhr :get, :start
assert_response :success
class ChangesetControllerTest < ActionController::TestCase
api_fixtures
+ ##
+ # test all routes which lead to this controller
+ def test_routes
+ assert_routing(
+ { :path => "/api/0.6/changeset/create", :method => :put },
+ { :controller => "changeset", :action => "create" }
+ )
+ assert_routing(
+ { :path => "/api/0.6/changeset/1/upload", :method => :post },
+ { :controller => "changeset", :action => "upload", :id => "1" }
+ )
+ assert_routing(
+ { :path => "/api/0.6/changeset/1/download", :method => :get },
+ { :controller => "changeset", :action => "download", :id => "1" }
+ )
+ assert_routing(
+ { :path => "/api/0.6/changeset/1/expand_bbox", :method => :post },
+ { :controller => "changeset", :action => "expand_bbox", :id => "1" }
+ )
+ assert_routing(
+ { :path => "/api/0.6/changeset/1", :method => :get },
+ { :controller => "changeset", :action => "read", :id => "1" }
+ )
+ assert_routing(
+ { :path => "/api/0.6/changeset/1", :method => :put },
+ { :controller => "changeset", :action => "update", :id => "1" }
+ )
+ assert_routing(
+ { :path => "/api/0.6/changeset/1/close", :method => :put },
+ { :controller => "changeset", :action => "close", :id => "1" }
+ )
+ assert_routing(
+ { :path => "/api/0.6/changesets", :method => :get },
+ { :controller => "changeset", :action => "query" }
+ )
+ assert_routing(
+ { :path => "/user/name/edits", :method => :get },
+ { :controller => "changeset", :action => "list", :display_name => "name" }
+ )
+ assert_routing(
+ { :path => "/user/name/edits/feed", :method => :get },
+ { :controller => "changeset", :action => "feed", :display_name => "name", :format => :atom }
+ )
+ assert_routing(
+ { :path => "/browse/friends", :method => :get },
+ { :controller => "changeset", :action => "list", :friends => true }
+ )
+ assert_routing(
+ { :path => "/browse/nearby", :method => :get },
+ { :controller => "changeset", :action => "list", :nearby => true }
+ )
+ assert_routing(
+ { :path => "/browse/changesets", :method => :get },
+ { :controller => "changeset", :action => "list" }
+ )
+ assert_routing(
+ { :path => "/browse/changesets/feed", :method => :get },
+ { :controller => "changeset", :action => "feed", :format => :atom }
+ )
+ assert_recognizes(
+ { :controller => "changeset", :action => "list" },
+ { :path => "/browse", :method => :get }
+ )
+ assert_recognizes(
+ { :controller => "changeset", :action => "list" },
+ { :path => "/history", :method => :get }
+ )
+ assert_recognizes(
+ { :controller => "changeset", :action => "feed", :format => :atom },
+ { :path => "/history/feed", :method => :get }
+ )
+ end
+
# -----------------------
# Test simple changeset creation
# -----------------------
include ActionView::Helpers::NumberHelper
+ ##
+ # test all routes which lead to this controller
+ def test_routes
+ assert_routing(
+ { :path => "/diary", :method => :get },
+ { :controller => "diary_entry", :action => "list" }
+ )
+ assert_routing(
+ { :path => "/diary/language", :method => :get },
+ { :controller => "diary_entry", :action => "list", :language => "language" }
+ )
+ assert_routing(
+ { :path => "/user/username/diary", :method => :get },
+ { :controller => "diary_entry", :action => "list", :display_name => "username" }
+ )
+ assert_routing(
+ { :path => "/diary/friends", :method => :get },
+ { :controller => "diary_entry", :action => "list", :friends => true }
+ )
+ assert_routing(
+ { :path => "/diary/nearby", :method => :get },
+ { :controller => "diary_entry", :action => "list", :nearby => true }
+ )
+
+ assert_routing(
+ { :path => "/diary/rss", :method => :get },
+ { :controller => "diary_entry", :action => "rss", :format => :rss }
+ )
+ assert_routing(
+ { :path => "/diary/language/rss", :method => :get },
+ { :controller => "diary_entry", :action => "rss", :language => "language", :format => :rss }
+ )
+ assert_routing(
+ { :path => "/user/username/diary/rss", :method => :get },
+ { :controller => "diary_entry", :action => "rss", :display_name => "username", :format => :rss }
+ )
+
+ assert_routing(
+ { :path => "/user/username/diary/comments", :method => :get },
+ { :controller => "diary_entry", :action => "comments", :display_name => "username" }
+ )
+ assert_routing(
+ { :path => "/user/username/diary/comments/1", :method => :get },
+ { :controller => "diary_entry", :action => "comments", :display_name => "username", :page => "1" }
+ )
+
+ assert_routing(
+ { :path => "/diary/new", :method => :get },
+ { :controller => "diary_entry", :action => "new" }
+ )
+ assert_routing(
+ { :path => "/diary/new", :method => :post },
+ { :controller => "diary_entry", :action => "new" }
+ )
+ assert_routing(
+ { :path => "/user/username/diary/1", :method => :get },
+ { :controller => "diary_entry", :action => "view", :display_name => "username", :id => "1" }
+ )
+ assert_routing(
+ { :path => "/user/username/diary/1/edit", :method => :get },
+ { :controller => "diary_entry", :action => "edit", :display_name => "username", :id => "1" }
+ )
+ assert_routing(
+ { :path => "/user/username/diary/1/edit", :method => :post },
+ { :controller => "diary_entry", :action => "edit", :display_name => "username", :id => "1" }
+ )
+ assert_routing(
+ { :path => "/user/username/diary/1/newcomment", :method => :post },
+ { :controller => "diary_entry", :action => "comment", :display_name => "username", :id => "1" }
+ )
+ assert_routing(
+ { :path => "/user/username/diary/1/hide", :method => :post },
+ { :controller => "diary_entry", :action => "hide", :display_name => "username", :id => "1" }
+ )
+ assert_routing(
+ { :path => "/user/username/diary/1/hidecomment/2", :method => :post },
+ { :controller => "diary_entry", :action => "hidecomment", :display_name => "username", :id => "1", :comment => "2" }
+ )
+ end
+
def test_showing_new_diary_entry
@request.cookies["_osm_username"] = users(:normal_user).display_name
def test_editing_diary_entry
@request.cookies["_osm_username"] = users(:normal_user).display_name
+ entry = diary_entries(:normal_user_entry_1)
# Make sure that you are redirected to the login page when you are
# not logged in, without and with the id of the entry you want to edit
- get :edit
+ get :edit, :display_name => entry.user.display_name, :id => entry.id
assert_response :redirect
- assert_redirected_to :controller => :user, :action => "login", :referer => "/diary_entry/edit"
+ assert_redirected_to :controller => :user, :action => "login", :referer => "/user/#{entry.user.display_name}/diary/#{entry.id}/edit"
- get :edit, :id => diary_entries(:normal_user_entry_1).id
- assert_response :redirect
- assert_redirected_to :controller => :user, :action => "login", :referer => "/diary_entry/edit"
-
- # Verify that you get a not found error, when you don't pass an id
- get(:edit, nil, {'user' => users(:normal_user).id})
+ # Verify that you get a not found error, when you pass a bogus id
+ get(:edit, {:display_name => entry.user.display_name, :id => 9999}, {'user' => entry.user.id})
assert_response :not_found
assert_select "html", :count => 1 do
assert_select "body", :count => 1 do
assert_select "div#content", :count => 1 do
- assert_select "h2", :text => "No entry with the id:", :count => 1
+ assert_select "h2", :text => "No entry with the id: 9999", :count => 1
end
end
end
# Now pass the id, and check that you can edit it, when using the same
# user as the person who created the entry
- get(:edit, {:id => diary_entries(:normal_user_entry_1).id}, {'user' => users(:normal_user).id})
+ get(:edit, {:display_name => entry.user.display_name, :id => entry.id}, {'user' => entry.user.id})
assert_response :success
assert_select "html", :count => 1 do
assert_select "head", :count => 1 do
assert_select "body", :count => 1 do
assert_select "div#content", :count => 1 do
assert_select "h1", :text => /Edit diary entry/, :count => 1
- assert_select "form[action='/diary_entry/#{diary_entries(:normal_user_entry_1).id}/edit'][method=post]", :count => 1 do
- assert_select "input#diary_entry_title[name='diary_entry[title]'][value='#{diary_entries(:normal_user_entry_1).title}']", :count => 1
- assert_select "textarea#diary_entry_body[name='diary_entry[body]']", :text => diary_entries(:normal_user_entry_1).body, :count => 1
+ assert_select "form[action='/user/#{entry.user.display_name}/diary/#{entry.id}/edit'][method=post]", :count => 1 do
+ assert_select "input#diary_entry_title[name='diary_entry[title]'][value='#{entry.title}']", :count => 1
+ assert_select "textarea#diary_entry_body[name='diary_entry[body]']", :text => entry.body, :count => 1
assert_select "select#diary_entry_language_code", :count => 1
assert_select "input#latitude[name='diary_entry[latitude]']", :count => 1
assert_select "input#longitude[name='diary_entry[longitude]']", :count => 1
new_latitude = "1.1"
new_longitude = "2.2"
new_language_code = "en"
- post(:edit, {:id => diary_entries(:normal_user_entry_1).id, 'commit' => 'save',
+ post(:edit, {:display_name => entry.user.display_name, :id => entry.id, 'commit' => 'save',
'diary_entry'=>{'title' => new_title, 'body' => new_body, 'latitude' => new_latitude,
'longitude' => new_longitude, 'language_code' => new_language_code} },
- {'user' => users(:normal_user).id})
+ {'user' => entry.user.id})
assert_response :redirect
- assert_redirected_to :action => :view, :id => diary_entries(:normal_user_entry_1).id
+ assert_redirected_to :action => :view, :display_name => entry.user.display_name, :id => entry.id
# Now check that the new data is rendered, when logged in
- get :view, {:id => diary_entries(:normal_user_entry_1).id, :display_name => 'test'}, {'user' => users(:normal_user).id}
+ get :view, {:display_name => entry.user.display_name, :id => entry.id}, {'user' => entry.user.id}
assert_response :success
assert_template 'diary_entry/view'
assert_select "html", :count => 1 do
end
assert_select "body", :count => 1 do
assert_select "div#content", :count => 1 do
- assert_select "h2", :text => /#{users(:normal_user).display_name}'s diary/, :count => 1
+ assert_select "h2", :text => /#{entry.user.display_name}'s diary/, :count => 1
assert_select "b", :text => /#{new_title}/, :count => 1
# This next line won't work if the text has been run through the htmlize function
# due to formatting that could be introduced
assert_select "abbr[class=geo][title=#{number_with_precision(new_latitude, :precision => 4)}; #{number_with_precision(new_longitude, :precision => 4)}]", :count => 1
# As we're not logged in, check that you cannot edit
#print @response.body
- assert_select "a[href='/user/#{users(:normal_user).display_name}/diary/#{diary_entries(:normal_user_entry_1).id}/edit']", :text => "Edit this entry", :count => 1
+ assert_select "a[href='/user/#{entry.user.display_name}/diary/#{entry.id}/edit']", :text => "Edit this entry", :count => 1
end
end
end
@request.cookies["_osm_username"] = users(:public_user).display_name
# and when not logged in as the user who wrote the entry
- get :view, {:id => diary_entries(:normal_user_entry_1).id, :display_name => 'test'}, {'user' => users(:public_user).id}
+ get :view, {:display_name => entry.user.display_name, :id => entry.id}, {'user' => entry.user.id}
assert_response :success
assert_template 'diary_entry/view'
assert_select "html", :count => 1 do
assert_select "p", :text => /#{new_body}/, :count => 1
assert_select "abbr[class=geo][title=#{number_with_precision(new_latitude, :precision => 4)}; #{number_with_precision(new_longitude, :precision => 4)}]", :count => 1
# As we're not logged in, check that you cannot edit
- assert_select "span[class=hidden show_if_user_#{users(:normal_user).id}]", :count => 1 do
- assert_select "a[href='/user/#{users(:normal_user).display_name}/diary/#{diary_entries(:normal_user_entry_1).id}/edit']", :text => "Edit this entry", :count => 1
+ assert_select "span[class=hidden show_if_user_#{entry.user.id}]", :count => 1 do
+ assert_select "a[href='/user/#{entry.user.display_name}/diary/#{entry.id}/edit']", :text => "Edit this entry", :count => 1
end
end
end
require File.dirname(__FILE__) + '/../test_helper'
class ExportControllerTest < ActionController::TestCase
- # Replace this with your real tests.
+
+ ##
+ # test all routes which lead to this controller
+ def test_routes
+ assert_routing(
+ { :path => "/export/start", :method => :get },
+ { :controller => "export", :action => "start" }
+ )
+ assert_routing(
+ { :path => "/export/finish", :method => :post },
+ { :controller => "export", :action => "finish" }
+ )
+ end
+
def test_start
xhr :get, :start
assert_response :success
require 'geocoder_controller'
class GeocoderControllerTest < ActionController::TestCase
+ ##
+ # test all routes which lead to this controller
+ def test_routes
+ assert_routing(
+ { :path => "/geocoder/search", :method => :post },
+ { :controller => "geocoder", :action => "search" }
+ )
+ assert_routing(
+ { :path => "/geocoder/search_latlon", :method => :get },
+ { :controller => "geocoder", :action => "search_latlon" }
+ )
+ assert_routing(
+ { :path => "/geocoder/search_us_postcode", :method => :get },
+ { :controller => "geocoder", :action => "search_us_postcode" }
+ )
+ assert_routing(
+ { :path => "/geocoder/search_uk_postcode", :method => :get },
+ { :controller => "geocoder", :action => "search_uk_postcode" }
+ )
+ assert_routing(
+ { :path => "/geocoder/search_ca_postcode", :method => :get },
+ { :controller => "geocoder", :action => "search_ca_postcode" }
+ )
+ assert_routing(
+ { :path => "/geocoder/search_osm_namefinder", :method => :get },
+ { :controller => "geocoder", :action => "search_osm_namefinder" }
+ )
+ assert_routing(
+ { :path => "/geocoder/search_osm_nominatim", :method => :get },
+ { :controller => "geocoder", :action => "search_osm_nominatim" }
+ )
+ assert_routing(
+ { :path => "/geocoder/search_geonames", :method => :get },
+ { :controller => "geocoder", :action => "search_geonames" }
+ )
- # Replace this with your real tests.
- def test_truth
- assert true
+ assert_routing(
+ { :path => "/geocoder/description", :method => :post },
+ { :controller => "geocoder", :action => "description" }
+ )
+ assert_routing(
+ { :path => "/geocoder/description_osm_namefinder", :method => :get },
+ { :controller => "geocoder", :action => "description_osm_namefinder" }
+ )
+ assert_routing(
+ { :path => "/geocoder/description_osm_nominatim", :method => :get },
+ { :controller => "geocoder", :action => "description_osm_nominatim" }
+ )
+ assert_routing(
+ { :path => "/geocoder/description_geonames", :method => :get },
+ { :controller => "geocoder", :action => "description_geonames" }
+ )
end
end
require 'message_controller'
class MessageControllerTest < ActionController::TestCase
-
- # Replace this with your real tests.
- def test_truth
- assert true
+ ##
+ # test all routes which lead to this controller
+ def test_routes
+ assert_routing(
+ { :path => "/user/username/inbox", :method => :get },
+ { :controller => "message", :action => "inbox", :display_name => "username" }
+ )
+ assert_routing(
+ { :path => "/user/username/outbox", :method => :get },
+ { :controller => "message", :action => "outbox", :display_name => "username" }
+ )
+ assert_routing(
+ { :path => "/message/new/username", :method => :get },
+ { :controller => "message", :action => "new", :display_name => "username" }
+ )
+ assert_routing(
+ { :path => "/message/new/username", :method => :post },
+ { :controller => "message", :action => "new", :display_name => "username" }
+ )
+ assert_routing(
+ { :path => "/message/read/1", :method => :get },
+ { :controller => "message", :action => "read", :message_id => "1" }
+ )
+ assert_routing(
+ { :path => "/message/mark/1", :method => :post },
+ { :controller => "message", :action => "mark", :message_id => "1" }
+ )
+ assert_routing(
+ { :path => "/message/reply/1", :method => :get },
+ { :controller => "message", :action => "reply", :message_id => "1" }
+ )
+ assert_routing(
+ { :path => "/message/reply/1", :method => :post },
+ { :controller => "message", :action => "reply", :message_id => "1" }
+ )
+ assert_routing(
+ { :path => "/message/delete/1", :method => :post },
+ { :controller => "message", :action => "delete", :message_id => "1" }
+ )
end
end
class NodeControllerTest < ActionController::TestCase
api_fixtures
+ ##
+ # test all routes which lead to this controller
+ def test_routes
+ assert_routing(
+ { :path => "/api/0.6/node/create", :method => :put },
+ { :controller => "node", :action => "create" }
+ )
+ assert_routing(
+ { :path => "/api/0.6/node/1", :method => :get },
+ { :controller => "node", :action => "read", :id => "1" }
+ )
+ assert_routing(
+ { :path => "/api/0.6/node/1", :method => :put },
+ { :controller => "node", :action => "update", :id => "1" }
+ )
+ assert_routing(
+ { :path => "/api/0.6/node/1", :method => :delete },
+ { :controller => "node", :action => "delete", :id => "1" }
+ )
+ assert_routing(
+ { :path => "/api/0.6/nodes", :method => :get },
+ { :controller => "node", :action => "nodes" }
+ )
+ end
+
def test_create
# cannot read password from fixture as it is stored as MD5 digest
## First try with no auth
--- /dev/null
+require File.dirname(__FILE__) + '/../test_helper'
+
+class OauthClientsControllerTest < ActionController::TestCase
+ ##
+ # test all routes which lead to this controller
+ def test_routes
+ assert_routing(
+ { :path => "/user/username/oauth_clients", :method => :get },
+ { :controller => "oauth_clients", :action => "index", :display_name => "username" }
+ )
+ assert_routing(
+ { :path => "/user/username/oauth_clients/new", :method => :get },
+ { :controller => "oauth_clients", :action => "new", :display_name => "username" }
+ )
+ assert_routing(
+ { :path => "/user/username/oauth_clients", :method => :post },
+ { :controller => "oauth_clients", :action => "create", :display_name => "username" }
+ )
+ assert_routing(
+ { :path => "/user/username/oauth_clients/1", :method => :get },
+ { :controller => "oauth_clients", :action => "show", :display_name => "username", :id => "1" }
+ )
+ assert_routing(
+ { :path => "/user/username/oauth_clients/1/edit", :method => :get },
+ { :controller => "oauth_clients", :action => "edit", :display_name => "username", :id => "1" }
+ )
+ assert_routing(
+ { :path => "/user/username/oauth_clients/1", :method => :put },
+ { :controller => "oauth_clients", :action => "update", :display_name => "username", :id => "1" }
+ )
+ assert_routing(
+ { :path => "/user/username/oauth_clients/1", :method => :delete },
+ { :controller => "oauth_clients", :action => "destroy", :display_name => "username", :id => "1" }
+ )
+ end
+end
--- /dev/null
+require File.dirname(__FILE__) + '/../test_helper'
+
+class OauthControllerTest < ActionController::TestCase
+ ##
+ # test all routes which lead to this controller
+ def test_routes
+ assert_routing(
+ { :path => "/oauth/revoke" },
+ { :controller => "oauth", :action => "revoke" }
+ )
+ assert_routing(
+ { :path => "/oauth/authorize" },
+ { :controller => "oauth", :action => "authorize" }
+ )
+ assert_routing(
+ { :path => "/oauth/token" },
+ { :controller => "oauth", :action => "token" }
+ )
+ assert_routing(
+ { :path => "/oauth/request_token" },
+ { :controller => "oauth", :action => "request_token" }
+ )
+ assert_routing(
+ { :path => "/oauth/access_token" },
+ { :controller => "oauth", :action => "access_token" }
+ )
+ assert_routing(
+ { :path => "/oauth/test_request" },
+ { :controller => "oauth", :action => "test_request" }
+ )
+ end
+end
# TODO: test history
#
+ ##
+ # test all routes which lead to this controller
+ def test_routes
+ assert_routing(
+ { :path => "/api/0.6/node/1/history", :method => :get },
+ { :controller => "old_node", :action => "history", :id => "1" }
+ )
+ assert_routing(
+ { :path => "/api/0.6/node/1/2", :method => :get },
+ { :controller => "old_node", :action => "version", :id => "1", :version => "2" }
+ )
+ end
+
##
# test the version call by submitting several revisions of a new node
# to the API and ensuring that later calls to version return the
class OldRelationControllerTest < ActionController::TestCase
api_fixtures
+ ##
+ # test all routes which lead to this controller
+ def test_routes
+ assert_routing(
+ { :path => "/api/0.6/relation/1/history", :method => :get },
+ { :controller => "old_relation", :action => "history", :id => "1" }
+ )
+ assert_routing(
+ { :path => "/api/0.6/relation/1/2", :method => :get },
+ { :controller => "old_relation", :action => "version", :id => "1", :version => "2" }
+ )
+ end
+
# -------------------------------------
# Test reading old relations.
# -------------------------------------
class OldWayControllerTest < ActionController::TestCase
api_fixtures
+ ##
+ # test all routes which lead to this controller
+ def test_routes
+ assert_routing(
+ { :path => "/api/0.6/way/1/history", :method => :get },
+ { :controller => "old_way", :action => "history", :id => "1" }
+ )
+ assert_routing(
+ { :path => "/api/0.6/way/1/2", :method => :get },
+ { :controller => "old_way", :action => "version", :id => "1", :version => "2" }
+ )
+ end
+
# -------------------------------------
# Test reading old ways.
# -------------------------------------
class RelationControllerTest < ActionController::TestCase
api_fixtures
+ ##
+ # test all routes which lead to this controller
+ def test_routes
+ assert_routing(
+ { :path => "/api/0.6/relation/create", :method => :put },
+ { :controller => "relation", :action => "create" }
+ )
+ assert_routing(
+ { :path => "/api/0.6/relation/1/full", :method => :get },
+ { :controller => "relation", :action => "full", :id => "1" }
+ )
+ assert_routing(
+ { :path => "/api/0.6/relation/1", :method => :get },
+ { :controller => "relation", :action => "read", :id => "1" }
+ )
+ assert_routing(
+ { :path => "/api/0.6/relation/1", :method => :put },
+ { :controller => "relation", :action => "update", :id => "1" }
+ )
+ assert_routing(
+ { :path => "/api/0.6/relation/1", :method => :delete },
+ { :controller => "relation", :action => "delete", :id => "1" }
+ )
+ assert_routing(
+ { :path => "/api/0.6/relations", :method => :get },
+ { :controller => "relation", :action => "relations" }
+ )
+
+ assert_routing(
+ { :path => "/api/0.6/node/1/relations", :method => :get },
+ { :controller => "relation", :action => "relations_for_node", :id => "1" }
+ )
+ assert_routing(
+ { :path => "/api/0.6/way/1/relations", :method => :get },
+ { :controller => "relation", :action => "relations_for_way", :id => "1" }
+ )
+ assert_routing(
+ { :path => "/api/0.6/relation/1/relations", :method => :get },
+ { :controller => "relation", :action => "relations_for_relation", :id => "1" }
+ )
+ end
+
# -------------------------------------
# Test reading relations.
# -------------------------------------
require File.dirname(__FILE__) + '/../test_helper'
class SearchControllerTest < ActionController::TestCase
- # Replace this with your real tests.
- def test_truth
- assert true
+ ##
+ # test all routes which lead to this controller
+ def test_routes
+ assert_routing(
+ { :path => "/api/0.6/search", :method => :get },
+ { :controller => "search", :action => "search_all" }
+ )
+ assert_routing(
+ { :path => "/api/0.6/nodes/search", :method => :get },
+ { :controller => "search", :action => "search_nodes" }
+ )
+ assert_routing(
+ { :path => "/api/0.6/ways/search", :method => :get },
+ { :controller => "search", :action => "search_ways" }
+ )
+ assert_routing(
+ { :path => "/api/0.6/relations/search", :method => :get },
+ { :controller => "search", :action => "search_relations" }
+ )
end
end
class SiteControllerTest < ActionController::TestCase
fixtures :users
+ ##
+ # test all routes which lead to this controller
+ def test_routes
+ assert_routing(
+ { :path => "/", :method => :get },
+ { :controller => "site", :action => "index" }
+ )
+ assert_recognizes(
+ { :controller => "site", :action => "index" },
+ { :path => "/index.html", :method => :get }
+ )
+ assert_routing(
+ { :path => "/edit", :method => :get },
+ { :controller => "site", :action => "edit" }
+ )
+ assert_recognizes(
+ { :controller => "site", :action => "edit", :format => "html" },
+ { :path => "/edit.html", :method => :get }
+ )
+ assert_routing(
+ { :path => "/copyright", :method => :get },
+ { :controller => "site", :action => "copyright" }
+ )
+ assert_routing(
+ { :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" }
+ )
+ assert_routing(
+ { :path => "/key", :method => :post },
+ { :controller => "site", :action => "key" }
+ )
+ assert_routing(
+ { :path => "/go/shortcode", :method => :get },
+ { :controller => "site", :action => "permalink", :code => "shortcode" }
+ )
+ end
+
## Lets check that we can get all the pages without any errors
# Get the index
def test_index
require File.dirname(__FILE__) + '/../test_helper'
class SwfControllerTest < ActionController::TestCase
- # Replace this with your real tests.
- def test_truth
- assert true
+ ##
+ # test all routes which lead to this controller
+ def test_routes
+ assert_routing(
+ { :path => "/api/0.6/swf/trackpoints", :method => :get },
+ { :controller => "swf", :action => "trackpoints" }
+ )
end
end
fixtures :users, :gpx_files
set_fixture_class :gpx_files => 'Trace'
+ ##
+ # test all routes which lead to this controller
+ def test_routes
+ assert_routing(
+ { :path => "/api/0.6/gpx/create", :method => :post },
+ { :controller => "trace", :action => "api_create" }
+ )
+ assert_routing(
+ { :path => "/api/0.6/gpx/1", :method => :get },
+ { :controller => "trace", :action => "api_read", :id => "1" }
+ )
+ assert_routing(
+ { :path => "/api/0.6/gpx/1", :method => :put },
+ { :controller => "trace", :action => "api_update", :id => "1" }
+ )
+ assert_routing(
+ { :path => "/api/0.6/gpx/1", :method => :delete },
+ { :controller => "trace", :action => "api_delete", :id => "1" }
+ )
+ assert_recognizes(
+ { :controller => "trace", :action => "api_read", :id => "1" },
+ { :path => "/api/0.6/gpx/1/details", :method => :get }
+ )
+ assert_routing(
+ { :path => "/api/0.6/gpx/1/data", :method => :get },
+ { :controller => "trace", :action => "api_data", :id => "1" }
+ )
+ assert_routing(
+ { :path => "/api/0.6/gpx/1/data.xml", :method => :get },
+ { :controller => "trace", :action => "api_data", :id => "1", :format => "xml" }
+ )
+
+ assert_routing(
+ { :path => "/traces", :method => :get },
+ { :controller => "trace", :action => "list" }
+ )
+ assert_routing(
+ { :path => "/traces/page/1", :method => :get },
+ { :controller => "trace", :action => "list", :page => "1" }
+ )
+ assert_routing(
+ { :path => "/traces/tag/tagname", :method => :get },
+ { :controller => "trace", :action => "list", :tag => "tagname" }
+ )
+ assert_routing(
+ { :path => "/traces/tag/tagname/page/1", :method => :get },
+ { :controller => "trace", :action => "list", :tag => "tagname", :page => "1" }
+ )
+ assert_routing(
+ { :path => "/user/username/traces", :method => :get },
+ { :controller => "trace", :action => "list", :display_name => "username" }
+ )
+ assert_routing(
+ { :path => "/user/username/traces/page/1", :method => :get },
+ { :controller => "trace", :action => "list", :display_name => "username", :page => "1" }
+ )
+ assert_routing(
+ { :path => "/user/username/traces/tag/tagname", :method => :get },
+ { :controller => "trace", :action => "list", :display_name => "username", :tag => "tagname" }
+ )
+ assert_routing(
+ { :path => "/user/username/traces/tag/tagname/page/1", :method => :get },
+ { :controller => "trace", :action => "list", :display_name => "username", :tag => "tagname", :page => "1" }
+ )
+
+ assert_routing(
+ { :path => "/traces/mine", :method => :get },
+ { :controller => "trace", :action => "mine" }
+ )
+ assert_routing(
+ { :path => "/traces/mine/page/1", :method => :get },
+ { :controller => "trace", :action => "mine", :page => "1" }
+ )
+ assert_routing(
+ { :path => "/traces/mine/tag/tagname", :method => :get },
+ { :controller => "trace", :action => "mine", :tag => "tagname" }
+ )
+ assert_routing(
+ { :path => "/traces/mine/tag/tagname/page/1", :method => :get },
+ { :controller => "trace", :action => "mine", :tag => "tagname", :page => "1" }
+ )
+
+ assert_routing(
+ { :path => "/traces/rss", :method => :get },
+ { :controller => "trace", :action => "georss" }
+ )
+ assert_routing(
+ { :path => "/traces/tag/tagname/rss", :method => :get },
+ { :controller => "trace", :action => "georss", :tag => "tagname" }
+ )
+ assert_routing(
+ { :path => "/user/username/traces/rss", :method => :get },
+ { :controller => "trace", :action => "georss", :display_name => "username" }
+ )
+ assert_routing(
+ { :path => "/user/username/traces/tag/tagname/rss", :method => :get },
+ { :controller => "trace", :action => "georss", :display_name => "username", :tag => "tagname" }
+ )
+
+ assert_routing(
+ { :path => "/user/username/traces/1", :method => :get },
+ { :controller => "trace", :action => "view", :display_name => "username", :id => "1" }
+ )
+ assert_routing(
+ { :path => "/user/username/traces/1/picture", :method => :get },
+ { :controller => "trace", :action => "picture", :display_name => "username", :id => "1" }
+ )
+ assert_routing(
+ { :path => "/user/username/traces/1/icon", :method => :get },
+ { :controller => "trace", :action => "icon", :display_name => "username", :id => "1" }
+ )
+
+ assert_routing(
+ { :path => "/trace/create", :method => :get },
+ { :controller => "trace", :action => "create" }
+ )
+ assert_routing(
+ { :path => "/trace/create", :method => :post },
+ { :controller => "trace", :action => "create" }
+ )
+ assert_routing(
+ { :path => "/trace/1/data", :method => :get },
+ { :controller => "trace", :action => "data", :id => "1" }
+ )
+ assert_routing(
+ { :path => "/trace/1/data.xml", :method => :get },
+ { :controller => "trace", :action => "data", :id => "1", :format => "xml" }
+ )
+ assert_routing(
+ { :path => "/trace/1/edit", :method => :get },
+ { :controller => "trace", :action => "edit", :id => "1" }
+ )
+ assert_routing(
+ { :path => "/trace/1/edit", :method => :post },
+ { :controller => "trace", :action => "edit", :id => "1" }
+ )
+ assert_routing(
+ { :path => "/trace/1/edit", :method => :put },
+ { :controller => "trace", :action => "edit", :id => "1" }
+ )
+ assert_routing(
+ { :path => "/trace/1/delete", :method => :post },
+ { :controller => "trace", :action => "delete", :id => "1" }
+ )
+ end
+
# Check that the list of changesets is displayed
def test_list
get :list
--- /dev/null
+require File.dirname(__FILE__) + '/../test_helper'
+
+class UserBlocksControllerTest < ActionController::TestCase
+ ##
+ # test all routes which lead to this controller
+ def test_routes
+ assert_routing(
+ { :path => "/blocks/new/username", :method => :get },
+ { :controller => "user_blocks", :action => "new", :display_name => "username" }
+ )
+
+ assert_routing(
+ { :path => "/user_blocks", :method => :get },
+ { :controller => "user_blocks", :action => "index" }
+ )
+ assert_routing(
+ { :path => "/user_blocks/new", :method => :get },
+ { :controller => "user_blocks", :action => "new" }
+ )
+ assert_routing(
+ { :path => "/user_blocks", :method => :post },
+ { :controller => "user_blocks", :action => "create" }
+ )
+ assert_routing(
+ { :path => "/user_blocks/1", :method => :get },
+ { :controller => "user_blocks", :action => "show", :id => "1" }
+ )
+ assert_routing(
+ { :path => "/user_blocks/1/edit", :method => :get },
+ { :controller => "user_blocks", :action => "edit", :id => "1" }
+ )
+ assert_routing(
+ { :path => "/user_blocks/1", :method => :put },
+ { :controller => "user_blocks", :action => "update", :id => "1" }
+ )
+ assert_routing(
+ { :path => "/user_blocks/1", :method => :delete },
+ { :controller => "user_blocks", :action => "destroy", :id => "1" }
+ )
+ assert_routing(
+ { :path => "/blocks/1/revoke", :method => :get },
+ { :controller => "user_blocks", :action => "revoke", :id => "1" }
+ )
+ assert_routing(
+ { :path => "/blocks/1/revoke", :method => :post },
+ { :controller => "user_blocks", :action => "revoke", :id => "1" }
+ )
+
+ assert_routing(
+ { :path => "/user/username/blocks", :method => :get },
+ { :controller => "user_blocks", :action => "blocks_on", :display_name => "username" }
+ )
+ assert_routing(
+ { :path => "/user/username/blocks_by", :method => :get },
+ { :controller => "user_blocks", :action => "blocks_by", :display_name => "username" }
+ )
+ end
+end
class UserControllerTest < ActionController::TestCase
fixtures :users
+ ##
+ # test all routes which lead to this controller
+ def test_routes
+ assert_routing(
+ { :path => "/api/0.6/user/details", :method => :get },
+ { :controller => "user", :action => "api_details" }
+ )
+ assert_routing(
+ { :path => "/api/0.6/user/gpx_files", :method => :get },
+ { :controller => "user", :action => "api_gpx_files" }
+ )
+
+ assert_routing(
+ { :path => "/login", :method => :get },
+ { :controller => "user", :action => "login" }
+ )
+ assert_routing(
+ { :path => "/login", :method => :post },
+ { :controller => "user", :action => "login" }
+ )
+ assert_recognizes(
+ { :controller => "user", :action => "login", :format => "html" },
+ { :path => "/login.html", :method => :get }
+ )
+
+ assert_routing(
+ { :path => "/logout", :method => :get },
+ { :controller => "user", :action => "logout" }
+ )
+ assert_routing(
+ { :path => "/logout", :method => :post },
+ { :controller => "user", :action => "logout" }
+ )
+ assert_recognizes(
+ { :controller => "user", :action => "logout", :format => "html" },
+ { :path => "/logout.html", :method => :get }
+ )
+
+ assert_routing(
+ { :path => "/user/new", :method => :get },
+ { :controller => "user", :action => "new" }
+ )
+ assert_recognizes(
+ { :controller => "user", :action => "new" },
+ { :path => "/create-account.html", :method => :get }
+ )
+
+ assert_routing(
+ { :path => "/user/terms", :method => :get },
+ { :controller => "user", :action => "terms" }
+ )
+ assert_routing(
+ { :path => "/user/terms", :method => :post },
+ { :controller => "user", :action => "terms" }
+ )
+
+ assert_routing(
+ { :path => "/user/save", :method => :post },
+ { :controller => "user", :action => "save" }
+ )
+
+ assert_routing(
+ { :path => "/user/username/confirm", :method => :get },
+ { :controller => "user", :action => "confirm", :display_name => "username" }
+ )
+ assert_routing(
+ { :path => "/user/username/confirm", :method => :post },
+ { :controller => "user", :action => "confirm", :display_name => "username" }
+ )
+ assert_routing(
+ { :path => "/user/username/confirm/resend", :method => :get },
+ { :controller => "user", :action => "confirm_resend", :display_name => "username" }
+ )
+
+ assert_routing(
+ { :path => "/user/confirm", :method => :get },
+ { :controller => "user", :action => "confirm" }
+ )
+ assert_routing(
+ { :path => "/user/confirm", :method => :post },
+ { :controller => "user", :action => "confirm" }
+ )
+ assert_routing(
+ { :path => "/user/confirm-email", :method => :get },
+ { :controller => "user", :action => "confirm_email" }
+ )
+ assert_routing(
+ { :path => "/user/confirm-email", :method => :post },
+ { :controller => "user", :action => "confirm_email" }
+ )
+
+ assert_routing(
+ { :path => "/user/go_public", :method => :post },
+ { :controller => "user", :action => "go_public" }
+ )
+
+ assert_routing(
+ { :path => "/user/forgot-password", :method => :get },
+ { :controller => "user", :action => "lost_password" }
+ )
+ assert_routing(
+ { :path => "/user/forgot-password", :method => :post },
+ { :controller => "user", :action => "lost_password" }
+ )
+ assert_recognizes(
+ { :controller => "user", :action => "lost_password" },
+ { :path => "/forgot-password.html", :method => :get }
+ )
+ assert_routing(
+ { :path => "/user/reset-password", :method => :get },
+ { :controller => "user", :action => "reset_password" }
+ )
+ assert_routing(
+ { :path => "/user/reset-password", :method => :post },
+ { :controller => "user", :action => "reset_password" }
+ )
+
+ assert_routing(
+ { :path => "/user/suspended", :method => :get },
+ { :controller => "user", :action => "suspended" }
+ )
+
+ assert_routing(
+ { :path => "/user/username", :method => :get },
+ { :controller => "user", :action => "view", :display_name => "username" }
+ )
+
+ assert_routing(
+ { :path => "/user/username/account", :method => :get },
+ { :controller => "user", :action => "account", :display_name => "username" }
+ )
+ assert_routing(
+ { :path => "/user/username/account", :method => :post },
+ { :controller => "user", :action => "account", :display_name => "username" }
+ )
+
+ assert_routing(
+ { :path => "/user/username/make_friend", :method => :get },
+ { :controller => "user", :action => "make_friend", :display_name => "username" }
+ )
+ assert_routing(
+ { :path => "/user/username/remove_friend", :method => :get },
+ { :controller => "user", :action => "remove_friend", :display_name => "username" }
+ )
+
+ assert_routing(
+ { :path => "/user/username/set_status", :method => :get },
+ { :controller => "user", :action => "set_status", :display_name => "username" }
+ )
+ assert_routing(
+ { :path => "/user/username/delete", :method => :get },
+ { :controller => "user", :action => "delete", :display_name => "username" }
+ )
+
+ assert_routing(
+ { :path => "/users", :method => :get },
+ { :controller => "user", :action => "list" }
+ )
+ assert_routing(
+ { :path => "/users", :method => :post },
+ { :controller => "user", :action => "list" }
+ )
+ assert_routing(
+ { :path => "/users/status", :method => :get },
+ { :controller => "user", :action => "list", :status => "status" }
+ )
+ assert_routing(
+ { :path => "/users/status", :method => :post },
+ { :controller => "user", :action => "list", :status => "status" }
+ )
+ end
+
# The user creation page loads
def test_user_create_view
get :new
class UserPreferenceControllerTest < ActionController::TestCase
fixtures :users, :user_preferences
-
+
+ ##
+ # test all routes which lead to this controller
+ def test_routes
+ assert_routing(
+ { :path => "/api/0.6/user/preferences", :method => :get },
+ { :controller => "user_preference", :action => "read" }
+ )
+ assert_routing(
+ { :path => "/api/0.6/user/preferences", :method => :put },
+ { :controller => "user_preference", :action => "update" }
+ )
+ assert_routing(
+ { :path => "/api/0.6/user/preferences/key", :method => :get },
+ { :controller => "user_preference", :action => "read_one", :preference_key => "key" }
+ )
+ assert_routing(
+ { :path => "/api/0.6/user/preferences/key", :method => :put },
+ { :controller => "user_preference", :action => "update_one", :preference_key => "key" }
+ )
+ assert_routing(
+ { :path => "/api/0.6/user/preferences/key", :method => :delete },
+ { :controller => "user_preference", :action => "delete_one", :preference_key => "key" }
+ )
+ end
+
def test_read
# first try without auth
get :read
end
end
end
-
end
--- /dev/null
+require File.dirname(__FILE__) + '/../test_helper'
+
+class UserRolesControllerTest < ActionController::TestCase
+ ##
+ # test all routes which lead to this controller
+ def test_routes
+ assert_routing(
+ { :path => "/user/username/role/rolename/grant", :method => :get },
+ { :controller => "user_roles", :action => "grant", :display_name => "username", :role => "rolename" }
+ )
+ assert_routing(
+ { :path => "/user/username/role/rolename/grant", :method => :post },
+ { :controller => "user_roles", :action => "grant", :display_name => "username", :role => "rolename" }
+ )
+ assert_routing(
+ { :path => "/user/username/role/rolename/revoke", :method => :get },
+ { :controller => "user_roles", :action => "revoke", :display_name => "username", :role => "rolename" }
+ )
+ assert_routing(
+ { :path => "/user/username/role/rolename/revoke", :method => :post },
+ { :controller => "user_roles", :action => "revoke", :display_name => "username", :role => "rolename" }
+ )
+ end
+end
class WayControllerTest < ActionController::TestCase
api_fixtures
+ ##
+ # test all routes which lead to this controller
+ def test_routes
+ assert_routing(
+ { :path => "/api/0.6/way/create", :method => :put },
+ { :controller => "way", :action => "create" }
+ )
+ assert_routing(
+ { :path => "/api/0.6/way/1/full", :method => :get },
+ { :controller => "way", :action => "full", :id => "1" }
+ )
+ assert_routing(
+ { :path => "/api/0.6/way/1", :method => :get },
+ { :controller => "way", :action => "read", :id => "1" }
+ )
+ assert_routing(
+ { :path => "/api/0.6/way/1", :method => :put },
+ { :controller => "way", :action => "update", :id => "1" }
+ )
+ assert_routing(
+ { :path => "/api/0.6/way/1", :method => :delete },
+ { :controller => "way", :action => "delete", :id => "1" }
+ )
+ assert_routing(
+ { :path => "/api/0.6/ways", :method => :get },
+ { :controller => "way", :action => "ways" }
+ )
+ end
+
# -------------------------------------
# Test reading ways.
# -------------------------------------
require File.dirname(__FILE__) + '/../test_helper'
-class UserRolesControllerTest < ActionController::IntegrationTest
+class UserRolesTest < ActionController::IntegrationTest
fixtures :users, :user_roles
test "grant" do
assert_response :success
# don't agree to the terms, but hit decline
- post "/user/#{user.display_name}/save", {'decline' => 'decline', 'referer' => '/'}
+ post "/user/save", {'decline' => 'decline', 'referer' => '/'}
assert_redirected_to "/"
follow_redirect!