Skip to content

Commit

Permalink
Upgraded to Rails 2.3.4 (#3597)
Browse files Browse the repository at this point in the history
* Ran the Rails upgrade
* Upgraded to Rails Engines 2.3.2
* Added a plugin to let Engines override application views.
* Converted tests to use the new classes:
** ActionController::TestCase for functional
** ActiveSupport::TestCase for units
* Converted ActiveRecord::Error message to a string.
* ActiveRecord grouping returns an ordered hash which doesn't have #sort!
* Updated the I18n storage_units format.
* Added some default initializers from a fresh rails app
* Changed the order of check_box_tags and hidden_field_tags.  The hidden tag
  needs to appear first in Rails 2.3, otherwise it will override any value in
  the check_box_tag.
* Removed the custom handler for when the cookie store is tampered with.
  Rails 2.3 removed the TamperedWithCookie exception and instead Rails will not
  load the data from it when it's been tampered with (e.g. no user login).
* Fixed mail layouts, 2.3 has problems with implicit multipart emails that
  use layouts.  Also removed some custom Redmine mailer code.
* Fixed a bug that occurred in tests where the "required" span tag would be
  added to the :field_status translation.  This resulted in an email string of:

    <li>Status<span class="required"> *</span><span class="required"> *</span>

  Instead of:

    <li>Status: New</li>

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2887 e93f8b46-1217-0410-a6f0-8f06a7374b81
  • Loading branch information
edavis10 committed Sep 13, 2009
1 parent fb349dc commit 7b0cb6a
Show file tree
Hide file tree
Showing 263 changed files with 1,636 additions and 440 deletions.
Expand Up @@ -20,12 +20,7 @@

class ApplicationController < ActionController::Base
include Redmine::I18n

# In case the cookie store secret changes
rescue_from CGI::Session::CookieStore::TamperedWithCookie do |exception|
render :text => 'Your session was invalid and has been reset. Please, reload this page.', :status => 500
end


layout 'base'

before_filter :user_setup, :check_if_login_required, :set_localization
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/repositories_controller.rb
Expand Up @@ -259,7 +259,7 @@ def graph_commits_per_month(repository)

def graph_commits_per_author(repository)
commits_by_author = repository.changesets.count(:all, :group => :committer)
commits_by_author.sort! {|x, y| x.last <=> y.last}
commits_by_author.to_a.sort! {|x, y| x.last <=> y.last}

changes_by_author = repository.changes.count(:all, :group => :committer)
h = changes_by_author.inject({}) {|o, i| o[i.first] = i.last; o}
Expand Down
48 changes: 28 additions & 20 deletions app/models/mailer.rb
Expand Up @@ -16,6 +16,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

class Mailer < ActionMailer::Base
layout 'mailer'
helper :application
helper :issues
helper :custom_fields
Expand Down Expand Up @@ -45,6 +46,7 @@ def issue_add(issue)
subject "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] (#{issue.status.name}) #{issue.subject}"
body :issue => issue,
:issue_url => url_for(:controller => 'issues', :action => 'show', :id => issue)
render_multipart('issue_add', body)
end

# Builds a tmail object used to email recipients of the edited issue.
Expand All @@ -71,6 +73,8 @@ def issue_edit(journal)
body :issue => issue,
:journal => journal,
:issue_url => url_for(:controller => 'issues', :action => 'show', :id => issue)

render_multipart('issue_edit', body)
end

def reminder(user, issues, days)
Expand All @@ -80,6 +84,7 @@ def reminder(user, issues, days)
body :issues => issues,
:days => days,
:issues_url => url_for(:controller => 'issues', :action => 'index', :set_filter => 1, :assigned_to_id => user.id, :sort_key => 'due_date', :sort_order => 'asc')
render_multipart('reminder', body)
end

# Builds a tmail object used to email users belonging to the added document's project.
Expand All @@ -93,6 +98,7 @@ def document_added(document)
subject "[#{document.project.name}] #{l(:label_document_new)}: #{document.title}"
body :document => document,
:document_url => url_for(:controller => 'documents', :action => 'show', :id => document)
render_multipart('document_added', body)
end

# Builds a tmail object used to email recipients of a project when an attachements are added.
Expand Down Expand Up @@ -121,6 +127,7 @@ def attachments_added(attachments)
body :attachments => attachments,
:added_to => added_to,
:added_to_url => added_to_url
render_multipart('attachments_added', body)
end

# Builds a tmail object used to email recipients of a news' project when a news item is added.
Expand All @@ -135,6 +142,7 @@ def news_added(news)
subject "[#{news.project.name}] #{l(:label_news)}: #{news.title}"
body :news => news,
:news_url => url_for(:controller => 'news', :action => 'show', :id => news)
render_multipart('news_added', body)
end

# Builds a tmail object used to email the specified recipients of the specified message that was posted.
Expand All @@ -151,6 +159,7 @@ def message_posted(message, recipients)
subject "[#{message.board.project.name} - #{message.board.name} - msg#{message.root.id}] #{message.subject}"
body :message => message,
:message_url => url_for(:controller => 'messages', :action => 'show', :board_id => message.board_id, :id => message.root)
render_multipart('message_posted', body)
end

# Builds a tmail object used to email the recipients of a project of the specified wiki content was added.
Expand All @@ -167,6 +176,7 @@ def wiki_content_added(wiki_content)
subject "[#{wiki_content.project.name}] #{l(:mail_subject_wiki_content_added, :page => wiki_content.page.pretty_title)}"
body :wiki_content => wiki_content,
:wiki_content_url => url_for(:controller => 'wiki', :action => 'index', :id => wiki_content.project, :page => wiki_content.page.title)
render_multipart('wiki_content_added', body)
end

# Builds a tmail object used to email the recipients of a project of the specified wiki content was updated.
Expand All @@ -184,6 +194,7 @@ def wiki_content_updated(wiki_content)
body :wiki_content => wiki_content,
:wiki_content_url => url_for(:controller => 'wiki', :action => 'index', :id => wiki_content.project, :page => wiki_content.page.title),
:wiki_diff_url => url_for(:controller => 'wiki', :action => 'diff', :id => wiki_content.project, :page => wiki_content.page.title, :version => wiki_content.version)
render_multipart('wiki_content_updated', body)
end

# Builds a tmail object used to email the specified user their account information.
Expand All @@ -198,6 +209,7 @@ def account_information(user, password)
body :user => user,
:password => password,
:login_url => url_for(:controller => 'account', :action => 'login')
render_multipart('account_information', body)
end

# Builds a tmail object used to email all active administrators of an account activation request.
Expand All @@ -211,6 +223,7 @@ def account_activation_request(user)
subject l(:mail_subject_account_activation_request, Setting.app_title)
body :user => user,
:url => url_for(:controller => 'users', :action => 'index', :status => User::STATUS_REGISTERED, :sort_key => 'created_on', :sort_order => 'desc')
render_multipart('account_activation_request', body)
end

# Builds a tmail object used to email the specified user that their account was activated by an administrator.
Expand All @@ -224,6 +237,7 @@ def account_activated(user)
subject l(:mail_subject_register, Setting.app_title)
body :user => user,
:login_url => url_for(:controller => 'account', :action => 'login')
render_multipart('account_activated', body)
end

def lost_password(token)
Expand All @@ -232,6 +246,7 @@ def lost_password(token)
subject l(:mail_subject_lost_password, Setting.app_title)
body :token => token,
:url => url_for(:controller => 'account', :action => 'lost_password', :token => token.value)
render_multipart('lost_password', body)
end

def register(token)
Expand All @@ -240,13 +255,15 @@ def register(token)
subject l(:mail_subject_register, Setting.app_title)
body :token => token,
:url => url_for(:controller => 'account', :action => 'activate', :token => token.value)
render_multipart('register', body)
end

def test(user)
set_language_if_valid(user.language)
recipients user.mail
subject 'Redmine test'
body :url => url_for(:controller => 'welcome')
render_multipart('test', body)
end

# Overrides default deliver! method to prevent from sending an email
Expand Down Expand Up @@ -327,26 +344,17 @@ def create_mail
super
end

# Renders a message with the corresponding layout
def render_message(method_name, body)
layout = method_name.to_s.match(%r{text\.html\.(rhtml|rxml)}) ? 'layout.text.html.rhtml' : 'layout.text.plain.rhtml'
body[:content_for_layout] = render(:file => method_name, :body => body)
ActionView::Base.new(template_root, body, self).render(:file => "mailer/#{layout}", :use_full_path => true)
end

# for the case of plain text only
def body(*params)
value = super(*params)
if Setting.plain_text_mail?
templates = Dir.glob("#{template_path}/#{@template}.text.plain.{rhtml,erb}")
unless String === @body or templates.empty?
template = File.basename(templates.first)
@body[:content_for_layout] = render(:file => template, :body => @body)
@body = ActionView::Base.new(template_root, @body, self).render(:file => "mailer/layout.text.plain.rhtml", :use_full_path => true)
return @body
end
end
return value
# Rails 2.3 has problems rendering implicit multipart messages with
# layouts so this method will wrap an multipart messages with
# explicit parts.
#
# https://rails.lighthouseapp.com/projects/8994/tickets/2338-actionmailer-mailer-views-and-content-type
# https://rails.lighthouseapp.com/projects/8994/tickets/1799-actionmailer-doesnt-set-template_format-when-rendering-layouts

def render_multipart(method_name, body)
content_type "multipart/alternative"
part :content_type => "text/plain", :body => render(:file => "#{method_name}.text.plain.rhtml", :body => body, :layout => 'mailer.text.plain.erb')
part :content_type => "text/html", :body => render_message("#{method_name}.text.html.rhtml", body) unless Setting.plain_text_mail?
end

# Makes partial rendering work with Rails 1.2 (retro-compatibility)
Expand Down
File renamed without changes.
File renamed without changes.
12 changes: 9 additions & 3 deletions app/views/settings/_authentication.rhtml
Expand Up @@ -2,7 +2,9 @@

<div class="box tabular settings">
<p><label><%= l(:setting_login_required) %></label>
<%= check_box_tag 'settings[login_required]', 1, Setting.login_required? %><%= hidden_field_tag 'settings[login_required]', 0 %></p>
<%= hidden_field_tag 'settings[login_required]', 0 %>
<%= check_box_tag 'settings[login_required]', 1, Setting.login_required? %>
</p>

<p><label><%= l(:setting_autologin) %></label>
<%= select_tag 'settings[autologin]', options_for_select( [[l(:label_disabled), "0"]] + [1, 7, 30, 365].collect{|days| [l('datetime.distance_in_words.x_days', :count => days), days.to_s]}, Setting.autologin) %></p>
Expand All @@ -19,10 +21,14 @@
<%= text_field_tag 'settings[password_min_length]', Setting.password_min_length, :size => 6 %></p>

<p><label><%= l(:label_password_lost) %></label>
<%= check_box_tag 'settings[lost_password]', 1, Setting.lost_password? %><%= hidden_field_tag 'settings[lost_password]', 0 %></p>
<%= hidden_field_tag 'settings[lost_password]', 0 %>
<%= check_box_tag 'settings[lost_password]', 1, Setting.lost_password? %>
</p>

<p><label><%= l(:setting_openid) %></label>
<%= check_box_tag 'settings[openid]', 1, Setting.openid?, :disabled => !Object.const_defined?(:OpenID) %><%= hidden_field_tag 'settings[openid]', 0 %></p>
<%= hidden_field_tag 'settings[openid]', 0 %>
<%= check_box_tag 'settings[openid]', 1, Setting.openid?, :disabled => !Object.const_defined?(:OpenID) %>
</p>
</div>

<div style="float:right;">
Expand Down
4 changes: 3 additions & 1 deletion app/views/settings/_display.rhtml
Expand Up @@ -17,7 +17,9 @@
<%= select_tag 'settings[user_format]', options_for_select( @options[:user_format], Setting.user_format.to_s ) %></p>

<p><label><%= l(:setting_gravatar_enabled) %></label>
<%= check_box_tag 'settings[gravatar_enabled]', 1, Setting.gravatar_enabled? %><%= hidden_field_tag 'settings[gravatar_enabled]', 0 %></p>
<%= hidden_field_tag 'settings[gravatar_enabled]', 0 %>
<%= check_box_tag 'settings[gravatar_enabled]', 1, Setting.gravatar_enabled? %>
</p>
</div>

<%= submit_tag l(:button_save) %>
Expand Down
8 changes: 6 additions & 2 deletions app/views/settings/_issues.rhtml
Expand Up @@ -2,10 +2,14 @@

<div class="box tabular settings">
<p><label><%= l(:setting_cross_project_issue_relations) %></label>
<%= check_box_tag 'settings[cross_project_issue_relations]', 1, Setting.cross_project_issue_relations? %><%= hidden_field_tag 'settings[cross_project_issue_relations]', 0 %></p>
<%= hidden_field_tag 'settings[cross_project_issue_relations]', 0 %>
<%= check_box_tag 'settings[cross_project_issue_relations]', 1, Setting.cross_project_issue_relations? %>
</p>

<p><label><%= l(:setting_display_subprojects_issues) %></label>
<%= check_box_tag 'settings[display_subprojects_issues]', 1, Setting.display_subprojects_issues? %><%= hidden_field_tag 'settings[display_subprojects_issues]', 0 %></p>
<%= hidden_field_tag 'settings[display_subprojects_issues]', 0 %>
<%= check_box_tag 'settings[display_subprojects_issues]', 1, Setting.display_subprojects_issues? %>
</p>

<p><label><%= l(:setting_issues_export_limit) %></label>
<%= text_field_tag 'settings[issues_export_limit]', Setting.issues_export_limit, :size => 6 %></p>
Expand Down
3 changes: 2 additions & 1 deletion app/views/settings/_mail_handler.rhtml
Expand Up @@ -2,9 +2,10 @@

<div class="box tabular settings">
<p><label><%= l(:setting_mail_handler_api_enabled) %></label>
<%= hidden_field_tag 'settings[mail_handler_api_enabled]', 0 %>
<%= check_box_tag 'settings[mail_handler_api_enabled]', 1, Setting.mail_handler_api_enabled?,
:onclick => "if (this.checked) { Form.Element.enable('settings_mail_handler_api_key'); } else { Form.Element.disable('settings_mail_handler_api_key'); }" %>
<%= hidden_field_tag 'settings[mail_handler_api_enabled]', 0 %></p>
</p>

<p><label><%= l(:setting_mail_handler_api_key) %></label>
<%= text_field_tag 'settings[mail_handler_api_key]', Setting.mail_handler_api_key,
Expand Down
6 changes: 4 additions & 2 deletions app/views/settings/_notifications.rhtml
Expand Up @@ -6,12 +6,14 @@
<%= text_field_tag 'settings[mail_from]', Setting.mail_from, :size => 60 %></p>

<p><label><%= l(:setting_bcc_recipients) %></label>
<%= hidden_field_tag 'settings[bcc_recipients]', 0 %>
<%= check_box_tag 'settings[bcc_recipients]', 1, Setting.bcc_recipients? %>
<%= hidden_field_tag 'settings[bcc_recipients]', 0 %></p>
</p>

<p><label><%= l(:setting_plain_text_mail) %></label>
<%= hidden_field_tag 'settings[plain_text_mail]', 0 %>
<%= check_box_tag 'settings[plain_text_mail]', 1, Setting.plain_text_mail? %>
<%= hidden_field_tag 'settings[plain_text_mail]', 0 %></p>
</p>
</div>

<fieldset class="box" id="notified_events"><legend><%=l(:text_select_mail_notifications)%></legend>
Expand Down
8 changes: 6 additions & 2 deletions app/views/settings/_projects.rhtml
Expand Up @@ -2,10 +2,14 @@

<div class="box tabular settings">
<p><label><%= l(:setting_default_projects_public) %></label>
<%= check_box_tag 'settings[default_projects_public]', 1, Setting.default_projects_public? %><%= hidden_field_tag 'settings[default_projects_public]', 0 %></p>
<%= hidden_field_tag 'settings[default_projects_public]', 0 %>
<%= check_box_tag 'settings[default_projects_public]', 1, Setting.default_projects_public? %>
</p>

<p><label><%= l(:setting_sequential_project_identifiers) %></label>
<%= check_box_tag 'settings[sequential_project_identifiers]', 1, Setting.sequential_project_identifiers? %><%= hidden_field_tag 'settings[sequential_project_identifiers]', 0 %></p>
<%= hidden_field_tag 'settings[sequential_project_identifiers]', 0 %>
<%= check_box_tag 'settings[sequential_project_identifiers]', 1, Setting.sequential_project_identifiers? %>
</p>

<p><label><%= l(:setting_new_project_user_role_id) %></label>
<%= select_tag('settings[new_project_user_role_id]', options_for_select([["--- #{l(:actionview_instancetag_blank_option)} ---", '']] + Role.find_all_givable.collect {|r| [r.name, r.id]}, Setting.new_project_user_role_id.to_i)) %></p>
Expand Down
8 changes: 6 additions & 2 deletions app/views/settings/_repositories.rhtml
Expand Up @@ -2,10 +2,14 @@

<div class="box tabular settings">
<p><label><%= l(:setting_autofetch_changesets) %></label>
<%= check_box_tag 'settings[autofetch_changesets]', 1, Setting.autofetch_changesets? %><%= hidden_field_tag 'settings[autofetch_changesets]', 0 %></p>
<%= hidden_field_tag 'settings[autofetch_changesets]', 0 %>
<%= check_box_tag 'settings[autofetch_changesets]', 1, Setting.autofetch_changesets? %>
</p>

<p><label><%= l(:setting_sys_api_enabled) %></label>
<%= check_box_tag 'settings[sys_api_enabled]', 1, Setting.sys_api_enabled? %><%= hidden_field_tag 'settings[sys_api_enabled]', 0 %></p>
<%= hidden_field_tag 'settings[sys_api_enabled]', 0 %>
<%= check_box_tag 'settings[sys_api_enabled]', 1, Setting.sys_api_enabled? %>
</p>

<p><label><%= l(:setting_enabled_scm) %></label>
<% REDMINE_SUPPORTED_SCM.each do |scm| -%>
Expand Down
5 changes: 3 additions & 2 deletions config/boot.rb
@@ -1,7 +1,7 @@
# Don't change this file!
# Configure your app in config/environment.rb and config/environments/*.rb

RAILS_ROOT = File.expand_path("#{File.dirname(__FILE__)}/..") unless defined?(RAILS_ROOT)
RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)

