From: Andy Allan Date: Wed, 29 Aug 2018 09:43:34 +0000 (+0800) Subject: Rename traces#view to traces#show X-Git-Tag: live~3485^2~3 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/16fef14b61f4cf5222484b7c315ed05c661cbcef Rename traces#view to traces#show --- diff --git a/app/controllers/api_controller.rb b/app/controllers/api_controller.rb index 021ada0cd..81b8bca53 100644 --- a/app/controllers/api_controller.rb +++ b/app/controllers/api_controller.rb @@ -67,7 +67,7 @@ class ApiController < ApplicationController 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 => "traces", :action => "view", :display_name => gpx_file.user.display_name, :id => gpx_file.id)) + track << (XML::Node.new("url") << url_for(:controller => "traces", :action => "show", :display_name => gpx_file.user.display_name, :id => gpx_file.id)) end else # use the anonymous track segment if the user hasn't allowed diff --git a/app/controllers/traces_controller.rb b/app/controllers/traces_controller.rb index 31ce88ec3..b6982894d 100644 --- a/app/controllers/traces_controller.rb +++ b/app/controllers/traces_controller.rb @@ -12,7 +12,7 @@ class TracesController < ApplicationController 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] @@ -89,7 +89,7 @@ class TracesController < ApplicationController redirect_to :action => :list, :display_name => current_user.display_name end - def view + def show @trace = Trace.find(params[:id]) if @trace && @trace.visible? && @@ -189,7 +189,7 @@ class TracesController < ApplicationController 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" diff --git a/app/views/traces/_trace.html.erb b/app/views/traces/_trace.html.erb index 9b8b16a63..b81e19025 100644 --- a/app/views/traces/_trace.html.erb +++ b/app/views/traces/_trace.html.erb @@ -3,13 +3,13 @@ <% if STATUS != :gpx_offline %> <% if trace.inserted %> - + <% else %> <%= t '.pending' %> <% end %> <% end %> - <%= link_to trace.name, { :controller => 'traces', :action => 'view', :display_name => trace.user.display_name, :id => trace.id } %> + <%= link_to trace.name, { :controller => 'traces', :action => 'show', :display_name => trace.user.display_name, :id => trace.id } %> ... <% if trace.inserted %> (<%= t '.count_points', :count => trace.size.to_s.gsub(/(\d)(?=(\d{3})+$)/,'\1,') %>) diff --git a/app/views/traces/view.html.erb b/app/views/traces/show.html.erb similarity index 100% rename from app/views/traces/view.html.erb rename to app/views/traces/show.html.erb diff --git a/config/locales/en.yml b/config/locales/en.yml index 5854df0d9..af54e0890 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1726,7 +1726,7 @@ en: updated: Trace updated trace_optionals: tags: "Tags" - view: + show: title: "Viewing trace %{name}" heading: "Viewing trace %{name}" pending: "PENDING" diff --git a/config/routes.rb b/config/routes.rb index 4b126c752..410db3c25 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -195,7 +195,7 @@ OpenStreetMap::Application.routes.draw do get "/user/:display_name/traces" => "traces#list" get "/user/:display_name/traces/tag/:tag/rss" => "traces#georss", :defaults => { :format => :rss } get "/user/:display_name/traces/rss" => "traces#georss", :defaults => { :format => :rss } - get "/user/:display_name/traces/:id" => "traces#view" + get "/user/:display_name/traces/:id" => "traces#show" get "/user/:display_name/traces/:id/picture" => "traces#picture" get "/user/:display_name/traces/:id/icon" => "traces#icon" get "/traces/tag/:tag/page/:page" => "traces#list", :page => /[1-9][0-9]*/ diff --git a/test/controllers/traces_controller_test.rb b/test/controllers/traces_controller_test.rb index 5a5b8631b..29e359956 100644 --- a/test/controllers/traces_controller_test.rb +++ b/test/controllers/traces_controller_test.rb @@ -123,7 +123,7 @@ class TracesControllerTest < ActionController::TestCase 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 }, @@ -299,53 +299,53 @@ class TracesControllerTest < ActionController::TestCase 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 @@ -640,7 +640,7 @@ class TracesControllerTest < ActionController::TestCase # 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 @@ -1029,9 +1029,9 @@ class TracesControllerTest < ActionController::TestCase 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)} /