]> git.openstreetmap.org Git - rails.git/commitdiff
Drop the username from the "new diary entry" link to avoid problems
authorTom Hughes <tom@compton.nu>
Thu, 4 Feb 2010 15:48:40 +0000 (15:48 +0000)
committerTom Hughes <tom@compton.nu>
Thu, 4 Feb 2010 15:48:40 +0000 (15:48 +0000)
with caching - we don't need it as we know who the logged in user is
when a diary posting is made.

app/views/diary_entry/list.html.erb
config/routes.rb
test/functional/diary_entry_controller_test.rb
test/integration/user_diaries_test.rb

index 68c8c12668bb7134fee58e6430fd4e208b9522ab..0bc17d2bb14324f030b9824c87bafb57bca78d5d 100644 (file)
@@ -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 %>
 
index 9d1da0c97dc21335774778805db53ca62d9085a4..90364c3955cf2427ee1ac1b6f90492876b4933b5 100644 (file)
@@ -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'
index 1f3492ae98a1236e4d1e7f0cb474f352fa9400d9..53d9716b3ebc8870cd72165d713a1252aa161936 100644 (file)
@@ -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
index 8fcc694e9196150d2eeac8cdc07cb84c030d6309..b686fbac9132d858d6165c3ef33127418efee62a 100644 (file)
@@ -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