def after_create
scan_comment_for_issue_ids
end
+ require 'pp'
def scan_comment_for_issue_ids
return if comments.blank?
# update status of issues
logger.debug "Issues fixed by changeset #{self.revision}: #{issue_ids.join(', ')}." if logger && logger.debug?
target_issues.each do |issue|
- # don't change the status is the issue is already closed
+ # don't change the status is the issue is closed
next if issue.status.is_closed?
+ user = committer_user || User.anonymous
+ journal = issue.init_journal(user, l(:text_status_changed_by_changeset, "r#{self.revision}"))
issue.status = fix_status
issue.done_ratio = done_ratio if done_ratio
issue.save
+ Mailer.deliver_issue_edit(journal) if Setting.notified_events.include?('issue_updated')
end
end
referenced_issues += target_issues
self.issues = referenced_issues.uniq
end
+ # Returns the Redmine User corresponding to the committer
+ def committer_user
+ if committer && committer.strip =~ /^([^<]+)(<(.*)>)?$/
+ username, email = $1.strip, $3
+ u = User.find_by_login(username)
+ u ||= User.find_by_mail(email) unless email.blank?
+ u
+ end
+ end
+
# Returns the previous changeset
def previous
@previous ||= Changeset.find(:first, :conditions => ['revision < ? AND repository_id = ?', self.revision, self.repository_id], :order => 'revision DESC')
label_repository_plural: Хранилища
label_associated_revisions: Асоциирани ревизии
setting_user_format: Потребителски формат
+text_status_changed_by_changeset: Applied in changeset %s.
label_repository_plural: Repositories
label_associated_revisions: Associated revisions
setting_user_format: Users display format
+text_status_changed_by_changeset: Applied in changeset %s.
enumeration_issue_priorities: Ticket-Prioritäten
enumeration_doc_categories: Dokumentenkategorien
enumeration_activities: Aktivitäten (Zeiterfassung)
+text_status_changed_by_changeset: Applied in changeset %s.
text_user_mail_option: "For unselected projects, you will only receive notifications about things you watch or you're involved in (eg. issues you're the author or assignee)."
text_no_configuration_data: "Roles, trackers, issue statuses and workflow have not been configured yet.\nIt is highly recommended to load the default configuration. You will be able to modify it once loaded."
text_load_default_configuration: Load the default configuration
+text_status_changed_by_changeset: Applied in changeset %s.
default_role_manager: Manager
default_role_developper: Developer
label_repository_plural: Repositories
label_associated_revisions: Associated revisions
setting_user_format: Users display format
+text_status_changed_by_changeset: Applied in changeset %s.
enumeration_activities: Aktiviteetit (ajan seuranta)
label_associated_revisions: Liittyvät versiot
setting_user_format: Users display format
+text_status_changed_by_changeset: Applied in changeset %s.
text_user_mail_option: "Pour les projets non sélectionnés, vous recevrez seulement des notifications pour ce que vous surveillez ou à quoi vous participez (exemple: demandes dont vous êtes l'auteur ou la personne assignée)."
text_no_configuration_data: "Les rôles, trackers, statuts et le workflow ne sont pas encore paramétrés.\nIl est vivement recommandé de charger le paramétrage par defaut. Vous pourrez le modifier une fois chargé."
text_load_default_configuration: Charger le paramétrage par défaut
+text_status_changed_by_changeset: Appliqué par commit %s.
default_role_manager: Manager
default_role_developper: Développeur
label_repository_plural: Repositories
label_associated_revisions: Associated revisions
setting_user_format: Users display format
+text_status_changed_by_changeset: Applied in changeset %s.
label_repository_plural: Repositories
label_associated_revisions: Associated revisions
setting_user_format: Users display format
+text_status_changed_by_changeset: Applied in changeset %s.
label_repository_plural: Repositories
label_associated_revisions: Associated revisions
setting_user_format: Users display format
+text_status_changed_by_changeset: Applied in changeset %s.
label_repository_plural: 저장소들
label_associated_revisions: Associated revisions
setting_user_format: Users display format
+text_status_changed_by_changeset: Applied in changeset %s.
error_can_t_load_default_data: "Numatytoji konfiguracija negali būti užkrauta: %s"
label_associated_revisions: susijusios revizijos
setting_user_format: Vartotojo atvaizdavimo formatas
+text_status_changed_by_changeset: Applied in changeset %s.
label_repository_plural: Repositories
label_associated_revisions: Associated revisions
setting_user_format: Users display format
+text_status_changed_by_changeset: Applied in changeset %s.
label_repository_plural: Repozytoria
label_associated_revisions: Associated revisions
setting_user_format: Users display format
+text_status_changed_by_changeset: Applied in changeset %s.
label_repository_plural: Repositories\r
label_associated_revisions: Associated revisions\r
setting_user_format: Users display format\r
+text_status_changed_by_changeset: Applied in changeset %s.\r
label_repository_plural: Repositories
label_associated_revisions: Associated revisions
setting_user_format: Users display format
+text_status_changed_by_changeset: Applied in changeset %s.
label_repository_plural: Repositories
label_associated_revisions: Associated revisions
setting_user_format: Users display format
+text_status_changed_by_changeset: Applied in changeset %s.
enumeration_issue_priorities: Приоритеты задач
enumeration_doc_categories: Категории документов
enumeration_activities: Действия (учет времени)
+text_status_changed_by_changeset: Applied in changeset %s.
label_repository_plural: Repositories
label_associated_revisions: Associated revisions
setting_user_format: Users display format
+text_status_changed_by_changeset: Applied in changeset %s.
label_repository_plural: Repositories
label_associated_revisions: Associated revisions
setting_user_format: Users display format
+text_status_changed_by_changeset: Applied in changeset %s.
enumeration_issue_priorities: 項目重要性
enumeration_doc_categories: 文件分類
enumeration_activities: 活動 (time tracking)
+text_status_changed_by_changeset: Applied in changeset %s.
label_repository_plural: 源代码库
label_associated_revisions: 相关的版本
setting_user_format: 用户显示格式
+text_status_changed_by_changeset: Applied in changeset %s.
require File.dirname(__FILE__) + '/../test_helper'
class RepositoryTest < Test::Unit::TestCase
- fixtures :projects, :repositories, :issues, :issue_statuses, :changesets, :changes
+ fixtures :projects,
+ :trackers,
+ :projects_trackers,
+ :repositories,
+ :issues,
+ :issue_statuses,
+ :changesets,
+ :changes,
+ :users,
+ :enumerations
def setup
@repository = Project.find(1).repository
Setting.commit_fix_done_ratio = "90"
Setting.commit_ref_keywords = 'refs , references, IssueID'
Setting.commit_fix_keywords = 'fixes , closes'
-
+ Setting.default_language = 'en'
+ ActionMailer::Base.deliveries.clear
+
# make sure issue 1 is not already closed
- assert !Issue.find(1).status.is_closed?
+ fixed_issue = Issue.find(1)
+ assert !fixed_issue.status.is_closed?
+ old_status = fixed_issue.status
Repository.scan_changesets_for_issue_ids
assert_equal [101, 102], Issue.find(3).changeset_ids
# fixed issues
- fixed_issue = Issue.find(1)
+ fixed_issue.reload
assert fixed_issue.status.is_closed?
assert_equal 90, fixed_issue.done_ratio
assert_equal [101], fixed_issue.changeset_ids
+ # issue change
+ journal = fixed_issue.journals.find(:first, :order => 'created_on desc')
+ assert_equal User.find_by_login('dlopper'), journal.user
+ assert_equal 'Applied in changeset r2.', journal.notes
+
+ # 2 email notifications
+ assert_equal 2, ActionMailer::Base.deliveries.size
+ mail = ActionMailer::Base.deliveries.first
+ assert_kind_of TMail::Mail, mail
+ assert mail.subject.starts_with?("[#{fixed_issue.project.name} - #{fixed_issue.tracker.name} ##{fixed_issue.id}]")
+ assert mail.body.include?("Status changed from #{old_status} to #{fixed_issue.status}")
+
# ignoring commits referencing an issue of another project
assert_equal [], Issue.find(4).changesets
end