translating the listing of diary entries. Adding some initial tests for checking that you don't get any errors in any locale, when listing the diary entries. Don't yet check for missing translations through an assert_select, .., :count => 0.

This commit is contained in:
Shaun McDonald 2009-05-27 15:06:25 +00:00
parent 544353a8d9
commit 6ba51da46e
4 changed files with 30 additions and 14 deletions

View file

@ -7,27 +7,27 @@
<% if @this_user %>
<% if @user == @this_user %>
<%= link_to image_tag("new.png", :border=>0) + 'New diary entry', {:controller => 'diary_entry', :action => 'new', :display_name => @user.display_name}, {:title => 'Compose a new entry in your user diary'} %>
<%= 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')} %>
<% end %>
<% else %>
<% if @user %>
<%= link_to image_tag("new.png", :border=>0) + 'New diary entry', {:controller => 'diary_entry', :action => 'new', :display_name => @user.display_name}, {:title => 'Compose a new entry in your user diary'} %>
<%= 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')} %>
<% end %>
<% end %>
<% if @entries.empty? %>
<p>No diary entries</p>
<p><%= t 'diary_entry.list.no_entries' %></p>
<% else %>
<p>Recent diary entries:</p>
<p><%= t 'diary_entry.list.recent_entries' %></p>
<hr />
<%= render :partial => 'diary_entry', :collection => @entries %>
<%= link_to "Older Entries", { :page => @entry_pages.current.next } if @entry_pages.current.next %>
<%= link_to t('diary_entry.list.older_entries'), { :page => @entry_pages.current.next } if @entry_pages.current.next %>
<% if @entry_pages.current.next and @entry_pages.current.previous %>|<% end %>
<%= link_to "Newer Entries", { :page => @entry_pages.current.previous } if @entry_pages.current.previous %>
<%= link_to t('diary_entry.list.newer_entries'), { :page => @entry_pages.current.previous } if @entry_pages.current.previous %>
<br />
<% end %>

View file

@ -4,7 +4,13 @@ en:
edit: Edit
coordinates: "Coordinates:"
diary_entry:
new: New Diary Entry
list:
new: New Diary Entry
new_title: Compose a new entry in your user diary
no_entries: No diary entries
recent_entries: "Recent diary entries: "
older_entries: Older Entries
newer_entries: Newer Entries
comment_link: Comment on this entry
reply_link: Reply to this entry
comment_count:

View file

@ -153,15 +153,21 @@ class DiaryEntryControllerTest < ActionController::TestCase
end
# Check that you can get the expected response and template for all available languages
# Should test that there are no <span class="translation_missing">
def test_listing_diary_entries
get :list
assert_response :success
assert_template 'list'
I18n.available_locales.each do |locale|
set_locale locale
get :list
assert_response :success, "Should be able to list the diary entries in #{locale}"
assert_template 'list', "Should use the list template in #{locale}"
# Now try to find a specific user's diary entry
get :list, {:display_name => users(:normal_user).display_name}
assert_response :success
assert_template 'list'
# Now try to find a specific user's diary entry
get :list, {:display_name => users(:normal_user).display_name}
assert_response :success, "Should be able to list the diary entries for a user in #{locale}"
assert_template 'list', "Should use the list template for a user in #{locale}"
end
end
def test_rss

View file

@ -123,6 +123,10 @@ class Test::Unit::TestCase
@request.env["RAW_POST_DATA"] = c.to_s
end
def set_locale(l)
@request.env["HTTP_ACCEPT_LANGUAGE"] = l.to_s
end
# Used to check that the error header and the forbidden responses are given
# when the owner of the changset has their data not marked as public
def assert_require_public_data(msg = "Shouldn't be able to use API when the user's data is not public")