]> git.openstreetmap.org Git - rails.git/commitdiff
translating the listing of diary entries. Adding some initial tests for checking...
authorShaun McDonald <shaun@shaunmcdonald.me.uk>
Wed, 27 May 2009 15:06:25 +0000 (15:06 +0000)
committerShaun McDonald <shaun@shaunmcdonald.me.uk>
Wed, 27 May 2009 15:06:25 +0000 (15:06 +0000)
app/views/diary_entry/list.rhtml
config/locales/en.yml
test/functional/diary_entry_controller_test.rb
test/test_helper.rb

index 38157b183b976883282d86ba2bdcca717ccf0857..00937d89e0001d9c765596ceb2cc0575dec7b5a2 100644 (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 %>
index 8f466c0f8a4e9a1259c06a9373e9faaf256873ef..a414e659a0dd4bbf0d96c2337d9ebca68f92f60f 100644 (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:
index 628cf4dbf166e82e59b842c1366ed90f57e65db9..3bbf8ae0a357c1870368037e5302d7a12daf9b54 100644 (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
index 5dd319e02a05e1d1a40391b40f18f8b62b8febfc..95b6e7e6766ba669c6451c5da9e5397d765651fe 100644 (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")