aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/application_controller.rb5
-rw-r--r--app/views/general/blog.html.erb2
-rw-r--r--lib/mail_handler/backends/mail_backend.rb2
-rwxr-xr-xscript/rails-post-deploy2
-rw-r--r--spec/controllers/help_controller_spec.rb27
-rw-r--r--spec/fixtures/theme_views/theme_one/help/contact.es.html.erb1
-rw-r--r--spec/fixtures/theme_views/theme_one/help/contact.html.erb1
-rw-r--r--spec/lib/mail_handler/mail_handler_spec.rb2
-rw-r--r--spec/mailers/outgoing_mailer_spec.rb2
9 files changed, 36 insertions, 8 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index a8ba52e4f..acf366bfb 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -51,6 +51,9 @@ class ApplicationController < ActionController::Base
anonymous_cache(24.hours)
end
+ # This is an override of the method provided by gettext_i18n_rails - note the explicit
+ # setting of I18n.locale, required due to the I18nProxy used in Rails 3 to trigger the
+ # lookup_context and expire the template cache
def set_gettext_locale
if AlaveteliConfiguration::include_default_locale_in_urls == false
params_locale = params[:locale] ? params[:locale] : I18n.default_locale
@@ -63,7 +66,7 @@ class ApplicationController < ActionController::Base
requested_locale = params_locale || session[:locale] || cookies[:locale] || I18n.default_locale
end
requested_locale = FastGettext.best_locale_in(requested_locale)
- session[:locale] = FastGettext.set_locale(requested_locale)
+ session[:locale] = I18n.locale = FastGettext.set_locale(requested_locale)
if !@user.nil?
if @user.locale != requested_locale
@user.locale = session[:locale]
diff --git a/app/views/general/blog.html.erb b/app/views/general/blog.html.erb
index 7146aab5d..ef587421e 100644
--- a/app/views/general/blog.html.erb
+++ b/app/views/general/blog.html.erb
@@ -23,7 +23,7 @@
<% @blog_items.each do |item| %>
<div class="blog_post">
<h2 id="<%= Time.parse(item['pubDate'][0]).to_i %>"><a href="<%=item['link'][0]%>"><%=h item['title'][0] %></a></h2>
- <p class="subtitle"><%= _("Posted on {{date}} by {{author}}", :date=>simple_date(Time.parse(item['pubDate'][0])), :author=>item['creator'][0]) %></p>
+ <p class="subtitle"><%= _("Posted on {{date}} by {{author}}", :date=>simple_date(Time.parse(item['pubDate'][0])), :author=> item['creator'] ? item['creator'][0] : item['author'][0]) %></p>
<div>
<% if item['encoded'] %>
<%= raw item['encoded'][0] %>
diff --git a/lib/mail_handler/backends/mail_backend.rb b/lib/mail_handler/backends/mail_backend.rb
index 561946980..28c486e1b 100644
--- a/lib/mail_handler/backends/mail_backend.rb
+++ b/lib/mail_handler/backends/mail_backend.rb
@@ -112,7 +112,7 @@ module MailHandler
if first_from.is_a?(ActiveSupport::Multibyte::Chars)
return nil
else
- return first_from.display_name ? eval(%Q{"#{first_from.display_name}"}) : nil
+ return (first_from.display_name || nil)
end
else
return nil
diff --git a/script/rails-post-deploy b/script/rails-post-deploy
index 4048c852f..a3257cf35 100755
--- a/script/rails-post-deploy
+++ b/script/rails-post-deploy
@@ -50,7 +50,7 @@ fi
if [ ! -e "$TOP_DIR/public/download" ]
then
mkdir -p "$TOP_DIR/cache/zips/download"
- ln -s "$TOP_DIR/cache/zips/download" "$TOP_DIR/public/"
+ ln -s "../cache/zips/download" "$TOP_DIR/public/"
fi
cd log
diff --git a/spec/controllers/help_controller_spec.rb b/spec/controllers/help_controller_spec.rb
index 0f6f75eb9..c47e1abd3 100644
--- a/spec/controllers/help_controller_spec.rb
+++ b/spec/controllers/help_controller_spec.rb
@@ -1,8 +1,9 @@
+# -*- coding: utf-8 -*-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe HelpController, "when using help" do
render_views
-
+
it "shows the about page" do
get :about
end
@@ -12,7 +13,7 @@ describe HelpController, "when using help" do
end
it "sends a contact message" do
- post :contact, { :contact => {
+ post :contact, { :contact => {
:name => "Vinny Vanilli",
:email => "vinny@localhost",
:subject => "Why do I have such an ace name?",
@@ -27,5 +28,27 @@ describe HelpController, "when using help" do
deliveries.clear
end
+ describe 'when requesting a page in a supported locale ' do
+
+ before do
+ # Allow us to supply the locale manually
+ RoutingFilter.active = false
+ # Prepend our fixture templates
+ fixture_theme_path = File.join(Rails.root, 'spec', 'fixtures', 'theme_views', 'theme_one')
+ controller.prepend_view_path fixture_theme_path
+ end
+
+ after do
+ RoutingFilter.active = true
+ end
+
+ it 'should render the locale-specific template if available' do
+ get :contact, {:locale => 'es'}
+ response.body.should match('contáctenos theme one')
+ end
+
+ end
+
+
end
diff --git a/spec/fixtures/theme_views/theme_one/help/contact.es.html.erb b/spec/fixtures/theme_views/theme_one/help/contact.es.html.erb
new file mode 100644
index 000000000..a294c8aa1
--- /dev/null
+++ b/spec/fixtures/theme_views/theme_one/help/contact.es.html.erb
@@ -0,0 +1 @@
+contáctenos theme one
diff --git a/spec/fixtures/theme_views/theme_one/help/contact.html.erb b/spec/fixtures/theme_views/theme_one/help/contact.html.erb
new file mode 100644
index 000000000..428c7368d
--- /dev/null
+++ b/spec/fixtures/theme_views/theme_one/help/contact.html.erb
@@ -0,0 +1 @@
+Contact us
diff --git a/spec/lib/mail_handler/mail_handler_spec.rb b/spec/lib/mail_handler/mail_handler_spec.rb
index 272b56d0b..d6e7ba5d2 100644
--- a/spec/lib/mail_handler/mail_handler_spec.rb
+++ b/spec/lib/mail_handler/mail_handler_spec.rb
@@ -223,7 +223,7 @@ describe 'when deriving a name, email and formatted address from a message from
it 'should quote a name with quotes in it' do
should_render_from_address('"FOI \" Person" <foiperson@localhost>',
- ['FOI " Person',
+ ['FOI \" Person',
'foiperson@localhost',
'"FOI \" Person" <foiperson@localhost>'])
end
diff --git a/spec/mailers/outgoing_mailer_spec.rb b/spec/mailers/outgoing_mailer_spec.rb
index 5d1ea2dfb..0ae31801c 100644
--- a/spec/mailers/outgoing_mailer_spec.rb
+++ b/spec/mailers/outgoing_mailer_spec.rb
@@ -53,7 +53,7 @@ describe OutgoingMailer, " when working out follow up addresses" do
# check the basic entry in the fixture is fine
OutgoingMailer.name_and_email_for_followup(ir, im).should == "\"FOI \\\" Person\" <foiperson@localhost>"
- OutgoingMailer.name_for_followup(ir, im).should == "FOI \" Person"
+ OutgoingMailer.name_for_followup(ir, im).should == "FOI \\\" Person"
OutgoingMailer.email_for_followup(ir, im).should == "foiperson@localhost"
end