From: Jean-Philippe Lang
<%= l(:text_comma_separated) %>
<%= setting_check_box :commit_logtime_enabled, + :onclick => "if (this.checked) { Form.Element.enable('settings_commit_logtime_activity_id'); } else { Form.Element.disable('settings_commit_logtime_activity_id'); }"%>
+ +<%= setting_select :commit_logtime_activity_id, + [[l(:label_default), 0]] + TimeEntryActivity.shared.all.collect{|activity| [activity.name, activity.id.to_s]}, + :disabled => !Setting.commit_logtime_enabled?%>
<%= submit_tag l(:button_save) %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 78654b1fb..e559d01c2 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -354,6 +354,8 @@ en: setting_rest_api_enabled: Enable REST web service setting_cache_formatted_text: Cache formatted text setting_default_notification_option: Default notification option + setting_commit_logtime_enabled: Enable time logging + setting_commit_logtime_activity_id: Activity for logged time permission_add_project: Create project permission_add_subprojects: Create subprojects @@ -875,6 +877,7 @@ en: 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 {{value}}." + text_time_logged_by_changeset: "Applied in changeset {{value}}." text_issues_destroy_confirmation: 'Are you sure you want to delete the selected issue(s) ?' text_select_project_modules: 'Select modules to enable for this project:' text_default_administrator_account_changed: Default administrator account changed diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 350c38dbd..897c6312f 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -358,6 +358,8 @@ fr: setting_gravatar_default: Image Gravatar par défaut setting_start_of_week: Jour de début des calendriers setting_cache_formatted_text: Mettre en cache le texte formaté + setting_commit_logtime_enabled: Permettre la saisie de temps + setting_commit_logtime_activity_id: Activité pour le temps saisi permission_add_project: Créer un projet permission_add_subprojects: Créer des sous-projets @@ -857,6 +859,7 @@ fr: 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 {{value}}." + text_time_logged_by_changeset: "Appliqué par commit {{value}}" text_issues_destroy_confirmation: 'Ãtes-vous sûr de vouloir supprimer le(s) demandes(s) selectionnée(s) ?' text_select_project_modules: 'Sélectionner les modules à activer pour ce projet :' text_default_administrator_account_changed: Compte administrateur par défaut changé diff --git a/config/settings.yml b/config/settings.yml index 2d32decb3..74647eb5a 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -98,6 +98,11 @@ commit_fix_status_id: default: 0 commit_fix_done_ratio: default: 100 +commit_logtime_enabled: + default: 0 +commit_logtime_activity_id: + format: int + default: 0 # autologin duration in days # 0 means autologin is disabled autologin: diff --git a/test/fixtures/changesets.yml b/test/fixtures/changesets.yml index 41f077a3f..a7d168a6e 100644 --- a/test/fixtures/changesets.yml +++ b/test/fixtures/changesets.yml @@ -24,7 +24,7 @@ changesets_003: id: 102 comments: |- A commit with wrong issue ids - IssueID 666 3 + IssueID #666 #3 repository_id: 10 committer: dlopper user_id: 3 diff --git a/test/unit/changeset_test.rb b/test/unit/changeset_test.rb index 8010383fe..612a4299b 100644 --- a/test/unit/changeset_test.rb +++ b/test/unit/changeset_test.rb @@ -44,6 +44,77 @@ class ChangesetTest < ActiveSupport::TestCase assert_equal 1, ActionMailer::Base.deliveries.size end + def test_ref_keywords + Setting.commit_ref_keywords = 'refs' + Setting.commit_fix_keywords = '' + + c = Changeset.new(:repository => Project.find(1).repository, + :committed_on => Time.now, + :comments => 'Ignores #2. Refs #1') + c.scan_comment_for_issue_ids + + assert_equal [1], c.issue_ids.sort + end + + def test_ref_keywords_any_only + Setting.commit_ref_keywords = '*' + Setting.commit_fix_keywords = '' + + c = Changeset.new(:repository => Project.find(1).repository, + :committed_on => Time.now, + :comments => 'Ignores #2. Refs #1') + c.scan_comment_for_issue_ids + + assert_equal [1, 2], c.issue_ids.sort + end + + def test_ref_keywords_any_with_timelog + Setting.commit_ref_keywords = '*' + Setting.commit_logtime_enabled = '1' + + c = Changeset.new(:repository => Project.find(1).repository, + :committed_on => 24.hours.ago, + :comments => 'Worked on this issue #1 @2h', + :scmid => '520', + :revision => '520', + :user => User.find(2)) + assert_difference 'TimeEntry.count' do + c.scan_comment_for_issue_ids + end + assert_equal [1], c.issue_ids.sort + + time = TimeEntry.first(:order => 'id desc') + assert_equal 1, time.issue_id + assert_equal 1, time.project_id + assert_equal 2, time.user_id + assert_equal 2.0, time.hours + assert_equal Date.yesterday, time.spent_on + assert time.activity.is_default? + assert time.comments.include?('r520'), "r520 was expected in time_entry comments: #{time.comments}" + end + + def test_ref_keywords_closing_with_timelog + Setting.commit_fix_status_id = IssueStatus.find(:first, :conditions => ["is_closed = ?", true]).id + Setting.commit_ref_keywords = '*' + Setting.commit_fix_keywords = 'fixes , closes' + Setting.commit_logtime_enabled = '1' + + c = Changeset.new(:repository => Project.find(1).repository, + :committed_on => Time.now, + :comments => 'This is a comment. Fixes #1 @2.5, #2 @1', + :user => User.find(2)) + assert_difference 'TimeEntry.count', 2 do + c.scan_comment_for_issue_ids + end + + assert_equal [1, 2], c.issue_ids.sort + assert Issue.find(1).closed? + assert Issue.find(2).closed? + + times = TimeEntry.all(:order => 'id desc', :limit => 2) + assert_equal [1, 2], times.collect(&:issue_id).sort + end + def test_ref_keywords_any_line_start Setting.commit_ref_keywords = '*' @@ -99,6 +170,16 @@ class ChangesetTest < ActiveSupport::TestCase assert_equal [2], c.issue_ids.sort assert c.issues.first.project != c.project end + + def test_text_tag_numeric + c = Changeset.new(:scmid => '520', :revision => '520') + assert_equal 'r520', c.text_tag + end + + def test_text_tag_hash + c = Changeset.new(:scmid => '7234cb2750b63f47bff735edc50a1c0a433c2518', :revision => '7234cb2750b63f47bff735edc50a1c0a433c2518') + assert_equal 'commit:7234cb2750b63f47bff735edc50a1c0a433c2518', c.text_tag + end def test_previous changeset = Changeset.find_by_revision('3')