Commit 216619d3 authored by Eric Davis's avatar Eric Davis

Merge branch 'unstable' into ticket/unstable/123-journalized

Conflicts:
	test/unit/journal_test.rb
	vendor/plugins/acts_as_journalized/lib/redmine/acts/journalized/permissions.rb
parents 0ca73a7f bf90848a
......@@ -24,3 +24,6 @@
/vendor/rails
*.rbc
doc/app
/.bundle
/Gemfile.lock
/.rvmrc*
......@@ -27,3 +27,7 @@ vendor/rails
*.rbc
.svn/
.git/
doc/app
/.bundle
/Gemfile.lock
/.rvmrc*
source :rubygems
gem "rails", "2.3.11"
gem "coderay", "~> 0.9.7"
gem "i18n", "~> 0.4.2"
gem "rubytree", "~> 0.5.2", :require => 'tree'
group :test do
gem 'shoulda', '~> 2.10.3'
gem 'edavis10-object_daddy', :require => 'object_daddy'
gem 'mocha'
end
group :openid do
gem "ruby-openid", '~> 2.1.4', :require => 'openid'
end
group :rmagick do
gem "rmagick", "~> 1.15.17"
end
# Use the commented pure ruby gems, if you have not the needed prerequisites on
# board to compile the native ones. Note, that their use is discouraged, since
# their integration is propbably not that well tested and their are slower in
# orders of magnitude compared to their native counterparts. You have been
# warned.
#
platforms :mri do
group :mysql do
gem "mysql"
# gem "ruby-mysql"
end
group :mysql2 do
gem "mysql2", "~> 0.2.7"
end
group :postgres do
gem "pg", "~> 0.9.0"
# gem "postgres-pr"
end
group :sqlite do
gem "sqlite3-ruby", "< 1.3", :require => "sqlite3"
# please tell me, if you are fond of a pure ruby sqlite3 binding
end
end
platforms :jruby do
gem "jruby-openssl"
group :mysql do
gem "activerecord-jdbcmysql-adapter"
end
group :postgres do
gem "activerecord-jdbcpostgresql-adapter"
end
group :sqlite do
gem "activerecord-jdbcsqlite3-adapter"
end
end
# Load plugins' Gemfiles
Dir.glob File.expand_path("../vendor/plugins/*/Gemfile", __FILE__) do |file|
puts "Loading #{file} ..." if $DEBUG # `ruby -d` or `bundle -v`
instance_eval File.read(file)
end
# 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'))
......@@ -7,4 +7,4 @@ require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
require 'tasks/rails'
\ No newline at end of file
require 'tasks/rails'
......@@ -66,7 +66,7 @@ class AccountController < ApplicationController
if token.save
Mailer.deliver_lost_password(token)
flash[:notice] = l(:notice_account_lost_email_sent)
redirect_to :action => 'login'
redirect_to :action => 'login', :back_url => home_url
return
end
end
......
......@@ -275,6 +275,7 @@ class ApplicationController < ActionController::Base
end
end
redirect_to default
false
end
def render_403(options={})
......
......@@ -38,8 +38,9 @@ class CustomFieldsController < ApplicationController
flash[:notice] = l(:notice_successful_create)
call_hook(:controller_custom_fields_new_after_save, :params => params, :custom_field => @custom_field)
redirect_to :action => 'index', :tab => @custom_field.class.name
else
@trackers = Tracker.find(:all, :order => 'position')
end
@trackers = Tracker.find(:all, :order => 'position')
end
def edit
......@@ -48,8 +49,9 @@ class CustomFieldsController < ApplicationController
flash[:notice] = l(:notice_successful_update)
call_hook(:controller_custom_fields_edit_after_save, :params => params, :custom_field => @custom_field)
redirect_to :action => 'index', :tab => @custom_field.class.name
else
@trackers = Tracker.find(:all, :order => 'position')
end
@trackers = Tracker.find(:all, :order => 'position')
end
def destroy
......
......@@ -74,10 +74,12 @@ class EnumerationsController < ApplicationController
# No associated objects
@enumeration.destroy
redirect_to :action => 'index'
return
elsif params[:reassign_to_id]
if reassign_to = @enumeration.class.find_by_id(params[:reassign_to_id])
@enumeration.destroy(reassign_to)
redirect_to :action => 'index'
return
end
end
@enumerations = @enumeration.class.find(:all) - [@enumeration]
......
......@@ -65,10 +65,12 @@ class IssueCategoriesController < ApplicationController
# No issue assigned to this category
@category.destroy
redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'categories'
return
elsif params[:todo]
reassign_to = @project.issue_categories.find_by_id(params[:reassign_to_id]) if params[:todo] == 'reassign'
@category.destroy(reassign_to)
redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'categories'
return
end
@categories = @project.issue_categories - [@category]
end
......
......@@ -123,6 +123,7 @@ class IssuesController < ApplicationController
def create
call_hook(:controller_issues_new_before_save, { :params => params, :issue => @issue })
IssueObserver.instance.send_notification = params[:send_notification] == '0' ? false : true
if @issue.save
attachments = Attachment.attach_files(@issue, params[:attachments])
render_attachment_warning_if_needed(@issue)
......@@ -158,7 +159,7 @@ class IssuesController < ApplicationController
def update
update_issue_from_params
JournalObserver.instance.send_notification = params[:send_notification] == '0' ? false : true
if @issue.save_issue_with_child_records(params, @time_entry)
render_attachment_warning_if_needed(@issue)
flash[:notice] = l(:notice_successful_update) unless @issue.current_journal == @journal
......@@ -198,6 +199,7 @@ class IssuesController < ApplicationController
journal = issue.init_journal(User.current, params[:notes])
issue.safe_attributes = attributes
call_hook(:controller_issues_bulk_edit_before_save, { :params => params, :issue => issue })
JournalObserver.instance.send_notification = params[:send_notification] == '0' ? false : true
unless issue.save
# Keep unsaved issue ids to display them in flash error
unsaved_issue_ids << issue.id
......
......@@ -38,9 +38,10 @@ class RolesController < ApplicationController
end
flash[:notice] = l(:notice_successful_create)
redirect_to :action => 'index'
else
@permissions = @role.setable_permissions
@roles = Role.find :all, :order => 'builtin, position'
end
@permissions = @role.setable_permissions
@roles = Role.find :all, :order => 'builtin, position'
end
def edit
......@@ -48,8 +49,9 @@ class RolesController < ApplicationController
if request.post? and @role.update_attributes(params[:role])
flash[:notice] = l(:notice_successful_update)
redirect_to :action => 'index'
else
@permissions = @role.setable_permissions
end
@permissions = @role.setable_permissions
end
def destroy
......
......@@ -36,16 +36,16 @@ class SettingsController < ApplicationController
end
flash[:notice] = l(:notice_successful_update)
redirect_to :action => 'edit', :tab => params[:tab]
return
end
@options = {}
@options[:user_format] = User::USER_FORMATS.keys.collect {|f| [User.current.name(f), f.to_s] }
@deliveries = ActionMailer::Base.perform_deliveries
else
@options = {}
@options[:user_format] = User::USER_FORMATS.keys.collect {|f| [User.current.name(f), f.to_s] }
@deliveries = ActionMailer::Base.perform_deliveries
@guessed_host_and_path = request.host_with_port.dup
@guessed_host_and_path << ('/'+ Redmine::Utils.relative_url_root.gsub(%r{^\/}, '')) unless Redmine::Utils.relative_url_root.blank?
@guessed_host_and_path = request.host_with_port.dup
@guessed_host_and_path << ('/'+ Redmine::Utils.relative_url_root.gsub(%r{^\/}, '')) unless Redmine::Utils.relative_url_root.blank?
Redmine::Themes.rescan
Redmine::Themes.rescan
end
end
def plugin
......@@ -54,9 +54,10 @@ class SettingsController < ApplicationController
Setting["plugin_#{@plugin.id}"] = params[:settings]
flash[:notice] = l(:notice_successful_update)
redirect_to :action => 'plugin', :id => @plugin.id
else
@partial = @plugin.settings[:partial]
@settings = Setting["plugin_#{@plugin.id}"]
end
@partial = @plugin.settings[:partial]
@settings = Setting["plugin_#{@plugin.id}"]
rescue Redmine::PluginNotFound
render_404
end
......
......@@ -28,7 +28,7 @@ module AttachmentsHelper
end
end
def to_utf8(str)
def to_utf8_for_attachments(str)
if str.respond_to?(:force_encoding)
str.force_encoding('UTF-8')
return str if str.valid_encoding?
......
......@@ -289,4 +289,14 @@ module IssuesHelper
end
export
end
def send_notification_option
content_tag(:p,
content_tag(:label,
l(:label_notify_member_plural)) +
hidden_field_tag('send_notification', '0') +
check_box_tag('send_notification', '1', true))
end
end
......@@ -116,7 +116,7 @@ module RepositoriesHelper
output
end
def to_utf8(str)
def to_utf8_for_repositories(str)
return str if str.nil?
str = to_utf8_internal(str)
if str.respond_to?(:force_encoding)
......@@ -217,45 +217,44 @@ module RepositoriesHelper
def darcs_field_tags(form, repository)
content_tag('p', form.text_field(:url, :label => :label_darcs_path, :size => 60, :required => true, :disabled => (repository && !repository.new_record?))) +
content_tag('p', form.select(:log_encoding, [nil] + Setting::ENCODINGS,
:label => 'Commit messages encoding', :required => true))
:label => l(:setting_commit_logs_encoding), :required => true))
end
def mercurial_field_tags(form, repository)
content_tag('p', form.text_field(:url, :label => :label_mercurial_path, :size => 60, :required => true, :disabled => (repository && !repository.root_url.blank?)) +
'<br />local repository (e.g. /hgrepo, c:\hgrepo)' ) +
content_tag('p', form.select(
:path_encoding, [nil] + Setting::ENCODINGS,
:label => 'Path encoding') +
'<br />Default: UTF-8')
'<br />' + l(:text_mercurial_repo_example)) +
content_tag('p', form.select(:path_encoding, [nil] + Setting::ENCODINGS,
:label => l(:label_path_encoding)) +
'<br />' + l(:text_default_encoding))
end
def git_field_tags(form, repository)
content_tag('p', form.text_field(:url, :label => :label_git_path, :size => 60, :required => true, :disabled => (repository && !repository.root_url.blank?)) +
'<br />a bare and local repository (e.g. /gitrepo, c:\gitrepo)') +
'<br />' + l(:text_git_repo_example)) +
content_tag('p', form.select(
:path_encoding, [nil] + Setting::ENCODINGS,
:label => 'Path encoding') +
'<br />Default: UTF-8')
:label => l(:label_path_encoding)) +
'<br />' + l(:text_default_encoding))
end
def cvs_field_tags(form, repository)
content_tag('p', form.text_field(:root_url, :label => :label_cvs_path, :size => 60, :required => true, :disabled => !repository.new_record?)) +
content_tag('p', form.text_field(:url, :label => :label_cvs_module, :size => 30, :required => true, :disabled => !repository.new_record?)) +
content_tag('p', form.select(:log_encoding, [nil] + Setting::ENCODINGS,
:label => 'Commit messages encoding', :required => true))
:label => l(:setting_commit_logs_encoding), :required => true))
end
def bazaar_field_tags(form, repository)
content_tag('p', form.text_field(:url, :label => :label_bazaar_path, :size => 60, :required => true, :disabled => (repository && !repository.new_record?))) +
content_tag('p', form.select(:log_encoding, [nil] + Setting::ENCODINGS,
:label => 'Commit messages encoding', :required => true))
:label => l(:setting_commit_logs_encoding), :required => true))
end
def filesystem_field_tags(form, repository)
content_tag('p', form.text_field(:url, :label => :label_filesystem_path, :size => 60, :required => true, :disabled => (repository && !repository.root_url.blank?))) +
content_tag('p', form.select(:path_encoding, [nil] + Setting::ENCODINGS,
:label => 'Path encoding') +
'<br />Default: UTF-8')
:label => l(:label_path_encoding)) +
'<br />' + l(:text_default_encoding))
end
end
......@@ -144,7 +144,7 @@ module TimelogHelper
headers = criterias.collect {|criteria| l(@available_criterias[criteria][:label]) }
headers += periods
headers << l(:label_total)
csv << headers.collect {|c| to_utf8(c) }
csv << headers.collect {|c| to_utf8_for_timelogs(c) }
# Content
report_criteria_to_csv(csv, criterias, periods, hours)
# Total row
......@@ -166,7 +166,7 @@ module TimelogHelper
hours_for_value = select_hours(hours, criterias[level], value)
next if hours_for_value.empty?
row = [''] * level
row << to_utf8(format_criteria_value(criterias[level], value))
row << to_utf8_for_timelogs(format_criteria_value(criterias[level], value))
row += [''] * (criterias.length - level - 1)
total = 0
periods.each do |period|
......@@ -183,7 +183,7 @@ module TimelogHelper
end
end
def to_utf8(s)
def to_utf8_for_timelogs(s)
@ic ||= Iconv.new(l(:general_csv_encoding), 'UTF-8')
begin; @ic.iconv(s.to_s); rescue; s.to_s; end
end
......
......@@ -16,7 +16,25 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class IssueObserver < ActiveRecord::Observer
attr_accessor :send_notification
def after_create(issue)
Mailer.deliver_issue_add(issue) if Setting.notified_events.include?('issue_added')
if self.send_notification
Mailer.deliver_issue_add(issue) if Setting.notified_events.include?('issue_added')
end
clear_notification
end
# Wrap send_notification so it defaults to true, when it's nil
def send_notification
return true if @send_notification.nil?
return @send_notification
end
private
# Need to clear the notification setting after each usage otherwise it might be cached
def clear_notification
@send_notification = true
end
end
......@@ -131,7 +131,10 @@ class WikiPage < ActiveRecord::Base
unless @updated_on
if time = read_attribute(:updated_on)
# content updated_on was eager loaded with the page
@updated_on = Time.parse(time) rescue nil
unless time.is_a? Time
time = Time.parse(time) rescue nil
end
@updated_on = time
else
@updated_on = content && content.updated_on
end
......
......@@ -31,7 +31,7 @@
<% else -%>
<table class="filecontent">
<thead>
<tr><th colspan="3" class="filename"><%=to_utf8 table_file.file_name %></th></tr>
<tr><th colspan="3" class="filename"><%=to_utf8_for_attachments table_file.file_name %></th></tr>
</thead>
<tbody>
<% table_file.each_line do |spacing, line| %>
......@@ -44,7 +44,7 @@
<th class="line-num"><%= line.nb_line_left %></th>
<th class="line-num"><%= line.nb_line_right %></th>
<td class="line-code <%= line.type_diff %>">
<pre><%=to_utf8 line.html_line %></pre>
<pre><%=to_utf8_for_attachments line.html_line %></pre>
</td>
</tr>
<% end -%>
......
......@@ -2,7 +2,7 @@
<table class="filecontent syntaxhl">
<tbody>
<% line_num = 1 %>
<% syntax_highlight(filename, to_utf8(content)).each_line do |line| %>
<% syntax_highlight(filename, to_utf8_for_attachments(content)).each_line do |line| %>
<tr><th class="line-num" id="L<%= line_num %>"><a href="#L<%= line_num %>"><%= line_num %></a></th><td class="line-code"><pre><%= line %></pre></td></tr>
<% line_num += 1 %>
<% end %>
......
......@@ -43,6 +43,8 @@
<%= render :partial => 'attachments/form' %>
</div>
</fieldset>
<%= send_notification_option %>
</div>
<%= f.hidden_field :lock_version %>
......
......@@ -84,6 +84,7 @@
<fieldset><legend><%= l(:field_notes) %></legend>
<%= text_area_tag 'notes', @notes, :cols => 60, :rows => 10, :class => 'wiki-edit' %>
<%= wikitoolbar_for 'notes' %>
<%= send_notification_option %>
</fieldset>
</div>
......
......@@ -5,6 +5,7 @@
<%= error_messages_for 'issue' %>
<div class="box">
<%= render :partial => 'issues/form', :locals => {:f => f} %>
<%= send_notification_option %>
</div>
<%= submit_tag l(:button_create) %>
<%= submit_tag l(:button_create_and_continue), :name => 'continue' %>
......
<h3><%=l(:label_my_account)%></h3>
<p><%=l(:field_login)%>: <strong><%= @user.login %></strong><br />
<p><%=l(:field_login)%>: <strong><%= link_to_user(@user, :format => :username) %></strong><br />
<%=l(:field_created_on)%>: <%= format_time(@user.created_on) %></p>
......@@ -19,7 +19,7 @@
<h4><%= l(:label_api_access_key) %></h4>
<div>
<%= link_to_function(l(:button_show), "$('api-access-key').toggle();")%>
<pre id='api-access-key' class='autoscroll'><%= @user.api_key %></pre>
<pre id='api-access-key' class='autoscroll'><%= h(@user.api_key) %></pre>
</div>
<%= javascript_tag("$('api-access-key').hide();") %>
<p>
......
......@@ -14,7 +14,7 @@
<table class="filecontent annotate syntaxhl">
<tbody>
<% line_num = 1 %>
<% syntax_highlight(@path, to_utf8(@annotate.content)).each_line do |line| %>
<% syntax_highlight(@path, to_utf8_for_repositories(@annotate.content)).each_line do |line| %>
<% revision = @annotate.revisions[line_num-1] %>
<tr class="bloc-<%= revision.nil? ? 0 : colors[revision.identifier || revision.revision] %>">
<th class="line-num" id="L<%= line_num %>"><a href="#L<%= line_num %>"><%= line_num %></a></th>
......
......@@ -36,6 +36,15 @@ module Rails
class Boot
def run
load_initializer
# This block was added for bundler support while following setup
# instructions from http://gembundler.com/rails23.html
Rails::Initializer.class_eval do
def load_gems
@bundler_loaded ||= Bundler.require :default, Rails.env
end
end
Rails::Initializer.run(:set_load_path)
end
end
......@@ -62,8 +71,12 @@ module Rails
gem 'rails'
end
rescue Gem::LoadError => load_error
$stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
exit 1
if load_error.message =~ /Could not find RubyGem rails/
STDERR.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
exit 1
else
raise
end
end
class << self
......@@ -106,60 +119,5 @@ module Rails
end
end
# TODO: Workaround for #7013 to be removed for 1.2.0
# Loads i18n 0.4.2 before Rails loads any more recent gem
# 0.5.0 is not compatible with the old interpolation syntax
# Plugins will have to migrate to the new syntax for 1.2.0
require 'rubygems'
begin
gem 'i18n', '0.4.2'
rescue Gem::LoadError => load_error
$stderr.puts %(Missing the i18n 0.4.2 gem. Please `gem install -v=0.4.2 i18n`)
exit 1
end
# TODO: Workaround for rubygems > 1.5 compatibility (#133), to be removed
# for Rails > 2.3.5
#
# Fixes the deprecation warning about removal of version_requirements for
# rubygems < 1.5 and provide a workaround for rubygems >= 1.5 where that
# method was finally removed.
module Rails
# See lib/gems/1.8/gems/rails-2.3.5/lib/rails/gem_dependency.rb
class GemDependency < Gem::Dependency
def dependencies
return [] if framework_gem?
return [] unless installed?
specification.dependencies.reject do |dependency|
dependency.type == :development
end.map do |dependency|
GemDependency.new(dependency.name,
:requirement => (dependency.respond_to?(:requirement) ?
dependency.requirement :
dependency.version_requirements))
end
end
if method_defined?(:requirement)
# rubygem > 1.5
def requirement
req = super
req unless req == Gem::Requirement.default
end
# bypass passenger error
alias :version_requirements :requirement
else
# rubygem < 1.5
def requirement
req = version_requirements
req unless req == Gem::Requirement.default
end
end
end
end
# working around deprecation in RubyGems 1.6
require 'thread'
# All that for this:
Rails.boot!
......@@ -50,11 +50,8 @@ Rails::Initializer.run do |config|
# It will automatically turn deliveries on
config.action_mailer.perform_deliveries = false
config.gem 'rubytree', :lib => 'tree'
config.gem 'coderay', :version => '~>0.9.7'
# Load any local configuration that is kept out of source control
# (e.g. gems, patches).
# (e.g. patches).
if File.exists?(File.join(File.dirname(__FILE__), 'additional_environment.rb'))
instance_eval File.read(File.join(File.dirname(__FILE__), 'additional_environment.rb'))
end
......
......@@ -3,14 +3,15 @@
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the webserver when you make code changes.
config.cache_classes = false
config.cache_classes = false
# Log error messages when you accidentally call methods on nil.
config.whiny_nils = true
config.whiny_nils = true
# Show full error reports and disable caching
config.action_controller.consider_all_requests_local = true
config.action_view.debug_rjs = true
config.action_controller.perform_caching = false
# Don't care if the mailer can't send
config.action_mailer.raise_delivery_errors = false
config.action_mailer.raise_delivery_errors = false
\ No newline at end of file
......@@ -23,7 +23,3 @@ config.action_controller.session = {
# Skip protect_from_forgery in requests http://m.onkey.org/2007/9/28/csrf-protection-for-your-existing-rails-application
config.action_controller.allow_forgery_protection = false
config.gem "shoulda", :version => "~> 2.10.3"
config.gem "edavis10-object_daddy", :lib => "object_daddy"
config.gem "mocha"
......@@ -3,3 +3,4 @@ I18n.default_locale = 'en'
I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks)
require 'redmine'