Actualiza a Redmine 3.4.13
This commit is contained in:
parent
807ff3308d
commit
ecddcaf1d3
224 changed files with 2222 additions and 1000 deletions
|
@ -21,8 +21,9 @@ class Redmine::CipheringTest < ActiveSupport::TestCase
|
|||
|
||||
def test_password_should_be_encrypted
|
||||
Redmine::Configuration.with 'database_cipher_key' => 'secret' do
|
||||
r = Repository::Subversion.create!(:password => 'foo', :url => 'file:///tmp', :identifier => 'svn')
|
||||
assert_equal 'foo', r.password
|
||||
plaintext_password = "THIS_IS_A_32_BYTES_LONG_PASSWORD"
|
||||
r = Repository::Subversion.create!(:password => plaintext_password, :url => 'file:///tmp', :identifier => 'svn')
|
||||
assert_equal plaintext_password, r.password
|
||||
assert r.read_attribute(:password).match(/\Aaes-256-cbc:.+\Z/)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -23,26 +23,26 @@ class Redmine::ConfigurationTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_empty
|
||||
assert_kind_of Hash, load_conf('empty.yml', 'test')
|
||||
assert_kind_of Hash, load_conf('empty.yml.example', 'test')
|
||||
end
|
||||
|
||||
def test_default
|
||||
assert_kind_of Hash, load_conf('default.yml', 'test')
|
||||
assert_kind_of Hash, load_conf('default.yml.example', 'test')
|
||||
assert_equal 'foo', @conf['somesetting']
|
||||
end
|
||||
|
||||
def test_no_default
|
||||
assert_kind_of Hash, load_conf('no_default.yml', 'test')
|
||||
assert_kind_of Hash, load_conf('no_default.yml.example', 'test')
|
||||
assert_equal 'foo', @conf['somesetting']
|
||||
end
|
||||
|
||||
def test_overrides
|
||||
assert_kind_of Hash, load_conf('overrides.yml', 'test')
|
||||
assert_kind_of Hash, load_conf('overrides.yml.example', 'test')
|
||||
assert_equal 'bar', @conf['somesetting']
|
||||
end
|
||||
|
||||
def test_with
|
||||
load_conf('default.yml', 'test')
|
||||
load_conf('default.yml.example', 'test')
|
||||
assert_equal 'foo', @conf['somesetting']
|
||||
@conf.with 'somesetting' => 'bar' do
|
||||
assert_equal 'bar', @conf['somesetting']
|
||||
|
|
|
@ -26,6 +26,7 @@ class AttachmentFormatVisibilityTest < ActionView::TestCase
|
|||
:versions, :issues
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
set_tmp_attachments_directory
|
||||
end
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ class Redmine::BoolFieldFormatTest < ActionView::TestCase
|
|||
include Redmine::I18n
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
set_language_if_valid 'en'
|
||||
end
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ class Redmine::EnumerationFieldFormatTest < ActionView::TestCase
|
|||
include ApplicationHelper
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
set_language_if_valid 'en'
|
||||
@field = IssueCustomField.create!(:name => 'List', :field_format => 'enumeration', :is_required => false)
|
||||
@foo = CustomFieldEnumeration.new(:name => 'Foo')
|
||||
|
|
|
@ -21,6 +21,7 @@ class Redmine::FieldFormatTest < ActionView::TestCase
|
|||
include ApplicationHelper
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
set_language_if_valid 'en'
|
||||
end
|
||||
|
||||
|
|
|
@ -19,6 +19,11 @@ require File.expand_path('../../../../../test_helper', __FILE__)
|
|||
require 'redmine/field_format'
|
||||
|
||||
class Redmine::LinkFieldFormatTest < ActionView::TestCase
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def test_link_field_should_substitute_value
|
||||
field = IssueCustomField.new(:field_format => 'link', :url_pattern => 'http://foo/%value%')
|
||||
custom_value = CustomValue.new(:custom_field => field, :customized => Issue.new, :value => "bar")
|
||||
|
|
|
@ -23,6 +23,7 @@ class Redmine::ListFieldFormatTest < ActionView::TestCase
|
|||
include Redmine::I18n
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
set_language_if_valid 'en'
|
||||
end
|
||||
|
||||
|
@ -37,6 +38,16 @@ class Redmine::ListFieldFormatTest < ActionView::TestCase
|
|||
assert group.valid?
|
||||
end
|
||||
|
||||
def test_non_existing_value_should_be_invalid
|
||||
field = GroupCustomField.create!(:name => 'List', :field_format => 'list', :possible_values => ['Foo', 'Bar'])
|
||||
group = Group.new(:name => 'Group')
|
||||
group.custom_field_values = {field.id => 'Baz'}
|
||||
|
||||
assert_not_include 'Baz', field.possible_custom_value_options(group.custom_value_for(field))
|
||||
assert_equal false, group.valid?
|
||||
assert_include "List #{::I18n.t('activerecord.errors.messages.inclusion')}", group.errors.full_messages.first
|
||||
end
|
||||
|
||||
def test_edit_tag_should_have_id_and_name
|
||||
field = IssueCustomField.new(:field_format => 'list', :possible_values => ['Foo', 'Bar'], :is_required => false)
|
||||
value = CustomFieldValue.new(:custom_field => field, :customized => Issue.new)
|
||||
|
|
|
@ -1,31 +1,35 @@
|
|||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require File.expand_path('../../../../../test_helper', __FILE__)
|
||||
require 'redmine/field_format'
|
||||
|
||||
class Redmine::NumericFieldFormatTest < ActionView::TestCase
|
||||
include ApplicationHelper
|
||||
|
||||
def test_integer_field_with_url_pattern_should_format_as_link
|
||||
field = IssueCustomField.new(:field_format => 'int', :url_pattern => 'http://foo/%value%')
|
||||
custom_value = CustomValue.new(:custom_field => field, :customized => Issue.new, :value => "3")
|
||||
|
||||
assert_equal 3, field.format.formatted_custom_value(self, custom_value, false)
|
||||
assert_equal '<a href="http://foo/3">3</a>', field.format.formatted_custom_value(self, custom_value, true)
|
||||
end
|
||||
end
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require File.expand_path('../../../../../test_helper', __FILE__)
|
||||
require 'redmine/field_format'
|
||||
|
||||
class Redmine::NumericFieldFormatTest < ActionView::TestCase
|
||||
include ApplicationHelper
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def test_integer_field_with_url_pattern_should_format_as_link
|
||||
field = IssueCustomField.new(:field_format => 'int', :url_pattern => 'http://foo/%value%')
|
||||
custom_value = CustomValue.new(:custom_field => field, :customized => Issue.new, :value => "3")
|
||||
|
||||
assert_equal 3, field.format.formatted_custom_value(self, custom_value, false)
|
||||
assert_equal '<a href="http://foo/3">3</a>', field.format.formatted_custom_value(self, custom_value, true)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -24,6 +24,10 @@ class Redmine::UserFieldFormatTest < ActionView::TestCase
|
|||
:issue_statuses, :issue_categories, :issue_relations, :workflows,
|
||||
:enumerations
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def test_user_role_should_reject_blank_values
|
||||
field = IssueCustomField.new(:name => 'Foo', :field_format => 'user', :user_role => ["1", ""])
|
||||
field.save!
|
||||
|
@ -45,6 +49,21 @@ class Redmine::UserFieldFormatTest < ActionView::TestCase
|
|||
assert issue.valid?
|
||||
end
|
||||
|
||||
def test_non_existing_values_should_be_invalid
|
||||
field = IssueCustomField.create!(:name => 'Foo', :field_format => 'user', :is_for_all => true, :trackers => Tracker.all)
|
||||
project = Project.generate!
|
||||
user = User.generate!
|
||||
User.add_to_project(user, project, Role.find_by_name('Developer'))
|
||||
|
||||
field.user_role = [Role.find_by_name('Manager').id]
|
||||
field.save!
|
||||
|
||||
issue = Issue.new(:project_id => project.id, :tracker_id => 1, :custom_field_values => {field.id => user.id})
|
||||
assert_not_include [user.name, user.id.to_s], field.possible_custom_value_options(issue.custom_value_for(field))
|
||||
assert_equal false, issue.valid?
|
||||
assert_include "Foo #{::I18n.t('activerecord.errors.messages.inclusion')}", issue.errors.full_messages.first
|
||||
end
|
||||
|
||||
def test_possible_values_options_should_return_project_members
|
||||
field = IssueCustomField.new(:field_format => 'user')
|
||||
project = Project.find(1)
|
||||
|
|
|
@ -49,6 +49,20 @@ class Redmine::VersionFieldFormatTest < ActionView::TestCase
|
|||
assert issue.valid?
|
||||
end
|
||||
|
||||
def test_not_existing_values_should_be_invalid
|
||||
field = IssueCustomField.create!(:name => 'Foo', :field_format => 'version', :is_for_all => true, :trackers => Tracker.all)
|
||||
project = Project.generate!
|
||||
version = Version.generate!(:project => project, :status => 'closed')
|
||||
|
||||
field.version_status = ["open"]
|
||||
field.save!
|
||||
|
||||
issue = Issue.new(:project_id => project.id, :tracker_id => 1, :custom_field_values => {field.id => version.id})
|
||||
assert_not_include [version.name, version.id.to_s], field.possible_custom_value_options(issue.custom_value_for(field))
|
||||
assert_equal false, issue.valid?
|
||||
assert_include "Foo #{::I18n.t('activerecord.errors.messages.inclusion')}", issue.errors.full_messages.first
|
||||
end
|
||||
|
||||
def test_possible_values_options_should_return_project_versions
|
||||
field = IssueCustomField.new(:field_format => 'version')
|
||||
project = Project.find(1)
|
||||
|
|
|
@ -1,37 +1,37 @@
|
|||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require File.expand_path('../../../../../test_helper', __FILE__)
|
||||
|
||||
class DiffTest < ActiveSupport::TestCase
|
||||
def test_diff
|
||||
diff = Redmine::Helpers::Diff.new("foo", "bar")
|
||||
assert_not_nil diff
|
||||
end
|
||||
|
||||
def test_dont_double_escape
|
||||
# 3 cases to test in the before: first word, last word, everything inbetween
|
||||
before = "<stuff> with html & special chars</danger>"
|
||||
# all words in after are treated equal
|
||||
after = "other stuff <script>alert('foo');</alert>"
|
||||
|
||||
computed_diff = Redmine::Helpers::Diff.new(before, after).to_html
|
||||
expected_diff = '<span class="diff_in"><stuff> with html & special chars</danger></span> <span class="diff_out">other stuff <script>alert('foo');</alert></span>'
|
||||
|
||||
assert_equal computed_diff, expected_diff
|
||||
end
|
||||
end
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require File.expand_path('../../../../../test_helper', __FILE__)
|
||||
|
||||
class DiffTest < ActiveSupport::TestCase
|
||||
def test_diff
|
||||
diff = Redmine::Helpers::Diff.new("foo", "bar")
|
||||
assert_not_nil diff
|
||||
end
|
||||
|
||||
def test_dont_double_escape
|
||||
# 3 cases to test in the before: first word, last word, everything inbetween
|
||||
before = "<stuff> with html & special chars</danger>"
|
||||
# all words in after are treated equal
|
||||
after = "other stuff <script>alert('foo');</alert>"
|
||||
|
||||
computed_diff = Redmine::Helpers::Diff.new(before, after).to_html
|
||||
expected_diff = '<span class="diff_in"><stuff> with html & special chars</danger></span> <span class="diff_out">other stuff <script>alert('foo');</alert></span>'
|
||||
|
||||
assert_equal computed_diff, expected_diff
|
||||
end
|
||||
end
|
||||
|
|
|
@ -18,6 +18,15 @@
|
|||
require File.expand_path('../../../../../../test_helper', __FILE__)
|
||||
|
||||
class Redmine::Views::Builders::JsonTest < ActiveSupport::TestCase
|
||||
def test_nil_and_false
|
||||
assert_json_output({'value' => nil}) do |b|
|
||||
b.value nil
|
||||
end
|
||||
|
||||
assert_json_output({'value' => false}) do |b|
|
||||
b.value false
|
||||
end
|
||||
end
|
||||
|
||||
def test_hash
|
||||
assert_json_output({'person' => {'name' => 'Ryan', 'age' => 32}}) do |b|
|
||||
|
|
|
@ -401,4 +401,9 @@ EXPECTED
|
|||
|
||||
assert_equal expected.gsub(%r{[\r\n\t]}, ''), textilizable(text).gsub(%r{[\r\n\t]}, '')
|
||||
end
|
||||
|
||||
def test_macro_should_support_phrase_modifiers
|
||||
text = "*{{hello_world}}*"
|
||||
assert_match %r|\A<p><strong>Hello world!.*</strong></p>\z|, textilizable(text)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -89,5 +89,70 @@ STR
|
|||
assert_equal '<p>This is a <a href="/issues">link</a></p>', @formatter.new(text).to_html.strip
|
||||
end
|
||||
|
||||
def test_markdown_should_not_require_surrounded_empty_line
|
||||
text = <<-STR
|
||||
This is a list:
|
||||
* One
|
||||
* Two
|
||||
STR
|
||||
assert_equal "<p>This is a list:</p>\n\n<ul>\n<li>One</li>\n<li>Two</li>\n</ul>", @formatter.new(text).to_html.strip
|
||||
end
|
||||
|
||||
STR_WITH_PRE = [
|
||||
# 0
|
||||
"# Title
|
||||
|
||||
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas sed libero.",
|
||||
# 1
|
||||
"## Heading 2
|
||||
|
||||
~~~ruby
|
||||
def foo
|
||||
end
|
||||
>>>>>>> .merge-right.r17266
|
||||
~~~
|
||||
|
||||
Morbi facilisis accumsan orci non pharetra.
|
||||
|
||||
```
|
||||
Pre Content:
|
||||
|
||||
## Inside pre
|
||||
|
||||
<tag> inside pre block
|
||||
|
||||
Morbi facilisis accumsan orci non pharetra.
|
||||
```",
|
||||
# 2
|
||||
"### Heading 3
|
||||
|
||||
Nulla nunc nisi, egestas in ornare vel, posuere ac libero."]
|
||||
|
||||
def test_get_section_should_ignore_pre_content
|
||||
text = STR_WITH_PRE.join("\n\n")
|
||||
|
||||
assert_section_with_hash STR_WITH_PRE[1..2].join("\n\n"), text, 2
|
||||
assert_section_with_hash STR_WITH_PRE[2], text, 3
|
||||
end
|
||||
|
||||
def test_update_section_should_not_escape_pre_content_outside_section
|
||||
text = STR_WITH_PRE.join("\n\n")
|
||||
replacement = "New text"
|
||||
|
||||
assert_equal [STR_WITH_PRE[0..1], "New text"].flatten.join("\n\n"),
|
||||
@formatter.new(text).update_section(3, replacement)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def assert_section_with_hash(expected, text, index)
|
||||
result = @formatter.new(text).get_section(index)
|
||||
|
||||
assert_kind_of Array, result
|
||||
assert_equal 2, result.size
|
||||
assert_equal expected, result.first, "section content did not match"
|
||||
assert_equal Digest::MD5.hexdigest(expected), result.last, "section hash did not match"
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -536,13 +536,24 @@ STR
|
|||
def test_should_not_allow_arbitrary_class_attribute_on_offtags
|
||||
%w(code pre kbd).each do |tag|
|
||||
assert_html_output({"<#{tag} class=\"foo\">test</#{tag}>" => "<#{tag}>test</#{tag}>"}, false)
|
||||
assert_html_output({"<#{tag} class='foo'>test</#{tag}>" => "<#{tag}>test</#{tag}>"}, false)
|
||||
assert_html_output({"<#{tag} class=\"ruby foo\">test</#{tag}>" => "<#{tag}>test</#{tag}>"}, false)
|
||||
assert_html_output({"<#{tag} class='ruby foo'>test</#{tag}>" => "<#{tag}>test</#{tag}>"}, false)
|
||||
assert_html_output({"<#{tag} class=\"ruby \"foo\" bar\">test</#{tag}>" => "<#{tag}>test</#{tag}>"}, false)
|
||||
end
|
||||
|
||||
assert_html_output({"<notextile class=\"foo\">test</notextile>" => "test"}, false)
|
||||
assert_html_output({"<notextile class='foo'>test</notextile>" => "test"}, false)
|
||||
assert_html_output({"<notextile class=\"ruby foo\">test</notextile>" => "test"}, false)
|
||||
assert_html_output({"<notextile class='ruby foo'>test</notextile>" => "test"}, false)
|
||||
assert_html_output({"<notextile class=\"ruby \"foo\" bar\">test</notextile>" => "test"}, false)
|
||||
end
|
||||
|
||||
def test_should_allow_valid_language_class_attribute_on_code_tags
|
||||
# language name is double-quoted
|
||||
assert_html_output({"<code class=\"ruby\">test</code>" => "<code class=\"ruby syntaxhl\"><span class=\"CodeRay\">test</span></code>"}, false)
|
||||
# language name is single-quoted
|
||||
assert_html_output({"<code class='ruby'>test</code>" => "<code class=\"ruby syntaxhl\"><span class=\"CodeRay\">test</span></code>"}, false)
|
||||
end
|
||||
|
||||
def test_should_not_allow_valid_language_class_attribute_on_non_code_offtags
|
||||
|
@ -577,6 +588,28 @@ STR
|
|||
}, false)
|
||||
end
|
||||
|
||||
# TODO: Remove this test after migrating to RedCloth 4
|
||||
def test_should_not_crash_with_special_input
|
||||
assert_nothing_raised { to_html(" \f") }
|
||||
assert_nothing_raised { to_html(" \v") }
|
||||
end
|
||||
|
||||
def test_should_not_handle_as_preformatted_text_tags_that_starts_with_pre
|
||||
text = <<-STR
|
||||
<pree>
|
||||
This is some text
|
||||
</pree>
|
||||
STR
|
||||
|
||||
expected = <<-EXPECTED
|
||||
<p><pree><br />
|
||||
This is some text<br />
|
||||
</pree></p>
|
||||
EXPECTED
|
||||
|
||||
assert_equal expected.gsub(%r{[\r\n\t]}, ''), to_html(text).gsub(%r{[\r\n\t]}, '')
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def assert_html_output(to_test, expect_paragraph = true)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue