Merge branch 'release-v2.2.0' into stable

This commit is contained in:
Holger Just 2011-08-27 18:53:47 +02:00
commit 296de66847
81 changed files with 360 additions and 2094 deletions

View File

@ -1,11 +1,13 @@
source :rubygems
gem "rails", "2.3.12"
gem "rails", "2.3.14"
gem "coderay", "~> 0.9.7"
gem "i18n", "~> 0.4.2"
gem "rubytree", "~> 0.5.2", :require => 'tree'
gem "rdoc", ">= 2.4.2"
# Needed only on RUBY_VERSION = 1.8, ruby 1.9+ compatible interpreters should bring their csv
gem "fastercsv", "~> 1.5.0", :platforms => [:ruby_18, :jruby, :mingw_18]
group :test do
gem 'shoulda', '~> 2.10.3'
@ -29,7 +31,7 @@ end
# 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"

View File

@ -38,7 +38,7 @@ class AdminController < ApplicationController
end
def plugins
@plugins = Redmine::Plugin.all
@plugins = Redmine::Plugin.all.sort
end
# Loads the default configuration

View File

@ -268,5 +268,5 @@ private
project.members << m
end
end
end

View File

@ -25,7 +25,7 @@ module CalendarsHelper
"#{month_name(target_month)}"
end
link_to_month(('&#171; ' + name), target_year, target_month, options)
link_to_month(('&#171; ' + h(name)), target_year, target_month, options)
end
def link_to_next_month(year, month, options={})
@ -41,10 +41,10 @@ module CalendarsHelper
"#{month_name(target_month)}"
end
link_to_month((name + ' &#187;'), target_year, target_month, options)
link_to_month((h(name) + ' &#187;'), target_year, target_month, options)
end
def link_to_month(link_name, year, month, options={})
link_to_content_update(h(link_name), params.merge(:year => year, :month => month))
link_to_content_update(link_name, params.merge(:year => year, :month => month))
end
end

View File

