Commit be43b9b3 authored by jplang's avatar jplang

Merged rails-3.2 branch.

git-svn-id: https://svn.redmine.org/redmine/trunk@9528 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent a631c49b
......@@ -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
......
......@@ -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
......
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
......@@ -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
......@@ -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
......@@ -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
......
#!/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
......@@ -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
......@@ -68,7 +71,6 @@ class ApplicationController < ActionController::Base
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
......@@ -77,10 +79,6 @@ class ApplicationController < ActionController::Base
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
......@@ -242,7 +240,7 @@ class ApplicationController < ActionController::Base
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
......@@ -252,7 +250,7 @@ class ApplicationController < ActionController::Base
end
def self.model_object(model)
write_inheritable_attribute('model_object', model)
self.model_object = model
end
# Filter for bulk issue operations
......@@ -388,9 +386,9 @@ class ApplicationController < ActionController::Base
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
......@@ -400,9 +398,9 @@ class ApplicationController < ActionController::Base
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
......@@ -523,26 +521,12 @@ class ApplicationController < ActionController::Base
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
......@@ -95,10 +95,11 @@ class MessagesController < ApplicationController
# 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
......
......@@ -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
......@@ -307,8 +308,7 @@ class RepositoriesController < ApplicationController
@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]
......@@ -343,15 +343,15 @@ class RepositoriesController < ApplicationController
@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 }
......@@ -384,10 +384,10 @@ class RepositoriesController < ApplicationController
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}
......
......@@ -109,7 +109,7 @@ private
@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
......
......@@ -163,6 +163,8 @@ class WikiController < ApplicationController
# Optimistic locking exception
flash.now[:error] = l(:notice_locking_conflict)
render :action => 'edit'
rescue ActiveRecord::RecordNotSaved
render :action => 'edit'
end
# rename a page
......
......@@ -930,6 +930,9 @@ module ApplicationHelper
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
......@@ -1060,7 +1063,7 @@ module ApplicationHelper
# +user+ can be a User or a string that will be scanned for an email address (eg. 'joe <joe@foo.bar>')
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
......@@ -1079,7 +1082,7 @@ module ApplicationHelper
# 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
......
......@@ -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
......
......@@ -80,7 +80,7 @@ class CustomField < ActiveRecord::Base
when 'bool'
[[l(:general_text_Yes), '1'], [l(:general_text_No), '0']]
else
read_possible_values_utf8_encoded || []
possible_values || []
end
end
......@@ -91,14 +91,20 @@ class CustomField < ActiveRecord::Base
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
......@@ -218,14 +224,4 @@ class CustomField < ActiveRecord::Base
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
......@@ -246,8 +246,8 @@ class Issue < ActiveRecord::Base
write_attribute(:description, arg)
end
# Overrides attributes= so that project and tracker get assigned first
def attributes_with_project_and_tracker_first=(new_attributes, *args)
# Overrides assign_attributes so that project and tracker get assigned first
def assign_attributes_with_project_and_tracker_first(new_attributes, *args)
return if new_attributes.nil?
attrs = new_attributes.dup
attrs.stringify_keys!
......@@ -257,10 +257,10 @@ class Issue < ActiveRecord::Base
send "#{attr}=", attrs.delete(attr)
end
end
send :attributes_without_project_and_tracker_first=, attrs, *args
send :assign_attributes_without_project_and_tracker_first, attrs, *args
end
# Do not redefine alias chain on reload (see #4838)
alias_method_chain(:attributes=, :project_and_tracker_first) unless method_defined?(:attributes_without_project_and_tracker_first=)
alias_method_chain(:assign_attributes, :project_and_tracker_first) unless method_defined?(:assign_attributes_without_project_and_tracker_first)
def estimated_hours=(h)
write_attribute :estimated_hours, (h.is_a?(String) ? h.to_hours : h)
......@@ -350,7 +350,7 @@ class Issue < ActiveRecord::Base
end
# mass-assignment security bypass
self.send :attributes=, attrs, false
assign_attributes attrs, :without_protection => true
end
def done_ratio
......@@ -921,7 +921,7 @@ class Issue < ActiveRecord::Base
p.estimated_hours = nil if p.estimated_hours == 0.0
# ancestors will be recursively updated
p.save(false)
p.save(:validate => false)
end
end
......
......@@ -15,7 +15,9 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class MailHandler < ActionMailer::Base
require 'vendor/tmail'
class MailHandler
include ActionView::Helpers::SanitizeHelper
include Redmine::I18n
......@@ -39,7 +41,14 @@ class MailHandler < ActionMailer::Base
@@handler_options[:allow_override] << 'status' unless @@handler_options[:issue].has_key?(:status)
@@handler_options[:no_permission_check] = (@@handler_options[:no_permission_check].to_s == '1' ? true : false)
super email
mail = TMail::Mail.parse(email)
mail.base64_decode
new.receive(mail)
end
def logger
Rails.logger
end
cattr_accessor :ignored_emails_headers
......
This diff is collapsed.
......@@ -272,6 +272,10 @@ class Project < ActiveRecord::Base
end
end
def self.find_by_param(*args)
self.find(*args)
end
def reload(*args)
@shared_versions = nil
@rolled_up_versions = nil
......
......@@ -57,7 +57,7 @@ class Repository < ActiveRecord::Base
end
alias :attributes_without_extra_info= :attributes=
def attributes=(new_attributes, guard_protected_attributes = true)
def attributes=(new_attributes)
return if new_attributes.nil?
attributes = new_attributes.dup
attributes.stringify_keys!
......@@ -72,7 +72,7 @@ class Repository < ActiveRecord::Base
end
end
send :attributes_without_extra_info=, p, guard_protected_attributes
send :attributes_without_extra_info=, p
if p_extra.keys.any?
merge_extra_info(p_extra)
end
......
......@@ -36,7 +36,7 @@ class Role < ActiveRecord::Base
before_destroy :check_deletable
has_many :workflows, :dependent => :delete_all do
def copy(source_role)
Workflow.copy(nil, source_role, nil, proxy_owner)
Workflow.copy(nil, source_role, nil, proxy_association.owner)
end
end
......
......@@ -20,7 +20,7 @@ class Tracker < ActiveRecord::Base
has_many :issues
has_many :workflows, :dependent => :delete_all do
def copy(source_tracker)
Workflow.copy(source_tracker, nil, proxy_owner, nil)
Workflow.copy(source_tracker, nil, proxy_association.owner, nil)
end
end
......
<%= call_hook :view_account_login_top %>
<div id="login-form">
<% form_tag({:action=> "login"}) do %>
<%= form_tag({:action=> "login"}) do %>
<%= back_url_hidden_field_tag %>
<table>
<tr>
......
<h2><%=l(:label_password_lost)%></h2>
<div class="box">
<% form_tag({:action=> "lost_password"}, :class => "tabular") do %>
<%= form_tag({:action=> "lost_password"}, :class => "tabular") do %>
<p><label for="mail"><%=l(:field_mail)%> <span class="required">*</span></label>
<%= text_field_tag 'mail', nil, :size => 40 %>
......
......@@ -2,7 +2,7 @@
<%= error_messages_for 'user' %>
<% form_tag({:token => @token.value}) do %>
<%= form_tag({:token => @token.value}) do %>
<div class="box tabular">
<p><label for="new_password"><%=l(:field_new_password)%> <span class="required">*</span></label>
<%= password_field_tag 'new_password', nil, :size => 25 %>
......