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.
This commit is contained in:
parent
1997f1f662
commit
8cd02f4136
4 changed files with 10 additions and 10 deletions
|
@ -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 %>
|
||||
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue