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 diff --git a/app/models/issue.rb b/app/models/issue.rb index 233e2bb1..3bb35dd2 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -405,6 +405,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? @@ -560,6 +565,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 diff --git a/config/environment.rb b/config/environment.rb index 0ae61ffe..0a42d953 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -72,6 +72,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/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' 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 diff --git a/lib/chili_project/version.rb b/lib/chili_project/version.rb index 5aee2bed..1b3c9440 100644 --- a/lib/chili_project/version.rb +++ b/lib/chili_project/version.rb @@ -38,11 +38,13 @@ module ChiliProject end def self.revision - revision = `git rev-parse HEAD` - if revision.present? - revision.strip[0..8] - else - nil + @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 diff --git a/lib/redmine/scm/adapters/git_adapter.rb b/lib/redmine/scm/adapters/git_adapter.rb index 3165beab..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 @@ -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| 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 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. 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