Skip to content

Commit 5e57a1a

Browse files
committed
Merged rails-3.2 branch.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9528 e93f8b46-1217-0410-a6f0-8f06a7374b81
1 parent 34e20c4 commit 5e57a1a

File tree

457 files changed

+20230
-5367
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

457 files changed

+20230
-5367
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
/config/database.yml
66
/config/email.yml
77
/config/initializers/session_store.rb
8+
/config/initializers/secret_token.rb
89
/coverage
910
/db/*.db
1011
/db/*.sqlite3

.hgignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ config/configuration.yml
77
config/database.yml
88
config/email.yml
99
config/initializers/session_store.rb
10+
config/initializers/secret_token.rb
1011
coverage
1112
db/*.db
1213
db/*.sqlite3

Gemfile

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
source :rubygems
1+
source 'http://rubygems.org'
22

3-
gem "rails", "2.3.14"
4-
gem "i18n", "~> 0.4.2"
3+
gem 'rails', '3.2.3'
4+
gem 'prototype-rails', '3.2.1'
5+
gem "i18n", "~> 0.6.0"
56
gem "coderay", "~> 1.0.6"
67
gem "fastercsv", "~> 1.5.0", :platforms => [:mri_18, :mingw_18, :jruby]
78
gem "tzinfo", "~> 0.3.31"
9+
gem "builder"
810

911
# Optional gem for LDAP authentication
1012
group :ldap do
@@ -14,6 +16,7 @@ end
1416
# Optional gem for OpenID authentication
1517
group :openid do
1618
gem "ruby-openid", "~> 2.1.4", :require => "openid"
19+
gem "rack-openid"
1720
end
1821

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

4649
platforms :mri_19, :mingw_19 do
4750
group :mysql do
48-
gem "mysql2", "~> 0.2.7"
51+
gem "mysql2", "~> 0.3.11"
4952
end
5053
end
5154

@@ -69,8 +72,9 @@ group :development do
6972
gem "rdoc", ">= 2.4.2"
7073
end
7174

75+
7276
group :test do
73-
gem "shoulda", "~> 2.10.3"
77+
gem "shoulda"
7478
gem "mocha"
7579
end
7680

Rakefile

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
1+
#!/usr/bin/env rake
12
# Add your own tasks in files placed in lib/tasks ending in .rake,
2-
# for example lib/tasks/switchtower.rake, and they will automatically be available to Rake.
3+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
34

4-
require(File.join(File.dirname(__FILE__), 'config', 'boot'))
5+
require File.expand_path('../config/application', __FILE__)
56

6-
require 'rake'
7-
require 'rake/testtask'
8-
9-
begin
10-
require 'rdoc/task'
11-
rescue LoadError
12-
# RDoc is not available
13-
end
14-
15-
require 'tasks/rails'
7+
RedmineApp::Application.load_tasks

app/controllers/application_controller.rb

Lines changed: 14 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,12 @@ class Unauthorized < Exception; end
2222

2323
class ApplicationController < ActionController::Base
2424
include Redmine::I18n
25+
26+
class_attribute :accept_api_auth_actions
27+
class_attribute :accept_rss_auth_actions
28+
class_attribute :model_object
2529

2630
layout 'base'
27-
exempt_from_layout 'builder', 'rsb'
2831

2932
protect_from_forgery
3033
def handle_unverified_request
@@ -68,7 +71,6 @@ def utf8nize!(obj)
6871
end
6972

7073
before_filter :user_setup, :check_if_login_required, :set_localization
71-
filter_parameter_logging :password
7274

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

80-
Redmine::Scm::Base.all.each do |scm|
81-
require_dependency "repository/#{scm.underscore}"
82-
end
83-
8482
def user_setup
8583
# Check the settings cache for each request
8684
Setting.check_cache
@@ -242,7 +240,7 @@ def find_project_from_association
242240
end
243241

244242
def find_model_object
245-
model = self.class.read_inheritable_attribute('model_object')
243+
model = self.class.model_object
246244
if model
247245
@object = model.find(params[:id])
248246
self.instance_variable_set('@' + controller_name.singularize, @object) if @object
@@ -252,7 +250,7 @@ def find_model_object
252250
end
253251

254252
def self.model_object(model)
255-
write_inheritable_attribute('model_object', model)
253+
self.model_object = model
256254
end
257255

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

389387
def self.accept_rss_auth(*actions)
390388
if actions.any?
391-
write_inheritable_attribute('accept_rss_auth_actions', actions)
389+
self.accept_rss_auth_actions = actions
392390
else
393-
read_inheritable_attribute('accept_rss_auth_actions') || []
391+
self.accept_rss_auth_actions || []
394392
end
395393
end
396394

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

401399
def self.accept_api_auth(*actions)
402400
if actions.any?
403-
write_inheritable_attribute('accept_api_auth_actions', actions)
401+
self.accept_api_auth_actions = actions
404402
else
405-
read_inheritable_attribute('accept_api_auth_actions') || []
403+
self.accept_api_auth_actions || []
406404
end
407405
end
408406

@@ -523,26 +521,12 @@ def render_validation_errors(objects)
523521
else
524522
@error_messages = objects.errors.full_messages
525523
end
526-
render :template => 'common/error_messages.api', :status => :unprocessable_entity, :layout => false
527-
end
528-
529-
# Overrides #default_template so that the api template
530-
# is used automatically if it exists
531-
def default_template(action_name = self.action_name)
532-
if api_request?
533-
begin
534-
return self.view_paths.find_template(default_template_name(action_name), 'api')
535-
rescue ::ActionView::MissingTemplate
536-
# the api template was not found
537-
# fallback to the default behaviour
538-
end
539-
end
540-
super
524+
render :template => 'common/error_messages.api', :status => :unprocessable_entity, :layout => nil
541525
end
542526

543-
# Overrides #pick_layout so that #render with no arguments
527+
# Overrides #_include_layout? so that #render with no arguments
544528
# doesn't use the layout for api requests
545-
def pick_layout(*args)
546-
api_request? ? nil : super
529+
def _include_layout?(*args)
530+
api_request? ? false : super
547531
end
548532
end

app/controllers/messages_controller.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,11 @@ def edit
9595
# Delete a messages
9696
def destroy
9797
(render_403; return false) unless @message.destroyable_by?(User.current)
98+
r = @message.to_param
9899
@message.destroy
99100
redirect_to @message.parent.nil? ?
100101
{ :controller => 'boards', :action => 'show', :project_id => @project, :id => @board } :
101-
{ :action => 'show', :id => @message.parent, :r => @message }
102+
{ :action => 'show', :id => @message.parent, :r => r }
102103
end
103104

104105
def quote

app/controllers/repositories_controller.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
require 'SVG/Graph/Bar'
1919
require 'SVG/Graph/BarHorizontal'
2020
require 'digest/sha1'
21+
require 'redmine/scm/adapters/abstract_adapter'
2122

2223
class ChangesetNotFound < Exception; end
2324
class InvalidRevisionParam < Exception; end
@@ -307,8 +308,7 @@ def find_project_repository
307308
@repository = @project.repository
308309
end
309310
(render_404; return false) unless @repository
310-
@path = params[:path].join('/') unless params[:path].nil?
311-
@path ||= ''
311+
@path = params[:path].is_a?(Array) ? params[:path].join('/') : params[:path].to_s
312312
@rev = params[:rev].blank? ? @repository.default_branch : params[:rev].to_s.strip
313313
@rev_to = params[:rev_to]
314314

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

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

@@ -384,10 +384,10 @@ def graph_commits_per_month(repository)
384384
end
385385

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

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

393393
fields = commits_by_author.collect {|r| r.first}

app/controllers/watchers_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def find_project
109109
@watched = klass.find(params[:object_id])
110110
@project = @watched.project
111111
elsif params[:project_id]
112-
@project = Project.visible.find(params[:project_id])
112+
@project = Project.visible.find_by_param(params[:project_id])
113113
end
114114
rescue
115115
render_404

app/controllers/wiki_controller.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ def update
163163
# Optimistic locking exception
164164
flash.now[:error] = l(:notice_locking_conflict)
165165
render :action => 'edit'
166+
rescue ActiveRecord::RecordNotSaved
167+
render :action => 'edit'
166168
end
167169

168170
# rename a page

app/helpers/application_helper.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -930,6 +930,9 @@ def labelled_tabular_form_for(*args, &proc)
930930
def labelled_form_for(*args, &proc)
931931
args << {} unless args.last.is_a?(Hash)
932932
options = args.last
933+
if args.first.is_a?(Symbol)
934+
options.merge!(:as => args.shift)
935+
end
933936
options.merge!({:builder => Redmine::Views::LabelledFormBuilder})
934937
form_for(*args, &proc)
935938
end
@@ -1060,7 +1063,7 @@ def email_delivery_enabled?
10601063
# +user+ can be a User or a string that will be scanned for an email address (eg. 'joe <[email protected]>')
10611064
def avatar(user, options = { })
10621065
if Setting.gravatar_enabled?
1063-
options.merge!({:ssl => (defined?(request) && request.ssl?), :default => Setting.gravatar_default})
1066+
options.merge!({:ssl => (request && request.ssl?), :default => Setting.gravatar_default})
10641067
email = nil
10651068
if user.respond_to?(:mail)
10661069
email = user.mail
@@ -1079,7 +1082,7 @@ def sanitize_anchor_name(anchor)
10791082

10801083
# Returns the javascript tags that are included in the html layout head
10811084
def javascript_heads
1082-
tags = javascript_include_tag(:defaults)
1085+
tags = javascript_include_tag('prototype', 'effects', 'dragdrop', 'controls', 'rails', 'application')
10831086
unless User.current.pref.warn_on_leaving_unsaved == '0'
10841087
tags << "\n".html_safe + javascript_tag("Event.observe(window, 'load', function(){ new WarnLeavingUnsaved('#{escape_javascript( l(:text_warn_on_leaving_unsaved) )}'); });")
10851088
end

0 commit comments

Comments
 (0)