aboutsummaryrefslogtreecommitdiffstats
path: root/config/initializers
diff options
context:
space:
mode:
Diffstat (limited to 'config/initializers')
-rw-r--r--config/initializers/alaveteli.rb17
-rw-r--r--config/initializers/secret_token.rb7
-rw-r--r--config/initializers/theme_loader.rb21
3 files changed, 34 insertions, 11 deletions
diff --git a/config/initializers/alaveteli.rb b/config/initializers/alaveteli.rb
index 458201164..263e5cf7b 100644
--- a/config/initializers/alaveteli.rb
+++ b/config/initializers/alaveteli.rb
@@ -10,7 +10,7 @@ load "debug_helpers.rb"
load "util.rb"
# Application version
-ALAVETELI_VERSION = '0.8'
+ALAVETELI_VERSION = '0.10'
# Add new inflection rules using the following format
# (all these examples are active by default):
@@ -29,6 +29,10 @@ ALAVETELI_VERSION = '0.8'
# Domain for URLs (so can work for scripts, not just web pages)
ActionMailer::Base.default_url_options[:host] = AlaveteliConfiguration::domain
+# https links in emails if forcing SSL
+if AlaveteliConfiguration::force_ssl
+ ActionMailer::Base.default_url_options[:protocol] = "https"
+end
# fallback locale and available locales
available_locales = AlaveteliConfiguration::available_locales.split(/ /)
@@ -39,15 +43,11 @@ I18n.locale = default_locale
I18n.available_locales = available_locales.map {|locale_name| locale_name.to_sym}
I18n.default_locale = default_locale
-# Customise will_paginate URL generation
-WillPaginate::ViewHelpers.pagination_options[:renderer] = 'WillPaginateExtension::LinkRenderer'
-
# Load monkey patches and other things from lib/
require 'ruby19.rb'
require 'activesupport_cache_extensions.rb'
require 'use_spans_for_errors.rb'
require 'activerecord_errors_extensions.rb'
-require 'willpaginate_extension.rb'
require 'i18n_fixes.rb'
require 'world_foi_websites.rb'
require 'alaveteli_external_command.rb'
@@ -55,3 +55,10 @@ require 'quiet_opener.rb'
require 'mail_handler'
require 'public_body_categories'
require 'ability'
+require 'normalize_string'
+require 'alaveteli_file_types'
+
+# Allow tests to be run under a non-superuser database account if required
+if Rails.env == 'test' and ActiveRecord::Base.configurations['test']['constraint_disabling'] == false
+ require 'no_constraint_disabling'
+end
diff --git a/config/initializers/secret_token.rb b/config/initializers/secret_token.rb
index f82348169..d120b94ae 100644
--- a/config/initializers/secret_token.rb
+++ b/config/initializers/secret_token.rb
@@ -4,4 +4,9 @@
# If you change this key, all old signed cookies will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attacks.
-Alaveteli::Application.config.secret_token = AlaveteliConfiguration::cookie_store_session_secret
+
+# Just plopping an extra character on the secret_token so that any sessions on upgrading from
+# Rails 2 to Rails 3 version of Alaveteli are invalidated.
+# See http://blog.carbonfive.com/2011/03/19/rails-3-upgrade-tip-invalidate-session-cookies/
+
+Alaveteli::Application.config.secret_token = "3" + AlaveteliConfiguration::cookie_store_session_secret
diff --git a/config/initializers/theme_loader.rb b/config/initializers/theme_loader.rb
index 4c8967c97..1ad2d01f1 100644
--- a/config/initializers/theme_loader.rb
+++ b/config/initializers/theme_loader.rb
@@ -2,12 +2,23 @@
# It is used by our config/routes.rb to decide which route extension files to load.
$alaveteli_route_extensions = []
-if ENV["RAILS_ENV"] != "test" # Don't let the themes interfere with Alaveteli specs
+def require_theme(theme_name)
+ theme_main_include = File.expand_path "../../../vendor/plugins/#{theme_name}/lib/alavetelitheme.rb", __FILE__
+ if File.exists? theme_main_include
+ require theme_main_include
+ end
+end
+
+if Rails.env == "test"
+ # By setting this ALAVETELI_TEST_THEME to a theme name, theme tests can run in the Rails
+ # context with the theme loaded. Otherwise the themes from the config aren't loaded in testing
+ # so they don't interfere with core Alaveteli tests
+ if defined? ALAVETELI_TEST_THEME
+ require_theme(ALAVETELI_TEST_THEME)
+ end
+else
for url in AlaveteliConfiguration::theme_urls.reverse
theme_name = url.sub(/.*\/(.*).git/, "\\1")
- theme_main_include = File.expand_path "../../../vendor/plugins/#{theme_name}/lib/alavetelitheme.rb", __FILE__
- if File.exists? theme_main_include
- require theme_main_include
- end
+ require_theme(theme_name)
end
end