module Rails
class << self
Expand Down Expand Up @@ -44,6 +44,7 @@ class VendorBoot < Boot
def load_initializer
require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
Rails::Initializer.run(:install_gem_spec_stubs)
Rails::GemDependency.add_frozen_gem_path
end
end

Expand Down Expand Up @@ -81,8 +82,8 @@ def gem_version
end

def load_rubygems
min_version = '1.3.2'
require 'rubygems'
min_version = '1.3.1'
unless rubygems_version >= min_version
$stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
exit 1
Expand Down
2 changes: 1 addition & 1 deletion config/environment.rb
Expand Up @@ -5,7 +5,7 @@
# ENV['RAILS_ENV'] ||= 'production'

# Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION = '2.2.2' unless defined? RAILS_GEM_VERSION
RAILS_GEM_VERSION = '2.3.4' unless defined? RAILS_GEM_VERSION

# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')
Expand Down
2 changes: 1 addition & 1 deletion config/initializers/10-patches.rb
Expand Up @@ -33,7 +33,7 @@ def full_messages(options = {})
end
else
attr_name = @base.class.human_attribute_name(attr)
full_messages << attr_name + ' ' + message
full_messages << attr_name + ' ' + message.to_s
end
end
end
Expand Down
7 changes: 7 additions & 0 deletions config/initializers/backtrace_silencers.rb
@@ -0,0 +1,7 @@
# Be sure to restart your server when you modify this file.

# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }

# You can also remove all the silencers if you're trying do debug a problem that might steem from framework code.
# Rails.backtrace_cleaner.remove_silencers!
10 changes: 10 additions & 0 deletions config/initializers/inflections.rb
@@ -0,0 +1,10 @@
# Be sure to restart your server when you modify this file.

# Add new inflection rules using the following format
# (all these examples are active by default):
# ActiveSupport::Inflector.inflections do |inflect|
# inflect.plural /^(ox)$/i, '\1en'
# inflect.singular /^(ox)en/i, '\1'
# inflect.irregular 'person', 'people'
# inflect.uncountable %w( fish sheep )
# end
16 changes: 16 additions & 0 deletions config/locales/bg.yml
Expand Up @@ -59,6 +59,22 @@ bg:
over_x_years:
one: "over 1 year"
other: "over {{count}} years"

number:
human:
format:
precision: 1
delimiter: ""
storage_units:
format: "%n %u"
units:
kb: KB
tb: TB
gb: GB
byte:
one: Byte
other: Bytes
mb: 'MB'

# Used in array.to_sentence.
support:
Expand Down

0 comments on commit 7b0cb6a

Please sign in to comment.