From: Tom Hughes Date: Thu, 4 Feb 2010 15:48:40 +0000 (+0000) Subject: Drop the username from the "new diary entry" link to avoid problems X-Git-Tag: live~6341^2~4 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/8cd02f413690abfb499e02a5824bd46c1504b86f?ds=sidebyside Drop the username from the "new diary entry" link to avoid problems with caching - we don't need it as we know who the logged in user is when a diary posting is made. --- diff --git a/app/views/diary_entry/list.html.erb b/app/views/diary_entry/list.html.erb index 68c8c1266..0bc17d2bb 100644 --- a/app/views/diary_entry/list.html.erb +++ b/app/views/diary_entry/list.html.erb @@ -7,11 +7,11 @@ <% if @this_user %> <% if @user == @this_user %> - <%= link_to image_tag("new.png", :border=>0) + t('diary_entry.list.new'), {:controller => 'diary_entry', :action => 'new', :display_name => @user.display_name}, {:title => t('diary_entry.list.new_title')} %> + <%= link_to image_tag("new.png", :border=>0) + t('diary_entry.list.new'), {:controller => 'diary_entry', :action => 'new'}, {:title => t('diary_entry.list.new_title')} %> <% end %> <% else %> <% if @user %> - <%= link_to image_tag("new.png", :border=>0) + t('diary_entry.list.new'), {:controller => 'diary_entry', :action => 'new', :display_name => @user.display_name}, {:title => t('diary_entry.list.new_title')} %> + <%= link_to image_tag("new.png", :border=>0) + t('diary_entry.list.new'), {:controller => 'diary_entry', :action => 'new'}, {:title => t('diary_entry.list.new_title')} %> <% end %> <% end %> diff --git a/config/routes.rb b/config/routes.rb index 9d1da0c97..90364c395 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -154,7 +154,6 @@ ActionController::Routing::Routes.draw do |map| map.connect '/user/:display_name/diary/:id', :controller => 'diary_entry', :action => 'view', :id => /\d+/ map.connect '/user/:display_name/diary/:id/newcomment', :controller => 'diary_entry', :action => 'comment', :id => /\d+/ map.connect '/user/:display_name/diary/rss', :controller => 'diary_entry', :action => 'rss' - map.connect '/user/:display_name/diary/new', :controller => 'diary_entry', :action => 'new' map.connect '/user/:display_name/diary/:id/edit', :controller => 'diary_entry', :action => 'edit', :id => /\d+/ map.connect '/user/:display_name/diary/:id/hide', :controller => 'diary_entry', :action => 'hide', :id => /\d+/ map.connect '/user/:display_name/diary/:id/hidecomment/:comment', :controller => 'diary_entry', :action => 'hidecomment', :id => /\d+/, :comment => /\d+/ @@ -165,11 +164,12 @@ ActionController::Routing::Routes.draw do |map| map.connect '/user/:display_name/hide', :controller => 'user', :action => 'hide' map.connect '/user/:display_name/unhide', :controller => 'user', :action => 'unhide' map.connect '/user/:display_name/delete', :controller => 'user', :action => 'delete' + map.connect '/diary/new', :controller => 'diary_entry', :action => 'new' map.connect '/diary', :controller => 'diary_entry', :action => 'list' map.connect '/diary/rss', :controller => 'diary_entry', :action => 'rss' map.connect '/diary/:language', :controller => 'diary_entry', :action => 'list' map.connect '/diary/:language/rss', :controller => 'diary_entry', :action => 'rss' - + # test pages map.connect '/test/populate/:table/:from/:count', :controller => 'test', :action => 'populate' diff --git a/test/functional/diary_entry_controller_test.rb b/test/functional/diary_entry_controller_test.rb index 1f3492ae9..53d9716b3 100644 --- a/test/functional/diary_entry_controller_test.rb +++ b/test/functional/diary_entry_controller_test.rb @@ -6,7 +6,7 @@ class DiaryEntryControllerTest < ActionController::TestCase def test_showing_new_diary_entry get :new assert_response :redirect - assert_redirected_to :controller => :user, :action => "login", :referer => "/diary_entry/new" + assert_redirected_to :controller => :user, :action => "login", :referer => "/diary/new" # Now pretend to login by using the session hash, with the # id of the person we want to login as through session(:user)=user.id get(:new, nil, {'user' => users(:normal_user).id}) @@ -23,7 +23,7 @@ class DiaryEntryControllerTest < ActionController::TestCase assert_select "h1", "New Diary Entry", :count => 1 # We don't care about the layout, we just care about the form fields # that are available - assert_select "form[action='/diary_entry/new']", :count => 1 do + assert_select "form[action='/diary/new']", :count => 1 do assert_select "input[id=diary_entry_title][name='diary_entry[title]']", :count => 1 assert_select "textarea#diary_entry_body[name='diary_entry[body]']", :count => 1 assert_select "input#latitude[name='diary_entry[latitude]'][type=text]", :count => 1 diff --git a/test/integration/user_diaries_test.rb b/test/integration/user_diaries_test.rb index 8fcc694e9..b686fbac9 100644 --- a/test/integration/user_diaries_test.rb +++ b/test/integration/user_diaries_test.rb @@ -6,19 +6,19 @@ class UserDiariesTest < ActionController::IntegrationTest # Test the creation of a diary entry, making sure that you are redirected to # login page when not logged in def test_showing_create_diary_entry - get_via_redirect '/user/test/diary/new' + get_via_redirect '/diary/new' # We should now be at the login page assert_response :success assert_template 'user/login' # We can now login - post '/login', {'user[email]' => "test@openstreetmap.org", 'user[password]' => "test", :referer => '/user/test/diary/new'} + post '/login', {'user[email]' => "test@openstreetmap.org", 'user[password]' => "test", :referer => '/diary/new'} assert_response :redirect #print @response.body # Check that there is some payload alerting the user to the redirect # and allowing them to get to the page they are being directed to assert_select "html:root" do assert_select "body" do - assert_select "a[href='http://www.example.com/user/test/diary/new']" + assert_select "a[href='http://www.example.com/diary/new']" end end # Required due to a bug in the rails testing framework @@ -40,7 +40,7 @@ class UserDiariesTest < ActionController::IntegrationTest assert_select "body" do assert_select "div#content" do assert_select "h1", "New Diary Entry" - assert_select "form[action='/user/#{users(:normal_user).display_name}/diary/new']" do + assert_select "form[action='/diary/new']" do assert_select "input[id=diary_entry_title]" end end