Adding some more diary entry tests. Making the RSS feed links more portable, by using the SERVER_URL constant. Fixing the validation for the length of the language of diary entries until the i18n branch is integrated.

This commit is contained in:
Shaun McDonald 2008-11-13 17:20:40 +00:00
parent 797cbaab1e
commit bdd5c317a7
3 changed files with 73 additions and 13 deletions

View file

@ -86,7 +86,7 @@ class DiaryEntryController < ApplicationController
@entries = DiaryEntry.find(:all, :conditions => ['user_id = ?', user.id], :order => 'created_at DESC', :limit => 20)
@title = "OpenStreetMap diary entries for #{user.display_name}"
@description = "Recent OpenStreetmap diary entries from #{user.display_name}"
@link = "http://www.openstreetmap.org/user/#{user.display_name}/diary"
@link = "http://#{SERVER_URL}/user/#{user.display_name}/diary"
render :content_type => Mime::RSS
else
@ -98,7 +98,7 @@ class DiaryEntryController < ApplicationController
:order => 'created_at DESC', :limit => 20)
@title = "OpenStreetMap diary entries"
@description = "Recent diary entries from users of OpenStreetMap"
@link = "http://www.openstreetmap.org/diary"
@link = "http://#{SERVER_URL}/diary"
render :content_type => Mime::RSS
end
@ -109,6 +109,7 @@ class DiaryEntryController < ApplicationController
if user
@entry = DiaryEntry.find(:first, :conditions => ['user_id = ? AND id = ?', user.id, params[:id]])
@title = "Users' diaries | #{params[:display_name]}"
else
@not_found_user = params[:display_name]

View file

@ -6,7 +6,7 @@ class DiaryEntry < ActiveRecord::Base
validates_presence_of :title, :body
validates_length_of :title, :within => 1..255
validates_length_of :language, :within => 2..3
validates_length_of :language, :within => 2..3, :allow_nil => true
validates_numericality_of :latitude, :allow_nil => true
validates_numericality_of :longitude, :allow_nil => true
validates_associated :user