before_action :check_api_writable, :only => [:api_create, :api_update, :api_delete]
before_action :require_allow_read_gpx, :only => [:api_read, :api_data]
before_action :require_allow_write_gpx, :only => [:api_create, :api_update, :api_delete]
- before_action :offline_warning, :only => [:mine, :view]
+ before_action :offline_warning, :only => [:mine, :show]
before_action :offline_redirect, :only => [:new, :create, :edit, :delete, :data, :api_create, :api_delete, :api_data]
around_action :api_call_handle_error, :only => [:api_create, :api_read, :api_update, :api_delete, :api_data]
redirect_to :action => :list, :display_name => current_user.display_name
end
- def view
+ def show
@trace = Trace.find(params[:id])
if @trace && @trace.visible? &&
head :forbidden
elsif @trace.update(trace_params)
flash[:notice] = t ".updated"
- redirect_to :action => "view", :display_name => current_user.display_name
+ redirect_to :action => "show", :display_name => current_user.display_name
else
@title = t ".title", :name => @trace.name
render :action => "edit"
<td class="<%= cl %>">
<% if STATUS != :gpx_offline %>
<% if trace.inserted %>
- <a href="<%= url_for :controller => 'traces', :action => 'view', :id => trace.id, :display_name => trace.user.display_name %>"><img src="<%= url_for :controller => 'traces', :action => 'icon', :id => trace.id, :display_name => trace.user.display_name %>" border="0" alt="" /></a>
+ <a href="<%= url_for :controller => 'traces', :action => 'show', :id => trace.id, :display_name => trace.user.display_name %>"><img src="<%= url_for :controller => 'traces', :action => 'icon', :id => trace.id, :display_name => trace.user.display_name %>" border="0" alt="" /></a>
<% else %>
<span class="trace_pending"><%= t '.pending' %></span>
<% end %>
<% end %>
</td>
- <td class="<%= cl %>"><%= link_to trace.name, { :controller => 'traces', :action => 'view', :display_name => trace.user.display_name, :id => trace.id } %>
+ <td class="<%= cl %>"><%= link_to trace.name, { :controller => 'traces', :action => 'show', :display_name => trace.user.display_name, :id => trace.id } %>
<span class="trace_summary" title="<%= trace.timestamp %>"> ...
<% if trace.inserted %>
(<%= t '.count_points', :count => trace.size.to_s.gsub(/(\d)(?=(\d{3})+$)/,'\1,') %>)
assert_routing(
{ :path => "/user/username/traces/1", :method => :get },
- { :controller => "traces", :action => "view", :display_name => "username", :id => "1" }
+ { :controller => "traces", :action => "show", :display_name => "username", :id => "1" }
)
assert_routing(
{ :path => "/user/username/traces/1/picture", :method => :get },
check_trace_feed user.traces.tagged("Birmingham").visible_to_all
end
- # Test viewing a trace
- def test_view
+ # Test showing a trace
+ def test_show
public_trace_file = create(:trace, :visibility => "public")
# First with no auth, which should work since the trace is public
- get :view, :params => { :display_name => public_trace_file.user.display_name, :id => public_trace_file.id }
- check_trace_view public_trace_file
+ get :show, :params => { :display_name => public_trace_file.user.display_name, :id => public_trace_file.id }
+ check_trace_show public_trace_file
# Now with some other user, which should work since the trace is public
- get :view, :params => { :display_name => public_trace_file.user.display_name, :id => public_trace_file.id }, :session => { :user => create(:user) }
- check_trace_view public_trace_file
+ get :show, :params => { :display_name => public_trace_file.user.display_name, :id => public_trace_file.id }, :session => { :user => create(:user) }
+ check_trace_show public_trace_file
# And finally we should be able to do it with the owner of the trace
- get :view, :params => { :display_name => public_trace_file.user.display_name, :id => public_trace_file.id }, :session => { :user => public_trace_file.user }
- check_trace_view public_trace_file
+ get :show, :params => { :display_name => public_trace_file.user.display_name, :id => public_trace_file.id }, :session => { :user => public_trace_file.user }
+ check_trace_show public_trace_file
end
# Check an anonymous trace can't be viewed by another user
- def test_view_anon
+ def test_show_anon
anon_trace_file = create(:trace, :visibility => "private")
# First with no auth
- get :view, :params => { :display_name => anon_trace_file.user.display_name, :id => anon_trace_file.id }
+ get :show, :params => { :display_name => anon_trace_file.user.display_name, :id => anon_trace_file.id }
assert_response :redirect
assert_redirected_to :action => :list
# Now with some other user, which should not work since the trace is anon
- get :view, :params => { :display_name => anon_trace_file.user.display_name, :id => anon_trace_file.id }, :session => { :user => create(:user) }
+ get :show, :params => { :display_name => anon_trace_file.user.display_name, :id => anon_trace_file.id }, :session => { :user => create(:user) }
assert_response :redirect
assert_redirected_to :action => :list
# And finally we should be able to do it with the owner of the trace
- get :view, :params => { :display_name => anon_trace_file.user.display_name, :id => anon_trace_file.id }, :session => { :user => anon_trace_file.user }
- check_trace_view anon_trace_file
+ get :show, :params => { :display_name => anon_trace_file.user.display_name, :id => anon_trace_file.id }, :session => { :user => anon_trace_file.user }
+ check_trace_show anon_trace_file
end
- # Test viewing a trace that doesn't exist
- def test_view_not_found
+ # Test showing a trace that doesn't exist
+ def test_show_not_found
deleted_trace_file = create(:trace, :deleted)
# First with a trace that has never existed
- get :view, :params => { :display_name => create(:user).display_name, :id => 0 }
+ get :show, :params => { :display_name => create(:user).display_name, :id => 0 }
assert_response :redirect
assert_redirected_to :action => :list
# Now with a trace that has been deleted
- get :view, :params => { :display_name => deleted_trace_file.user.display_name, :id => deleted_trace_file.id }, :session => { :user => deleted_trace_file.user }
+ get :show, :params => { :display_name => deleted_trace_file.user.display_name, :id => deleted_trace_file.id }, :session => { :user => deleted_trace_file.user }
assert_response :redirect
assert_redirected_to :action => :list
end
# Finally with a trace that we are allowed to edit
put :update, :params => { :display_name => public_trace_file.user.display_name, :id => public_trace_file.id, :trace => new_details }, :session => { :user => public_trace_file.user }
assert_response :redirect
- assert_redirected_to :action => :view, :display_name => public_trace_file.user.display_name
+ assert_redirected_to :action => :show, :display_name => public_trace_file.user.display_name
trace = Trace.find(public_trace_file.id)
assert_equal new_details[:description], trace.description
assert_equal new_details[:tagstring], trace.tagstring
end
end
- def check_trace_view(trace)
+ def check_trace_show(trace)
assert_response :success
- assert_template "view"
+ assert_template "show"
assert_select "table", :count => 1 do
assert_select "td", /^#{Regexp.quote(trace.name)} /