From 6ba51da46e41f2cf9260ef8e0b74a933ae82a362 Mon Sep 17 00:00:00 2001 From: Shaun McDonald Date: Wed, 27 May 2009 15:06:25 +0000 Subject: [PATCH] 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. --- app/views/diary_entry/list.rhtml | 12 +++++------ config/locales/en.yml | 8 +++++++- .../functional/diary_entry_controller_test.rb | 20 ++++++++++++------- test/test_helper.rb | 4 ++++ 4 files changed, 30 insertions(+), 14 deletions(-) diff --git a/app/views/diary_entry/list.rhtml b/app/views/diary_entry/list.rhtml index 38157b183..00937d89e 100644 --- a/app/views/diary_entry/list.rhtml +++ b/app/views/diary_entry/list.rhtml @@ -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? %> -

No diary entries

+

<%= t 'diary_entry.list.no_entries' %>

<% else %> -

Recent diary entries:

+

<%= t 'diary_entry.list.recent_entries' %>


<%= 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 %>
<% end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 8f466c0f8..a414e659a 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -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: diff --git a/test/functional/diary_entry_controller_test.rb b/test/functional/diary_entry_controller_test.rb index 628cf4dbf..3bbf8ae0a 100644 --- a/test/functional/diary_entry_controller_test.rb +++ b/test/functional/diary_entry_controller_test.rb @@ -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 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 diff --git a/test/test_helper.rb b/test/test_helper.rb index 5dd319e02..95b6e7e67 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -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") -- 2.43.2