Skip to content

Commit

Permalink
Merged rails-3.2 branch.
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9528 e93f8b46-1217-0410-a6f0-8f06a7374b81
  • Loading branch information
jplang committed Apr 25, 2012
1 parent 34e20c4 commit 5e57a1a
Show file tree
Hide file tree
Showing 457 changed files with 20,230 additions and 5,367 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
/config/database.yml
/config/email.yml
/config/initializers/session_store.rb
/config/initializers/secret_token.rb
/coverage
/db/*.db
/db/*.sqlite3
Expand Down
1 change: 1 addition & 0 deletions .hgignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ config/configuration.yml
config/database.yml
config/email.yml
config/initializers/session_store.rb
config/initializers/secret_token.rb
coverage
db/*.db
db/*.sqlite3
Expand Down
14 changes: 9 additions & 5 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
source :rubygems
source 'http://rubygems.org'

gem "rails", "2.3.14"
gem "i18n", "~> 0.4.2"
gem 'rails', '3.2.3'
gem 'prototype-rails', '3.2.1'
gem "i18n", "~> 0.6.0"
gem "coderay", "~> 1.0.6"
gem "fastercsv", "~> 1.5.0", :platforms => [:mri_18, :mingw_18, :jruby]
gem "tzinfo", "~> 0.3.31"
gem "builder"

# Optional gem for LDAP authentication
group :ldap do
Expand All @@ -14,6 +16,7 @@ end
# Optional gem for OpenID authentication
group :openid do
gem "ruby-openid", "~> 2.1.4", :require => "openid"
gem "rack-openid"
end

# Optional gem for exporting the gantt to a PNG file, not supported with jruby
Expand Down Expand Up @@ -45,7 +48,7 @@ end

platforms :mri_19, :mingw_19 do
group :mysql do
gem "mysql2", "~> 0.2.7"
gem "mysql2", "~> 0.3.11"
end
end

Expand All @@ -69,8 +72,9 @@ group :development do
gem "rdoc", ">= 2.4.2"
end


group :test do
gem "shoulda", "~> 2.10.3"
gem "shoulda"
gem "mocha"
end

Expand Down
16 changes: 4 additions & 12 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
#!/usr/bin/env rake
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/switchtower.rake, and they will automatically be available to Rake.
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require(File.join(File.dirname(__FILE__), 'config', 'boot'))
require File.expand_path('../config/application', __FILE__)

require 'rake'
require 'rake/testtask'

begin
require 'rdoc/task'
rescue LoadError
# RDoc is not available
end

require 'tasks/rails'
RedmineApp::Application.load_tasks
44 changes: 14 additions & 30 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@ class Unauthorized < Exception; end

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

class_attribute :accept_api_auth_actions
class_attribute :accept_rss_auth_actions
class_attribute :model_object

layout 'base'
exempt_from_layout 'builder', 'rsb'

protect_from_forgery
def handle_unverified_request
Expand Down Expand Up @@ -68,7 +71,6 @@ def utf8nize!(obj)
end

before_filter :user_setup, :check_if_login_required, :set_localization
filter_parameter_logging :password

rescue_from ActionController::InvalidAuthenticityToken, :with => :invalid_authenticity_token
rescue_from ::Unauthorized, :with => :deny_access
Expand All @@ -77,10 +79,6 @@ def utf8nize!(obj)
include Redmine::MenuManager::MenuController
helper Redmine::MenuManager::MenuHelper

Redmine::Scm::Base.all.each do |scm|
require_dependency "repository/#{scm.underscore}"
end

def user_setup
# Check the settings cache for each request
Setting.check_cache
Expand Down Expand Up @@ -242,7 +240,7 @@ def find_project_from_association
end

def find_model_object
model = self.class.read_inheritable_attribute('model_object')
model = self.class.model_object
if model
@object = model.find(params[:id])
self.instance_variable_set('@' + controller_name.singularize, @object) if @object
Expand All @@ -252,7 +250,7 @@ def find_model_object
end

def self.model_object(model)
write_inheritable_attribute('model_object', model)
self.model_object = model
end

# Filter for bulk issue operations
Expand Down Expand Up @@ -388,9 +386,9 @@ def render_feed(items, options={})

def self.accept_rss_auth(*actions)
if actions.any?
write_inheritable_attribute('accept_rss_auth_actions', actions)
self.accept_rss_auth_actions = actions
else
read_inheritable_attribute('accept_rss_auth_actions') || []
self.accept_rss_auth_actions || []
end
end

Expand All @@ -400,9 +398,9 @@ def accept_rss_auth?(action=action_name)

def self.accept_api_auth(*actions)
if actions.any?
write_inheritable_attribute('accept_api_auth_actions', actions)
self.accept_api_auth_actions = actions
else
read_inheritable_attribute('accept_api_auth_actions') || []
self.accept_api_auth_actions || []
end
end

Expand Down Expand Up @@ -523,26 +521,12 @@ def render_validation_errors(objects)
else
@error_messages = objects.errors.full_messages
end
render :template => 'common/error_messages.api', :status => :unprocessable_entity, :layout => false
end

# Overrides #default_template so that the api template
# is used automatically if it exists
def default_template(action_name = self.action_name)
if api_request?
begin
return self.view_paths.find_template(default_template_name(action_name), 'api')
rescue ::ActionView::MissingTemplate
# the api template was not found
# fallback to the default behaviour
end
end
super
render :template => 'common/error_messages.api', :status => :unprocessable_entity, :layout => nil
end

# Overrides #pick_layout so that #render with no arguments
# Overrides #_include_layout? so that #render with no arguments
# doesn't use the layout for api requests
def pick_layout(*args)
api_request? ? nil : super
def _include_layout?(*args)
api_request? ? false : super
end
end
3 changes: 2 additions & 1 deletion app/controllers/messages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,11 @@ def edit
# Delete a messages
def destroy
(render_403; return false) unless @message.destroyable_by?(User.current)
r = @message.to_param
@message.destroy
redirect_to @message.parent.nil? ?
{ :controller => 'boards', :action => 'show', :project_id => @project, :id => @board } :
{ :action => 'show', :id => @message.parent, :r => @message }
{ :action => 'show', :id => @message.parent, :r => r }
end

def quote
Expand Down
18 changes: 9 additions & 9 deletions app/controllers/repositories_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
require 'SVG/Graph/Bar'
require 'SVG/Graph/BarHorizontal'
require 'digest/sha1'
require 'redmine/scm/adapters/abstract_adapter'

class ChangesetNotFound < Exception; end
class InvalidRevisionParam < Exception; end
Expand Down Expand Up @@ -307,8 +308,7 @@ def find_project_repository
@repository = @project.repository
end
(render_404; return false) unless @repository
@path = params[:path].join('/') unless params[:path].nil?
@path ||= ''
@path = params[:path].is_a?(Array) ? params[:path].join('/') : params[:path].to_s
@rev = params[:rev].blank? ? @repository.default_branch : params[:rev].to_s.strip
@rev_to = params[:rev_to]

Expand Down Expand Up @@ -343,15 +343,15 @@ def graph_commits_per_month(repository)
@date_to = Date.today
@date_from = @date_to << 11
@date_from = Date.civil(@date_from.year, @date_from.month, 1)
commits_by_day = repository.changesets.count(
commits_by_day = Changeset.count(
:all, :group => :commit_date,
:conditions => ["commit_date BETWEEN ? AND ?", @date_from, @date_to])
:conditions => ["repository_id = ? AND commit_date BETWEEN ? AND ?", repository.id, @date_from, @date_to])
commits_by_month = [0] * 12
commits_by_day.each {|c| commits_by_month[c.first.to_date.months_ago] += c.last }

changes_by_day = repository.changes.count(
:all, :group => :commit_date,
:conditions => ["commit_date BETWEEN ? AND ?", @date_from, @date_to])
changes_by_day = Change.count(
:all, :group => :commit_date, :include => :changeset,
:conditions => ["#{Changeset.table_name}.repository_id = ? AND #{Changeset.table_name}.commit_date BETWEEN ? AND ?", repository.id, @date_from, @date_to])
changes_by_month = [0] * 12
changes_by_day.each {|c| changes_by_month[c.first.to_date.months_ago] += c.last }

Expand Down Expand Up @@ -384,10 +384,10 @@ def graph_commits_per_month(repository)
end

def graph_commits_per_author(repository)
commits_by_author = repository.changesets.count(:all, :group => :committer)
commits_by_author = Changeset.count(:all, :group => :committer, :conditions => ["repository_id = ?", repository.id])
commits_by_author.to_a.sort! {|x, y| x.last <=> y.last}

changes_by_author = repository.changes.count(:all, :group => :committer)
changes_by_author = Change.count(:all, :group => :committer, :include => :changeset, :conditions => ["#{Changeset.table_name}.repository_id = ?", repository.id])
h = changes_by_author.inject({}) {|o, i| o[i.first] = i.last; o}

fields = commits_by_author.collect {|r| r.first}
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/watchers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def find_project
@watched = klass.find(params[:object_id])
@project = @watched.project
elsif params[:project_id]
@project = Project.visible.find(params[:project_id])
@project = Project.visible.find_by_param(params[:project_id])
end
rescue
render_404
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/wiki_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ def update
# Optimistic locking exception
flash.now[:error] = l(:notice_locking_conflict)
render :action => 'edit'
rescue ActiveRecord::RecordNotSaved
render :action => 'edit'
end

# rename a page
Expand Down
7 changes: 5 additions & 2 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,9 @@ def labelled_tabular_form_for(*args, &proc)
def labelled_form_for(*args, &proc)
args << {} unless args.last.is_a?(Hash)
options = args.last
if args.first.is_a?(Symbol)
options.merge!(:as => args.shift)
end
options.merge!({:builder => Redmine::Views::LabelledFormBuilder})
form_for(*args, &proc)
end
Expand Down Expand Up @@ -1060,7 +1063,7 @@ def email_delivery_enabled?
# +user+ can be a User or a string that will be scanned for an email address (eg. 'joe <[email protected]>')
def avatar(user, options = { })
if Setting.gravatar_enabled?
options.merge!({:ssl => (defined?(request) && request.ssl?), :default => Setting.gravatar_default})
options.merge!({:ssl => (request && request.ssl?), :default => Setting.gravatar_default})
email = nil
if user.respond_to?(:mail)
email = user.mail
Expand All @@ -1079,7 +1082,7 @@ def sanitize_anchor_name(anchor)

# Returns the javascript tags that are included in the html layout head
def javascript_heads
tags = javascript_include_tag(:defaults)
tags = javascript_include_tag('prototype', 'effects', 'dragdrop', 'controls', 'rails', 'application')
unless User.current.pref.warn_on_leaving_unsaved == '0'
tags << "\n".html_safe + javascript_tag("Event.observe(window, 'load', function(){ new WarnLeavingUnsaved('#{escape_javascript( l(:text_warn_on_leaving_unsaved) )}'); });")
end
Expand Down
6 changes: 3 additions & 3 deletions app/helpers/wiki_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ module WikiHelper

def wiki_page_options_for_select(pages, selected = nil, parent = nil, level = 0)
pages = pages.group_by(&:parent) unless pages.is_a?(Hash)
s = ''
s = ''.html_safe
if pages.has_key?(parent)
pages[parent].each do |page|
attrs = "value='#{page.id}'"
attrs << " selected='selected'" if selected == page
indent = (level > 0) ? ('&nbsp;' * level * 2 + '&#187; ') : nil
indent = (level > 0) ? ('&nbsp;' * level * 2 + '&#187; ') : ''

s << "<option #{attrs}>#{indent}#{h page.pretty_title}</option>\n" +
s << content_tag('option', (indent + h(page.pretty_title)).html_safe, :value => page.id.to_s, :selected => selected == page) +
wiki_page_options_for_select(pages, selected, page, level + 1)
end
end
Expand Down
22 changes: 9 additions & 13 deletions app/models/custom_field.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def possible_values_options(obj=nil)
when 'bool'
[[l(:general_text_Yes), '1'], [l(:general_text_No), '0']]
else
read_possible_values_utf8_encoded || []
possible_values || []
end
end

Expand All @@ -91,14 +91,20 @@ def possible_values(obj=nil)
when 'bool'
['1', '0']
else
read_possible_values_utf8_encoded
values = super()
if values.is_a?(Array)
values.each do |value|
value.force_encoding('UTF-8') if value.respond_to?(:force_encoding)
end
end
values
end
end

# Makes possible_values accept a multiline string
def possible_values=(arg)
if arg.is_a?(Array)
write_attribute(:possible_values, arg.compact.collect(&:strip).select {|v| !v.blank?})
super(arg.compact.collect(&:strip).select {|v| !v.blank?})
else
self.possible_values = arg.to_s.split(/[\n\r]+/)
end
Expand Down Expand Up @@ -218,14 +224,4 @@ def validate_field_value_format(value)
end
errs
end

def read_possible_values_utf8_encoded
values = read_attribute(:possible_values)
if values.is_a?(Array)
values.each do |value|
value.force_encoding('UTF-8') if value.respond_to?(:force_encoding)
end
end
values
end
end
Loading

0 comments on commit 5e57a1a

Please sign in to comment.