Support for multiple issue update keywords/rules in commit messages (#4911).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@12197 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -80,6 +80,57 @@ class SettingsControllerTest < ActionController::TestCase
|
||||
Setting.clear_cache
|
||||
end
|
||||
|
||||
def test_edit_commit_update_keywords
|
||||
with_settings :commit_update_keywords => {
|
||||
"fixes, resolves" => {"status_id" => "3"},
|
||||
"closes" => {"status_id" => "5", "done_ratio" => "100"}
|
||||
} do
|
||||
get :edit
|
||||
end
|
||||
assert_response :success
|
||||
assert_select 'tr.commit-keywords', 2
|
||||
assert_select 'tr.commit-keywords:nth-child(1)' do
|
||||
assert_select 'input[name=?][value=?]', 'settings[commit_update_keywords][keywords][]', 'fixes, resolves'
|
||||
assert_select 'select[name=?]', 'settings[commit_update_keywords][status_id][]' do
|
||||
assert_select 'option[value=3][selected=selected]'
|
||||
end
|
||||
end
|
||||
assert_select 'tr.commit-keywords:nth-child(2)' do
|
||||
assert_select 'input[name=?][value=?]', 'settings[commit_update_keywords][keywords][]', 'closes'
|
||||
assert_select 'select[name=?]', 'settings[commit_update_keywords][status_id][]' do
|
||||
assert_select 'option[value=5][selected=selected]'
|
||||
end
|
||||
assert_select 'select[name=?]', 'settings[commit_update_keywords][done_ratio][]' do
|
||||
assert_select 'option[value=100][selected=selected]'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_edit_without_commit_update_keywords_should_show_blank_line
|
||||
with_settings :commit_update_keywords => {} do
|
||||
get :edit
|
||||
end
|
||||
assert_response :success
|
||||
assert_select 'tr.commit-keywords', 1 do
|
||||
assert_select 'input[name=?][value=?]', 'settings[commit_update_keywords][keywords][]', ''
|
||||
end
|
||||
end
|
||||
|
||||
def test_post_edit_commit_update_keywords
|
||||
post :edit, :settings => {
|
||||
:commit_update_keywords => {
|
||||
:keywords => ["resolves", "closes"],
|
||||
:status_id => ["3", "5"],
|
||||
:done_ratio => ["", "100"]
|
||||
}
|
||||
}
|
||||
assert_redirected_to '/settings'
|
||||
assert_equal({
|
||||
"resolves" => {"status_id" => "3"},
|
||||
"closes" => {"status_id" => "5", "done_ratio" => "100"}
|
||||
}, Setting.commit_update_keywords)
|
||||
end
|
||||
|
||||
def test_get_plugin_settings
|
||||
Setting.stubs(:plugin_foo).returns({'sample_setting' => 'Plugin setting value'})
|
||||
ActionController::Base.append_view_path(File.join(Rails.root, "test/fixtures/plugins"))
|
||||
|
||||
@@ -30,10 +30,8 @@ class ChangesetTest < ActiveSupport::TestCase
|
||||
|
||||
def test_ref_keywords_any
|
||||
ActionMailer::Base.deliveries.clear
|
||||
Setting.commit_fix_status_id = IssueStatus.where(:is_closed => true).first.id
|
||||
Setting.commit_fix_done_ratio = '90'
|
||||
Setting.commit_ref_keywords = '*'
|
||||
Setting.commit_fix_keywords = 'fixes , closes'
|
||||
Setting.commit_update_keywords = {'fixes , closes' => {'status_id' => '5', 'done_ratio' => '90'}}
|
||||
|
||||
c = Changeset.new(:repository => Project.find(1).repository,
|
||||
:committed_on => Time.now,
|
||||
@@ -49,7 +47,7 @@ class ChangesetTest < ActiveSupport::TestCase
|
||||
|
||||
def test_ref_keywords
|
||||
Setting.commit_ref_keywords = 'refs'
|
||||
Setting.commit_fix_keywords = ''
|
||||
Setting.commit_update_keywords = ''
|
||||
c = Changeset.new(:repository => Project.find(1).repository,
|
||||
:committed_on => Time.now,
|
||||
:comments => 'Ignores #2. Refs #1',
|
||||
@@ -60,7 +58,7 @@ class ChangesetTest < ActiveSupport::TestCase
|
||||
|
||||
def test_ref_keywords_any_only
|
||||
Setting.commit_ref_keywords = '*'
|
||||
Setting.commit_fix_keywords = ''
|
||||
Setting.commit_update_keywords = ''
|
||||
c = Changeset.new(:repository => Project.find(1).repository,
|
||||
:committed_on => Time.now,
|
||||
:comments => 'Ignores #2. Refs #1',
|
||||
@@ -112,9 +110,12 @@ class ChangesetTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
def test_ref_keywords_closing_with_timelog
|
||||
Setting.commit_fix_status_id = IssueStatus.where(:is_closed => true).first.id
|
||||
Setting.commit_ref_keywords = '*'
|
||||
Setting.commit_fix_keywords = 'fixes , closes'
|
||||
Setting.commit_update_keywords = {
|
||||
'fixes , closes' => {
|
||||
'status_id' => IssueStatus.where(:is_closed => true).first.id.to_s
|
||||
}
|
||||
}
|
||||
Setting.commit_logtime_enabled = '1'
|
||||
|
||||
c = Changeset.new(:repository => Project.find(1).repository,
|
||||
@@ -163,6 +164,23 @@ class ChangesetTest < ActiveSupport::TestCase
|
||||
assert_equal [1,2,3], c.issue_ids.sort
|
||||
end
|
||||
|
||||
def test_update_keywords_with_multiple_rules
|
||||
Setting.commit_update_keywords = {
|
||||
'fixes, closes' => {'status_id' => '5'},
|
||||
'resolves' => {'status_id' => '3'}
|
||||
}
|
||||
issue1 = Issue.generate!
|
||||
issue2 = Issue.generate!
|
||||
|
||||
c = Changeset.new(:repository => Project.find(1).repository,
|
||||
:committed_on => Time.now,
|
||||
:comments => "Closes ##{issue1.id}\nResolves ##{issue2.id}",
|
||||
:revision => '12345')
|
||||
assert c.save
|
||||
assert_equal 5, issue1.reload.status_id
|
||||
assert_equal 3, issue2.reload.status_id
|
||||
end
|
||||
|
||||
def test_commit_referencing_a_subproject_issue
|
||||
c = Changeset.new(:repository => Project.find(1).repository,
|
||||
:committed_on => Time.now,
|
||||
@@ -174,7 +192,7 @@ class ChangesetTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
def test_commit_closing_a_subproject_issue
|
||||
with_settings :commit_fix_status_id => 5, :commit_fix_keywords => 'closes',
|
||||
with_settings :commit_update_keywords => {'closes' => {'status_id' => '5'}},
|
||||
:default_language => 'en' do
|
||||
issue = Issue.find(5)
|
||||
assert !issue.closed?
|
||||
|
||||
@@ -182,11 +182,10 @@ class RepositoryTest < ActiveSupport::TestCase
|
||||
def test_scan_changesets_for_issue_ids
|
||||
Setting.default_language = 'en'
|
||||
|
||||
# choosing a status to apply to fix issues
|
||||
Setting.commit_fix_status_id = IssueStatus.where(:is_closed => true).first.id
|
||||
Setting.commit_fix_done_ratio = "90"
|
||||
Setting.commit_ref_keywords = 'refs , references, IssueID'
|
||||
Setting.commit_fix_keywords = 'fixes , closes'
|
||||
Setting.commit_update_keywords = {
|
||||
'fixes , closes' => {'status_id' => IssueStatus.where(:is_closed => true).first.id, 'done_ratio' => '90'}
|
||||
}
|
||||
Setting.default_language = 'en'
|
||||
ActionMailer::Base.deliveries.clear
|
||||
|
||||
|
||||
Reference in New Issue
Block a user