From 13250b7223aff8e4f6b255a858d03ecdfe19b936 Mon Sep 17 00:00:00 2001 From: Eric Davis Date: Fri, 14 Oct 2011 14:29:52 -0700 Subject: [PATCH 01/10] [#298] Add vendor/chiliproject_plugins to the load path Contributed by Holger Just --- config/environment.rb | 3 +++ vendor/chiliproject_plugins/README | 1 + 2 files changed, 4 insertions(+) create mode 100644 vendor/chiliproject_plugins/README diff --git a/config/environment.rb b/config/environment.rb index 7380bd76..90f5a7b6 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -63,6 +63,9 @@ Rails::Initializer.run do |config| # It will automatically turn deliveries on config.action_mailer.perform_deliveries = false + # Insert vendor/chiliproject_plugins at the top of the plugin load paths + config.plugin_paths.insert(0, File.join(Rails.root, "vendor", "chiliproject_plugins")) + # Use redmine's custom plugin locater require File.join(RAILS_ROOT, "lib/redmine_plugin_locator") config.plugin_locators << RedminePluginLocator diff --git a/vendor/chiliproject_plugins/README b/vendor/chiliproject_plugins/README new file mode 100644 index 00000000..504ebc76 --- /dev/null +++ b/vendor/chiliproject_plugins/README @@ -0,0 +1 @@ +Install ChiliProject plugins here and they will be automatically loaded. From e2938d26f3bb098e84a77ce0beceb1d45d9251d7 Mon Sep 17 00:00:00 2001 From: Gregor Schmidt Date: Tue, 26 Jul 2011 17:34:16 +0200 Subject: [PATCH 02/10] [#708] Using instance var to store journal class name this way journal classes are only created for classes with calls to acts_as_journalized. You may now subclass journaled models to extend them with helper methods in plugins w/o interfering with aaj. --- .../acts_as_journalized/lib/acts_as_journalized.rb | 12 +++++++++--- .../lib/redmine/acts/journalized/options.rb | 7 ++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/vendor/plugins/acts_as_journalized/lib/acts_as_journalized.rb b/vendor/plugins/acts_as_journalized/lib/acts_as_journalized.rb index 337c3abd..7646d49c 100644 --- a/vendor/plugins/acts_as_journalized/lib/acts_as_journalized.rb +++ b/vendor/plugins/acts_as_journalized/lib/acts_as_journalized.rb @@ -32,6 +32,10 @@ module Redmine end module ClassMethods + attr_writer :journal_class_name + def journal_class_name + defined?(@journal_class_name) ? @journal_class_name : superclass.journal_class_name + end def plural_name self.name.underscore.pluralize @@ -55,6 +59,8 @@ module Redmine def acts_as_journalized(options = {}, &block) activity_hash, event_hash, journal_hash = split_option_hashes(options) + self.journal_class_name = journal_hash.delete(:class_name) || "#{name.gsub("::", "_")}Journal" + acts_as_activity(activity_hash) return if journaled? @@ -77,13 +83,13 @@ module Redmine (journal_hash[:except] ||= []) << self.primary_key << inheritance_column << :updated_on << :updated_at << :lock_version << :lft << :rgt + prepare_journaled_options(journal_hash) - has_many :journals, journal_hash.merge({:class_name => journal_class.name, - :foreign_key => "journaled_id"}), &block + + has_many :journals, journal_hash, &block end def journal_class - journal_class_name = "#{name.gsub("::", "_")}Journal" if Object.const_defined?(journal_class_name) Object.const_get(journal_class_name) else diff --git a/vendor/plugins/acts_as_journalized/lib/redmine/acts/journalized/options.rb b/vendor/plugins/acts_as_journalized/lib/redmine/acts/journalized/options.rb index 015ebfc5..9c0a2b97 100644 --- a/vendor/plugins/acts_as_journalized/lib/redmine/acts/journalized/options.rb +++ b/vendor/plugins/acts_as_journalized/lib/redmine/acts/journalized/options.rb @@ -63,11 +63,12 @@ module Redmine::Acts::Journalized options.symbolize_keys! options.reverse_merge!(Configuration.options) options.reverse_merge!( - :class_name => 'Journal', - :dependent => :delete_all + :class_name => journal_class_name, + :dependent => :delete_all, + :foreign_key => "journaled_id" ) options.reverse_merge!( - :order => "#{options[:class_name].constantize.table_name}.version ASC" + :order => "#{journal_class.table_name}.version ASC" ) class_inheritable_accessor :vestal_journals_options From fb7f109ac64e4f30d14d15fb10de65e4dac5a932 Mon Sep 17 00:00:00 2001 From: Gregor Schmidt Date: Thu, 17 Nov 2011 10:36:44 +0100 Subject: [PATCH 03/10] [#708] Adding tests exposing the erroneous behavior --- test/unit/journal_test.rb | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/test/unit/journal_test.rb b/test/unit/journal_test.rb index 6333058b..71831982 100644 --- a/test/unit/journal_test.rb +++ b/test/unit/journal_test.rb @@ -115,4 +115,29 @@ class JournalTest < ActiveSupport::TestCase assert_equal "Test setting fields on Journal from Issue", @issue.last_journal.notes assert_equal @issue.author, @issue.last_journal.user end + + test "subclasses of journaled models should have journal of parent type" do + Ticket = Class.new(Issue) + + project = Project.generate! + ticket = Ticket.new do |t| + t.project = project + t.subject = "Test initial journal" + t.tracker = project.trackers.first + t.author = User.generate! + t.description = "Some content" + end + + begin + oldstdout = $stdout + $stdout = StringIO.new + ticket.save! + assert $stdout.string.empty?, "No errors should be logged to stdout." + ensure + $stdout = oldstdout + end + + journal = ticket.journals.first + assert_equal IssueJournal, journal.class + end end From ed0e92b1f6ebea4cad044fafd2270310f8d3ef66 Mon Sep 17 00:00:00 2001 From: Moritz Breit Date: Fri, 4 Nov 2011 00:46:45 +0100 Subject: [PATCH 04/10] [#733] Add Issue#due_today? and add due-today css class --- app/models/issue.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/models/issue.rb b/app/models/issue.rb index cc754014..9ff4cb11 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -401,6 +401,11 @@ class Issue < ActiveRecord::Base !due_date.nil? && (due_date < Date.today) && !status.is_closed? end + # Returns true if the issue is due today and not closed + def due_today? + !due_date.nil? && (due_date == Date.today) && !status.is_closed? + end + # Is the amount of work done less than it should for the due date def behind_schedule? return false if start_date.nil? || due_date.nil? @@ -556,6 +561,7 @@ class Issue < ActiveRecord::Base s = "issue status-#{status.position} priority-#{priority.position}" s << ' closed' if closed? s << ' overdue' if overdue? + s << ' due-today' if due_today? s << ' child' if child? s << ' parent' unless leaf? s << ' created-by-me' if User.current.logged? && author_id == User.current.id From 579061c794dcb2f205d61df4b7940ceabd0e26cb Mon Sep 17 00:00:00 2001 From: Holger Just Date: Thu, 1 Dec 2011 20:58:14 +0100 Subject: [PATCH 05/10] Move shebang of rdm-mailhandler.rb back to the top. --- extra/mail_handler/rdm-mailhandler.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/extra/mail_handler/rdm-mailhandler.rb b/extra/mail_handler/rdm-mailhandler.rb index 8858fea5..2dd725b8 100644 --- a/extra/mail_handler/rdm-mailhandler.rb +++ b/extra/mail_handler/rdm-mailhandler.rb @@ -1,3 +1,4 @@ +#!/usr/bin/env ruby #-- encoding: UTF-8 #-- copyright # ChiliProject is a project management system. @@ -12,8 +13,6 @@ # See doc/COPYRIGHT.rdoc for more details. #++ -#!/usr/bin/env ruby - # == Synopsis # # Reads an email from standard input and forward it to a Redmine server From 6a616a5f13b9564e3f582afb8dbb875ffafcd975 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Sch=C3=A4fer?= Date: Sat, 3 Dec 2011 16:32:29 +0100 Subject: [PATCH 06/10] [#740] Fix faulty assignment --- app/models/change.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/change.rb b/app/models/change.rb index 4e90689e..c8324580 100644 --- a/app/models/change.rb +++ b/app/models/change.rb @@ -31,7 +31,7 @@ class Change < ActiveRecord::Base def from_path # TODO: shouldn't access Changeset#to_utf8 directly - self.path = Changeset.to_utf8(read_attribute(:from_path), changeset_repository_encoding) + self.from_path = Changeset.to_utf8(read_attribute(:from_path), changeset_repository_encoding) end def init_path From d943efd0eb701b7d7d31f9b39872678e70743e18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Sch=C3=A4fer?= Date: Sat, 3 Dec 2011 17:39:52 +0100 Subject: [PATCH 07/10] [#748] Make ChiliProject::Version.revision more resilient * Won't output errors when the ChiliProject git repo isn't there anymore, * Works even if not invoked from the ChiliProject root directory, * Moved the formatting logic to the git call. --- lib/chili_project/version.rb | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/lib/chili_project/version.rb b/lib/chili_project/version.rb index 5aee2bed..601449ea 100644 --- a/lib/chili_project/version.rb +++ b/lib/chili_project/version.rb @@ -38,12 +38,7 @@ module ChiliProject end def self.revision - revision = `git rev-parse HEAD` - if revision.present? - revision.strip[0..8] - else - nil - end + `git --git-dir="#{Rails.root.join('.git')}" rev-parse --short=9 HEAD`.chomp if File.directory? Rails.root.join('.git') end REVISION = self.revision From b264a8ee3ffc9f65a1f833731e94aff4315e95c7 Mon Sep 17 00:00:00 2001 From: Spencer Markowski Date: Thu, 8 Dec 2011 23:51:15 -0500 Subject: [PATCH 08/10] Encloses since date in single quotes. This was causing git to respond with fatal: Unknown Object and preventing revisions from being updated. --- lib/redmine/scm/adapters/git_adapter.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/redmine/scm/adapters/git_adapter.rb b/lib/redmine/scm/adapters/git_adapter.rb index 3165beab..bb543060 100644 --- a/lib/redmine/scm/adapters/git_adapter.rb +++ b/lib/redmine/scm/adapters/git_adapter.rb @@ -176,7 +176,7 @@ module Redmine from_to << "#{identifier_from}.." if identifier_from from_to << "#{identifier_to}" if identifier_to cmd_args << from_to if !from_to.empty? - cmd_args << "--since=#{options[:since].strftime("%Y-%m-%d %H:%M:%S")}" if options[:since] + cmd_args << "--since='#{options[:since].strftime("%Y-%m-%d %H:%M:%S")}'" if options[:since] cmd_args << "--" << scm_iconv(@path_encoding, 'UTF-8', path) if path && !path.empty? scm_cmd *cmd_args do |io| From 611889f3f7ccdf6db3c564a5103686501692b0e2 Mon Sep 17 00:00:00 2001 From: Holger Just Date: Thu, 15 Dec 2011 22:02:10 +0100 Subject: [PATCH 09/10] [#748] Use SCM commands to detect the revision --- lib/chili_project/version.rb | 9 ++++++++- lib/redmine/scm/adapters/git_adapter.rb | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/chili_project/version.rb b/lib/chili_project/version.rb index 601449ea..1b3c9440 100644 --- a/lib/chili_project/version.rb +++ b/lib/chili_project/version.rb @@ -38,7 +38,14 @@ module ChiliProject end def self.revision - `git --git-dir="#{Rails.root.join('.git')}" rev-parse --short=9 HEAD`.chomp if File.directory? Rails.root.join('.git') + @revision ||= begin + git = Redmine::Scm::Adapters::GitAdapter + git_dir = Rails.root.join('.git') + + if File.directory? git_dir + git.send(:shellout, "#{git.sq_bin} --git-dir='#{git_dir}' rev-parse --short=9 HEAD") { |io| io.read }.to_s.chomp + end + end end REVISION = self.revision diff --git a/lib/redmine/scm/adapters/git_adapter.rb b/lib/redmine/scm/adapters/git_adapter.rb index bb543060..798a8680 100644 --- a/lib/redmine/scm/adapters/git_adapter.rb +++ b/lib/redmine/scm/adapters/git_adapter.rb @@ -19,10 +19,10 @@ module Redmine module Adapters class GitAdapter < AbstractAdapter - SCM_GIT_REPORT_LAST_COMMIT = true + SCM_GIT_REPORT_LAST_COMMIT = true unless defined?(SCM_GIT_REPORT_LAST_COMMIT) # Git executable name - GIT_BIN = Redmine::Configuration['scm_git_command'] || "git" + GIT_BIN = Redmine::Configuration['scm_git_command'] || "git" unless defined?(GIT_BIN) # raised if scm command exited with error, e.g. unknown revision. class ScmCommandAborted < CommandFailed; end From 0d69fa6bb1e1dc65b2d4870fc5bf1db08263e5b5 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Thu, 15 Dec 2011 12:29:02 +0000 Subject: [PATCH 10/10] Patch for ruby1.9.3 compatibility. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8234 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- config/initializers/10-patches.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/config/initializers/10-patches.rb b/config/initializers/10-patches.rb index 12725e9c..591d02d5 100644 --- a/config/initializers/10-patches.rb +++ b/config/initializers/10-patches.rb @@ -12,6 +12,10 @@ # See doc/COPYRIGHT.rdoc for more details. #++ +# Patches active_support/core_ext/load_error.rb to support 1.9.3 LoadError message +if RUBY_VERSION >= '1.9.3' + MissingSourceFile::REGEXPS << [/^cannot load such file -- (.+)$/i, 1] +end require 'active_record'