@ -99,7 +99,7 @@ module RepositoriesHelper
:path => path_param,
:rev => @changeset.identifier) unless c.action == 'D'
text << " - #{h(c.revision)}" unless c.revision.blank?
text << ' (' + link_to('diff', :controller => 'repositories',
text << ' (' + link_to(l(:label_diff), :controller => 'repositories',
:action => 'diff',
:id => @project,
:path => path_param,

View File

@ -18,7 +18,7 @@ class Change < ActiveRecord::Base
before_save :init_path
delegate :repository_encoding, :to => :changeset, :allow_nil => true, :prefix => true
def relative_path
changeset.repository.relative_path(path)
end

View File

@ -82,7 +82,7 @@ class Changeset < ActiveRecord::Base
nil
end
end
# Committer of the Changeset
#
# Attribute reader for committer that encodes the committer string to
@ -278,7 +278,7 @@ class Changeset < ActiveRecord::Base
end
end
else
txtar = ""
begin
txtar += Iconv.new('UTF-8', normalized_encoding).iconv(str)

View File

@ -549,7 +549,7 @@ class Issue < ActiveRecord::Base
def nested_set_span
rgt - lft
end
# Returns a string of css classes that apply to the issue
def css_classes
s = "issue status-#{status.position} priority-#{priority.position}"

View File

@ -26,7 +26,7 @@ class WikiPage < ActiveRecord::Base
:datetime => :created_on,
:url => Proc.new {|o| {:controller => 'wiki', :action => 'show', :project_id => o.wiki.project, :id => o.title}}
acts_as_searchable :columns => ['title', 'text'],
acts_as_searchable :columns => ["#{WikiPage.table_name}.title", "#{WikiContent.table_name}.text"],
:include => [{:wiki => :project}, :content],
:project_key => "#{Wiki.table_name}.project_id"

View File

@ -7,7 +7,7 @@
<p>
<%= l(:label_version) %> <%= link_to h(@annotate.content.version), :action => 'show', :id => @page.title, :version => @annotate.content.version %>
<em>(<%= h(@annotate.content.author ? @annotate.content.author.name : "anonyme") %>, <%= format_time(@annotate.content.updated_on) %>)</em>
<em>(<%= h(@annotate.content.author ? @annotate.content.author.name : l(:label_user_anonymous)) %>, <%= format_time(@annotate.content.updated_on) %>)</em>
</p>
<% colors = Hash.new {|k,v| k[v] = (k.size % 12) } %>

View File

@ -6,10 +6,10 @@
<p>
<%= l(:label_version) %> <%= link_to @diff.content_from.version, :action => 'show', :id => @page.title, :project_id => @page.project, :version => @diff.content_from.version %>
<em>(<%= @diff.content_from.author ? link_to_user(@diff.content_from.author) : "anonyme" %>, <%= format_time(@diff.content_from.updated_on) %>)</em>
<em>(<%= @diff.content_from.author ? link_to_user(@diff.content_from.author) : l(:label_user_anonymous) %>, <%= format_time(@diff.content_from.updated_on) %>)</em>
&#8594;
<%= l(:label_version) %> <%= link_to @diff.content_to.version, :action => 'show', :id => @page.title, :project_id => @page.project, :version => @diff.content_to.version %>/<%= @page.content.version %>
<em>(<%= @diff.content_to.author ? link_to_user(@diff.content_to.author) : "anonyme" %>, <%= format_time(@diff.content_to.updated_on) %>)</em>
<em>(<%= @diff.content_to.author ? link_to_user(@diff.content_to.author) : l(:label_user_anonymous) %>, <%= format_time(@diff.content_to.updated_on) %>)</em>
</p>
<div class="text-diff">

View File

@ -17,11 +17,11 @@
<p>
<%= link_to(('&#171; ' + l(:label_previous)), :action => 'show', :id => @page.title, :project_id => @page.project, :version => (@content.version - 1)) + " - " if @content.version > 1 %>
<%= "#{l(:label_version)} #{@content.version}/#{@page.content.version}" %>
<%= '(' + link_to('diff', :controller => 'wiki', :action => 'diff', :id => @page.title, :project_id => @page.project, :version => @content.version) + ')' if @content.version > 1 %> -
<%= '(' + link_to(l(:label_diff), :controller => 'wiki', :action => 'diff', :id => @page.title, :project_id => @page.project, :version => @content.version) + ')' if @content.version > 1 %> -
<%= link_to((l(:label_next) + ' &#187;'), :action => 'show', :id => @page.title, :project_id => @page.project, :version => (@content.version + 1)) + " - " if @content.version < @page.content.version %>
<%= link_to(l(:label_current_version), :action => 'show', :id => @page.title, :project_id => @page.project) %>
<br />
<em><%= @content.author ? link_to_user(@content.author) : "anonyme" %>, <%= format_time(@content.updated_on) %> </em><br />
<em><%= @content.author ? link_to_user(@content.author) : l(:label_user_anonymous) %>, <%= format_time(@content.updated_on) %> </em><br />
<%=h @content.comments %>
</p>
<hr />

View File

@ -18,7 +18,7 @@
# ENV['RAILS_ENV'] ||= 'production'
# Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION = '2.3.12' unless defined? RAILS_GEM_VERSION
RAILS_GEM_VERSION = '2.3.14' unless defined? RAILS_GEM_VERSION
# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')
@ -63,6 +63,10 @@ Rails::Initializer.run do |config|
# It will automatically turn deliveries on
config.action_mailer.perform_deliveries = false
# Use redmine's custom plugin locater
require File.join(RAILS_ROOT, "lib/redmine_plugin_locator")
config.plugin_locators << RedminePluginLocator
# Load any local configuration that is kept out of source control
# (e.g. patches).
if File.exists?(File.join(File.dirname(__FILE__), 'additional_environment.rb'))

View File

@ -963,3 +963,4 @@ bg:
label_notify_member_plural: Email issue updates
label_path_encoding: Кодиране на пътищата
text_mercurial_repo_example: локално хранилище (например /hgrepo, c:\hgrepo)
label_diff: diff

View File

@ -977,3 +977,4 @@ bs:
label_notify_member_plural: Email issue updates
label_path_encoding: Path encoding
text_mercurial_repo_example: local repository (e.g. /hgrepo, c:\hgrepo)
label_diff: diff

View File

@ -966,3 +966,4 @@ ca:
label_notify_member_plural: Email issue updates
label_path_encoding: Path encoding
text_mercurial_repo_example: local repository (e.g. /hgrepo, c:\hgrepo)
label_diff: diff

View File

@ -1187,3 +1187,4 @@ cs:
label_notify_member_plural: Email issue updates
label_path_encoding: Path encoding
text_mercurial_repo_example: local repository (e.g. /hgrepo, c:\hgrepo)
label_diff: diff

View File

@ -979,3 +979,4 @@ da:
label_notify_member_plural: Email issue updates
label_path_encoding: Path encoding
text_mercurial_repo_example: local repository (e.g. /hgrepo, c:\hgrepo)
label_diff: diff

View File

@ -980,3 +980,4 @@ de:
label_notify_member_plural: Email issue updates
label_path_encoding: Path encoding
text_mercurial_repo_example: local repository (e.g. /hgrepo, c:\hgrepo)
label_diff: diff

View File

@ -963,3 +963,4 @@ el:
label_notify_member_plural: Email issue updates
label_path_encoding: Path encoding
text_mercurial_repo_example: local repository (e.g. /hgrepo, c:\hgrepo)
label_diff: diff

View File

@ -967,3 +967,4 @@ en-GB:
label_notify_member_plural: Email issue updates
label_path_encoding: Path encoding
text_mercurial_repo_example: local repository (e.g. /hgrepo, c:\hgrepo)
label_diff: diff

View File

@ -678,6 +678,7 @@ en:
label_statistics: Statistics
label_commits_per_month: Commits per month
label_commits_per_author: Commits per author
label_diff: diff
label_view_diff: View differences
label_diff_inline: inline
label_diff_side_by_side: side by side

View File

@ -1000,3 +1000,4 @@ es:
label_notify_member_plural: Email issue updates
label_path_encoding: Path encoding
text_mercurial_repo_example: local repository (e.g. /hgrepo, c:\hgrepo)
label_diff: diff

View File

@ -967,3 +967,4 @@ eu:
label_notify_member_plural: Email issue updates
label_path_encoding: Path encoding
text_mercurial_repo_example: local repository (e.g. /hgrepo, c:\hgrepo)
label_diff: diff

View File

@ -966,3 +966,4 @@ fa:
label_notify_member_plural: Email issue updates
label_path_encoding: Path encoding
text_mercurial_repo_example: local repository (e.g. /hgrepo, c:\hgrepo)
label_diff: diff

View File

@ -984,3 +984,4 @@ fi:
label_notify_member_plural: Email issue updates
label_path_encoding: Path encoding
text_mercurial_repo_example: local repository (e.g. /hgrepo, c:\hgrepo)
label_diff: diff

View File

@ -672,6 +672,7 @@ fr:
label_statistics: Statistiques
label_commits_per_month: Commits par mois
label_commits_per_author: Commits par auteur
label_diff: diff
label_view_diff: Voir les différences
label_diff_inline: en ligne
label_diff_side_by_side: côte à côte

View File

@ -975,3 +975,4 @@ gl:
label_notify_member_plural: Email issue updates
label_path_encoding: Path encoding
text_mercurial_repo_example: local repository (e.g. /hgrepo, c:\hgrepo)
label_diff: diff

View File

@ -968,3 +968,4 @@ he:
label_notify_member_plural: Email issue updates
label_path_encoding: Path encoding
text_mercurial_repo_example: local repository (e.g. /hgrepo, c:\hgrepo)
label_diff: diff

View File

@ -970,3 +970,4 @@ hr:
label_notify_member_plural: Email issue updates
label_path_encoding: Path encoding
text_mercurial_repo_example: local repository (e.g. /hgrepo, c:\hgrepo)
label_diff: diff

View File

@ -982,3 +982,4 @@
label_notify_member_plural: Email issue updates
label_path_encoding: Path encoding
text_mercurial_repo_example: local repository (e.g. /hgrepo, c:\hgrepo)
label_diff: diff

View File

@ -971,3 +971,4 @@ id:
label_notify_member_plural: Email issue updates
label_path_encoding: Path encoding
text_mercurial_repo_example: local repository (e.g. /hgrepo, c:\hgrepo)
label_diff: diff

View File

@ -964,3 +964,4 @@ it:
label_notify_member_plural: Email issue updates
label_path_encoding: Path encoding
text_mercurial_repo_example: local repository (e.g. /hgrepo, c:\hgrepo)
label_diff: diff

View File

@ -985,3 +985,4 @@ ja:
label_notify_member_plural: Email issue updates
label_path_encoding: Path encoding
text_mercurial_repo_example: local repository (e.g. /hgrepo, c:\hgrepo)
label_diff: diff

View File

@ -1015,3 +1015,4 @@ ko:
label_notify_member_plural: Email issue updates
label_path_encoding: Path encoding
text_mercurial_repo_example: local repository (e.g. /hgrepo, c:\hgrepo)
label_diff: diff

View File

@ -1023,3 +1023,4 @@ lt:
label_notify_member_plural: Email issue updates
label_path_encoding: Path encoding
text_mercurial_repo_example: local repository (e.g. /hgrepo, c:\hgrepo)
label_diff: diff

View File

@ -958,3 +958,4 @@ lv:
label_notify_member_plural: Email issue updates
label_path_encoding: Path encoding
text_mercurial_repo_example: local repository (e.g. /hgrepo, c:\hgrepo)
label_diff: diff

View File

@ -963,3 +963,4 @@ mk:
label_notify_member_plural: Email issue updates
label_path_encoding: Path encoding
text_mercurial_repo_example: local repository (e.g. /hgrepo, c:\hgrepo)
label_diff: diff

View File

@ -964,3 +964,4 @@ mn:
label_notify_member_plural: Email issue updates
label_path_encoding: Path encoding
text_mercurial_repo_example: local repository (e.g. /hgrepo, c:\hgrepo)
label_diff: diff

View File

@ -945,3 +945,4 @@ nl:
label_notify_member_plural: Email issue updates
label_path_encoding: Path encoding
text_mercurial_repo_example: local repository (e.g. /hgrepo, c:\hgrepo)
label_diff: diff

View File

@ -950,3 +950,4 @@
label_notify_member_plural: Email issue updates
label_path_encoding: Path encoding
text_mercurial_repo_example: local repository (e.g. /hgrepo, c:\hgrepo)
label_diff: diff

View File

@ -980,3 +980,4 @@ pl:
label_notify_member_plural: Email issue updates
label_path_encoding: Path encoding
text_mercurial_repo_example: local repository (e.g. /hgrepo, c:\hgrepo)
label_diff: diff

View File

@ -987,3 +987,4 @@ pt-BR:
label_git_path: Caminho para o diretório .git
label_mercurial_path: Diretório raiz
label_diff: diff

View File

@ -967,3 +967,4 @@ pt:
label_notify_member_plural: Email issue updates
label_path_encoding: Path encoding
text_mercurial_repo_example: local repository (e.g. /hgrepo, c:\hgrepo)
label_diff: diff

View File

@ -956,3 +956,4 @@ ro:
label_notify_member_plural: Email issue updates
label_path_encoding: Path encoding
text_mercurial_repo_example: local repository (e.g. /hgrepo, c:\hgrepo)
label_diff: diff

View File

@ -1076,3 +1076,4 @@ ru:
label_notify_member_plural: Email issue updates
label_path_encoding: Path encoding
text_mercurial_repo_example: local repository (e.g. /hgrepo, c:\hgrepo)
label_diff: diff

View File

@ -958,3 +958,4 @@ sk:
label_notify_member_plural: Email issue updates
label_path_encoding: Path encoding
text_mercurial_repo_example: local repository (e.g. /hgrepo, c:\hgrepo)
label_diff: diff

View File

@ -959,3 +959,4 @@ sl:
label_notify_member_plural: Email issue updates
label_path_encoding: Path encoding
text_mercurial_repo_example: local repository (e.g. /hgrepo, c:\hgrepo)
label_diff: diff

View File

@ -963,3 +963,4 @@ sr-YU:
label_notify_member_plural: Email issue updates
label_path_encoding: Path encoding
text_mercurial_repo_example: local repository (e.g. /hgrepo, c:\hgrepo)
label_diff: diff

View File

@ -964,3 +964,4 @@ sr:
label_notify_member_plural: Email issue updates
label_path_encoding: Path encoding
text_mercurial_repo_example: local repository (e.g. /hgrepo, c:\hgrepo)
label_diff: diff

View File

@ -1005,3 +1005,4 @@ sv:
label_notify_member_plural: Email issue updates
label_path_encoding: Path encoding
text_mercurial_repo_example: local repository (e.g. /hgrepo, c:\hgrepo)
label_diff: diff

View File

@ -960,3 +960,4 @@ th:
label_notify_member_plural: Email issue updates
label_path_encoding: Path encoding
text_mercurial_repo_example: local repository (e.g. /hgrepo, c:\hgrepo)
label_diff: diff

View File

@ -982,3 +982,4 @@ tr:
label_notify_member_plural: Email issue updates
label_path_encoding: Path encoding
text_mercurial_repo_example: local repository (e.g. /hgrepo, c:\hgrepo)
label_diff: diff

View File

@ -959,3 +959,4 @@ uk:
label_notify_member_plural: Email issue updates
label_path_encoding: Path encoding
text_mercurial_repo_example: local repository (e.g. /hgrepo, c:\hgrepo)
label_diff: diff

View File

@ -1014,3 +1014,4 @@ vi:
label_notify_member_plural: Email issue updates
label_path_encoding: Path encoding
text_mercurial_repo_example: local repository (e.g. /hgrepo, c:\hgrepo)
label_diff: diff

View File

@ -1045,3 +1045,4 @@
label_notify_member_plural: Email issue updates
label_path_encoding: Path encoding
text_mercurial_repo_example: local repository (e.g. /hgrepo, c:\hgrepo)
label_diff: diff

View File

@ -977,3 +977,4 @@ zh:
label_notify_member_plural: Email issue updates
label_path_encoding: Path encoding
text_mercurial_repo_example: local repository (e.g. /hgrepo, c:\hgrepo)
label_diff: diff

View File

@ -34,7 +34,7 @@ class UpdateJournalsForActsAsJournalized < ActiveRecord::Migration
rescue ActiveRecord::RecordInvalid => ex
puts "Error saving: #{j.class.to_s}##{j.id} - #{ex.message}"
end
end
end
end

View File

@ -51,14 +51,14 @@ class BuildInitialJournalsForActsAsJournalized < ActiveRecord::Migration
end
end
end
end
end
end
def self.down
# No-op
end
end

View File

@ -34,15 +34,15 @@ class AddChangesFromJournalDetailsForActsAsJournalized < ActiveRecord::Migration
rescue ActiveRecord::RecordInvalid => ex
puts "Error saving: #{journal.class.to_s}##{journal.id} - #{ex.message}"
end
end
end
end
def self.down
# No-op
end
end

View File

@ -1,3 +1,16 @@
#-- copyright
# ChiliProject is a project management system.
#
# Copyright (C) 2010-2011 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# See doc/COPYRIGHT.rdoc for more details.
#++
class RemoveDoubleInitialWikiContentJournals < ActiveRecord::Migration
def self.up
# Remove the newest initial WikiContentJournal (the one erroneously created by a former migration) if there are more than one

View File

@ -1,5 +1,19 @@
= ChiliProject changelog
== 2011-08-27 v2.2.0
* Bug #256: requires_redmine_plugin should defer loading plugins if not all dependencies are met
* Bug #517: Remove included lib/faster_csv.rb
* Bug #551: Hardcoded French string in wiki/diff.rhtml
* Bug #552: Hardcoded English string in RepositoriesHelper
* Bug #557: Calendar links for previous/next month contains double escaped characters
* Bug #561: PDF export of issue gives TypeError (can't convert nil into String)
* Bug #573: acts_as_searchable definition in WikiPage may be insufficient and cause SQL errors
* Bug #577: Invalid watcher user error when adding an invalid user as watcher
* Bug #586: TabularFormBuilder doesn't work with subforms
* Feature #275: Implement requires_chiliproject and requires_chiliproject_plugin methods
* Task #584: Upgrade to Rails 2.3.14
== 2011-08-01 v2.1.1
* Bug #547: Multiple XSS vulnerabilities
@ -1624,7 +1638,7 @@ Note: Previous versions referred to Redmine, which ChiliProject forked from in D
* simple SVN browser added (just needs svn binaries in PATH)
* comments can now be added on news
* "my page" is now customizable
* "my page" is now customizable
* more powerfull and savable filters for issues lists
* improved issues change history
* new functionality: move an issue to another project or tracker
@ -1663,7 +1677,7 @@ Note: Previous versions referred to Redmine, which ChiliProject forked from in D
* token based "lost password" functionality
* user self-registration functionality (optional)
* custom fields now available for issues, users and projects
* new custom field format "text" (displayed as a textarea field)
* new custom field format "text" (displayed as a textarea field)
* project & administration drop down menus in navigation bar for quicker access
* text formatting is preserved for long text fields (issues, projects and news descriptions)
* urls and emails are turned into clickable links in long text fields

View File

@ -1,6 +1,6 @@
ChiliProject is a project management system.
Copyright (C) 2010 the ChiliProject Team
Copyright (C) 2010-2011 the ChiliProject Team
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License

View File

@ -0,0 +1,70 @@
#-- copyright
# ChiliProject is a project management system.
#
# Copyright (C) 2010-2011 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# See doc/COPYRIGHT.rdoc for more details.
#++
require 'rexml/document'
module ChiliProject
module VERSION #:nodoc:
MAJOR = 2
MINOR = 2
PATCH = 0
TINY = PATCH # Redmine compat
# Used by semver to define the special version (if any).
# A special version "satify but have a lower precedence than the associated
# normal version". So 2.0.0RC1 would be part of the 2.0.0 series but
# be considered to be an older version.
#
# 1.4.0 < 2.0.0RC1 < 2.0.0RC2 < 2.0.0 < 2.1.0
#
# This method may be overridden by third party code to provide vendor or
# distribution specific versions. They may or may not follow semver.org:
#
# 2.0.0debian-2
def self.special
''
end
def self.revision
revision = nil
entries_path = "#{RAILS_ROOT}/.svn/entries"
if File.readable?(entries_path)
begin
f = File.open(entries_path, 'r')
entries = f.read
f.close
if entries.match(%r{^\d+})
revision = $1.to_i if entries.match(%r{^\d+\s+dir\s+(\d+)\s})
else
xml = REXML::Document.new(entries)
revision = xml.elements['wc-entries'].elements[1].attributes['revision'].to_i
end
rescue
# Could not find the current revision
end
end
revision
end
REVISION = self.revision
ARRAY = [MAJOR, MINOR, PATCH, REVISION].compact
STRING = ARRAY.join('.')
def self.to_a; ARRAY end
def self.to_s; STRING end
def self.to_semver
[MAJOR, MINOR, PATCH].join('.') + special
end
end
end

File diff suppressed because it is too large Load Diff

View File

@ -408,6 +408,7 @@ module Redmine
pdf.RDMCell(190,5, l(:label_history), "B")
pdf.Ln
for journal in issue.journals.find(:all, :include => [:user], :order => "#{Journal.table_name}.created_at ASC")
next if journal.initial?
pdf.SetFontStyle('B',8)
pdf.RDMCell(190,5, format_time(journal.created_at) + " - " + journal.user.name)
pdf.Ln

View File

@ -13,8 +13,24 @@
module Redmine #:nodoc:
class PluginNotFound < StandardError; end
class PluginRequirementError < StandardError; end
class PluginError < StandardError
attr_reader :plugin_id
def initialize(plug_id=nil)
super
@plugin_id = plug_id
end
end
class PluginNotFound < PluginError
def to_s
"Missing the plugin #{@plugin_id}"
end
end
class PluginCircularDependency < PluginError
def to_s
"Circular plugin dependency in #{@plugin_id}"
end
end
class PluginRequirementError < PluginError; end
# Base class for Redmine plugins.
# Plugins are registered using the <tt>register</tt> class method that acts as the public constructor.
@ -39,9 +55,11 @@ module Redmine #:nodoc:
#
# When rendered, the plugin settings value is available as the local variable +settings+
class Plugin
@registered_plugins = {}
@registered_plugins = ActiveSupport::OrderedHash.new
@deferred_plugins = {}
class << self
attr_reader :registered_plugins
attr_reader :registered_plugins, :deferred_plugins
private :new
def def_field(*names)
@ -59,6 +77,7 @@ module Redmine #:nodoc:
# Plugin constructor
def self.register(id, &block)
id = id.to_sym
p = new(id)
p.instance_eval(&block)
# Set a default name if it was not provided during registration
@ -67,17 +86,45 @@ module Redmine #:nodoc:
# YAML translation files should be found under <plugin>/config/locales/
::I18n.load_path += Dir.glob(File.join(RAILS_ROOT, 'vendor', 'plugins', id.to_s, 'config', 'locales', '*.yml'))
registered_plugins[id] = p
# If there are plugins waiting for us to be loaded, we try loading those, again
if deferred_plugins[id]
deferred_plugins[id].each do |ary|
plugin_id, block = ary
register(plugin_id, &block)
end
deferred_plugins.delete(id)
end
return p
rescue PluginNotFound => e
# find circular dependencies
raise PluginCircularDependency.new(id) if self.dependencies_for(e.plugin_id).include?(id)
if RedminePluginLocator.instance.has_plugin? e.plugin_id
# The required plugin is going to be loaded later, defer loading this plugin
(deferred_plugins[e.plugin_id] ||= []) << [id, block]
return p
else
raise
end
end
# Returns an array off all registered plugins
# returns an array of all dependencies we know of for plugin id
# (might not be complete at all times!)
def self.dependencies_for(id)
direct_deps = deferred_plugins.keys.find_all{|k| deferred_plugins[k].collect(&:first).include?(id)}
direct_deps.inject([]) {|deps,v| deps << v; deps += self.dependencies_for(v)}
end
# Returns an array of all registered plugins
def self.all
registered_plugins.values.sort
registered_plugins.values
end
# Finds a plugin by its id
# Returns a PluginNotFound exception if the plugin doesn't exist
def self.find(id)
registered_plugins[id.to_sym] || raise(PluginNotFound)
registered_plugins[id.to_sym] || raise(PluginNotFound.new(id.to_sym))
end
# Clears the registered plugins hash
@ -101,9 +148,36 @@ module Redmine #:nodoc:
self.id.to_s <=> plugin.id.to_s
end
# Sets a requirement on Redmine version
# Sets a requirement on the ChiliProject version.
# Raises a PluginRequirementError exception if the requirement is not met.
#
# It uses the same syntax as rubygems requirements.
# Examples
# # Requires exactly ChiliProject 1.1.1
# requires_chiliproject "1.1.1"
# requires_chiliproject "= 1.1.1"
# # Requires ChiliProject 1.1.x
# requires_chiliproject "~> 1.1.0"
# # Requires ChiliProject between 1.1.0 and 1.1.5 or higher
# requires_chiliproject ">= 1.1.0", "<= 1.1.5"
def requires_chiliproject(*args)
required_version = Gem::Requirement.new(*args)
chili_version = Gem::Version.new(ChiliProject::VERSION.to_semver)
unless required_version.satisfied_by? chili_version
raise PluginRequirementError.new("#{id} plugin requires ChiliProject version #{required_version} but current version is #{chili_version}.")
end
true
end
# Sets a requirement on Redmine version.
# Raises a PluginRequirementError exception if the requirement is not met
#
# THIS IS A REDMINE COMPATIBILITY INTERFACE
#
# Examples
# # Requires Redmine 0.7.3 or higher
# requires_redmine :version_or_higher => '0.7.3'

View File

@ -11,59 +11,7 @@
# See doc/COPYRIGHT.rdoc for more details.
#++
require 'rexml/document'
module Redmine
module VERSION #:nodoc:
MAJOR = 2
MINOR = 1
PATCH = 1
TINY = PATCH # Redmine compat
# Used by semver to define the special version (if any).
# A special version "satify but have a lower precedence than the associated
# normal version". So 2.0.0RC1 would be part of the 2.0.0 series but
# be considered to be an older version.
#
# 1.4.0 < 2.0.0RC1 < 2.0.0RC2 < 2.0.0 < 2.1.0
#
# This method may be overridden by third party code to provide vendor or
# distribution specific versions. They may or may not follow semver.org:
#
# 2.0.0debian-2
def self.special
''
end
def self.revision
revision = nil
entries_path = "#{RAILS_ROOT}/.svn/entries"
if File.readable?(entries_path)
begin
f = File.open(entries_path, 'r')
entries = f.read
f.close
if entries.match(%r{^\d+})
revision = $1.to_i if entries.match(%r{^\d+\s+dir\s+(\d+)\s})
else
xml = REXML::Document.new(entries)
revision = xml.elements['wc-entries'].elements[1].attributes['revision'].to_i
end
rescue
# Could not find the current revision
end
end
revision
end
REVISION = self.revision
ARRAY = [MAJOR, MINOR, PATCH, REVISION].compact
STRING = ARRAY.join('.')
def self.to_a; ARRAY end
def self.to_s; STRING end
def self.to_semver
[MAJOR, MINOR, PATCH].join('.') + special
end
end
# THIS IS A REDMINE COMPATIBILITY INTERFACE
VERSION = ChiliProject::VERSION
end

View File

@ -0,0 +1,35 @@
#-- copyright
# ChiliProject is a project management system.
#
# Copyright (C) 2010-2011 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# See doc/COPYRIGHT.rdoc for more details.
#++
class RedminePluginLocator < Rails::Plugin::FileSystemLocator
def initialize(initializer)
super
@@instance = self
end
def self.instance
@@instance
end
# This locator is not meant for loading plugins
# The plugin loading is done by the default rails locator, this one is
# only for querying available plugins easily
def plugins(for_loading = true)
return [] if for_loading
super()
end
def has_plugin?(name)
plugins(false).collect(&:name).include? name.to_s
end
end

View File

@ -40,8 +40,7 @@ class TabularFormBuilder < ActionView::Helpers::FormBuilder
text = options[:label].is_a?(Symbol) ? l(options[:label]) : options[:label]
text ||= l(("field_" + field.to_s.gsub(/\_id$/, "")).to_sym)
text += @template.content_tag("span", " *", :class => "required") if options.delete(:required)
@template.content_tag("label", text,
:class => (@object && @object.errors[field] ? "error" : nil),
:for => (@object_name.to_s + "_" + field.to_s))
@template.label(@object_name, field.to_s, text,
:class => (@object && @object.errors[field] ? "error" : nil))
end
end

View File

@ -19,7 +19,6 @@ namespace :code do
files.reject!{ |f|
f.include?("vendor") ||
f.include?("lib/SVG") ||
f.include?("lib/faster_csv") ||
f.include?("lib/redcloth") ||
f.include?("lib/diff")
}

View File

@ -24,7 +24,6 @@ namespace :copyright do
# Skip 3rd party code
next if file_name.include?("vendor") ||
file_name.include?("lib/SVG") ||
file_name.include?("lib/faster_csv") ||
file_name.include?("lib/redcloth") ||
file_name.include?("lib/diff")

View File

@ -86,7 +86,7 @@ class IssuesTest < ActionController::IntegrationTest
assert_select "a", :text => /testfile.txt/
end
end
# remove the attachments
Issue.find(1).attachments.each(&:destroy)
assert_equal 0, Issue.find(1).attachments.length

View File

@ -882,7 +882,7 @@ class IssueTest < ActiveSupport::TestCase
issue.update_attribute(:description, "Description with newlines\n\nembedded")
issue.reload
assert issue.description.include?("\n")
assert_no_difference("Journal.count") do
issue.safe_attributes= {
'description' => "Description with newlines\r\n\r\nembedded"
@ -892,5 +892,5 @@ class IssueTest < ActiveSupport::TestCase
assert_equal "Description with newlines\n\nembedded", issue.reload.description
end
end

View File

@ -39,7 +39,7 @@ class JournalObserverTest < ActiveSupport::TestCase
assert @issue.save
end
end
end
context "#after_create for 'issue_note_added'" do
@ -49,7 +49,7 @@ class JournalObserverTest < ActiveSupport::TestCase
@issue.init_journal(@user, 'This update has a note')
assert @issue.save
end
end
should "not send a notification with not configured" do
@ -58,7 +58,7 @@ class JournalObserverTest < ActiveSupport::TestCase
@issue.init_journal(@user, 'This update has a note')
assert @issue.save
end
end
end
@ -71,7 +71,7 @@ class JournalObserverTest < ActiveSupport::TestCase
assert @issue.save
end
end
should "not send a notification with not configured" do
@ -93,7 +93,7 @@ class JournalObserverTest < ActiveSupport::TestCase
@issue.priority = IssuePriority.generate!
assert @issue.save
end
end
should "not send a notification with not configured" do
@ -103,7 +103,7 @@ class JournalObserverTest < ActiveSupport::TestCase
@issue.priority = IssuePriority.generate!
assert @issue.save
end
end
end
end

View File

@ -73,13 +73,13 @@ class JournalTest < ActiveSupport::TestCase
assert_difference("Journal.count") do
assert issue.save
end
journal = issue.reload.journals.first
assert_equal ["","Test initial journal"], journal.changes["subject"]
assert_equal [0, @project.id], journal.changes["project_id"]
assert_equal [nil, "Some content"], journal.changes["description"]
end
test "creating a journal should update the updated_on value of the parent record (touch)" do
@user = User.generate!
@project = Project.generate!

View File

@ -71,6 +71,29 @@ class Redmine::PluginTest < ActiveSupport::TestCase
end
end
def test_requires_chiliproject
test = self
version = Redmine::VERSION.to_semver
@klass.register :foo do
test.assert requires_chiliproject('>= 0.1')
test.assert requires_chiliproject(">= #{version}")
test.assert requires_chiliproject(version)
test.assert_raise Redmine::PluginRequirementError do
requires_chiliproject('>= 99.0.0')
end
test.assert_raise Redmine::PluginRequirementError do
requires_chiliproject('< 0.9')
end
requires_chiliproject('> 0.9', "<= 99.0.0")
test.assert_raise Redmine::PluginRequirementError do
requires_chiliproject('< 0.9', ">= 98.0.0")
end
test.assert requires_chiliproject("~> #{Redmine::VERSION.to_semver.gsub(/\d+$/, '0')}")
end
end
def test_requires_redmine_plugin
test = self
other_version = '0.5.0'

View File

@ -145,6 +145,6 @@ class MessageTest < ActiveSupport::TestCase
message = Message.new(:board => @board, :subject => 'Test message', :content => 'Test message content', :author => @user)
assert message.save
end
end
end

View File

@ -42,7 +42,28 @@ class WatcherTest < ActiveSupport::TestCase
assert Issue.watched_by(@user).include?(@issue)
end
def test_watcher_users
watcher_users = Issue.find(2).watcher_users
assert_kind_of Array, watcher_users
assert_kind_of User, watcher_users.first
end
def test_watcher_users_should_not_validate_user
User.update_all("firstname = ''", "id=1")
@user.reload
assert !@user.valid?
issue = Issue.new(:project => Project.find(1), :tracker_id => 1, :subject => "test", :author => User.find(2))
issue.watcher_users << @user
issue.save!
assert issue.watched_by?(@user)
end
def test_watcher_user_ids
assert_equal [1, 3], Issue.find(2).watcher_user_ids.sort
end
def test_watcher_user_ids=
issue = Issue.new
issue.watcher_user_ids = ['1', '3']
assert issue.watched_by?(User.find(1))

View File

@ -13,7 +13,7 @@ module Redmine
class_eval do
has_many :watchers, :as => :watchable, :dependent => :delete_all
has_many :watcher_users, :through => :watchers, :source => :user
has_many :watcher_users, :through => :watchers, :source => :user, :validate => false
named_scope :watched_by, lambda { |user_id|
{ :include => :watchers,

View File

@ -36,7 +36,11 @@ namespace :db do
desc 'Migrate plugins to current status.'
task :plugins => :environment do
Engines.plugins.each do |plugin|
redmine_plugins = Redmine::Plugin.all.collect(&:id)
engines_plugins = Engines.plugins.collect(&:name).collect(&:to_sym)
load_order = (engines_plugins - redmine_plugins) + (redmine_plugins & engines_plugins)
load_order.each do |p|
plugin = Engines.plugins[p]
next unless plugin.respond_to?(:migration_directory)
next unless File.exists? plugin.migration_directory
puts "Migrating plugin #{plugin.name} ..."