Redmine 4.1.1

This commit is contained in:
Manuel Cillero 2020-11-22 21:20:06 +01:00
parent 33e7b881a5
commit 3d976f1b3b
1593 changed files with 36180 additions and 19489 deletions

View file

@ -1,5 +1,7 @@
# frozen_string_literal: true
# Redmine - project management software
# Copyright (C) 2006-2017 Jean-Philippe Lang
# Copyright (C) 2006-2019 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
@ -45,7 +47,7 @@ class CalendarTest < ActiveSupport::TestCase
[1, 6, 7].each do |day|
with_settings :start_of_week => day do
c = Redmine::Helpers::Calendar.new(Date.today, :en, :month)
assert_equal day , c.startdt.cwday
assert_equal day, c.startdt.cwday
assert_equal (day + 5) % 7 + 1, c.enddt.cwday
end
end

View file

@ -1,37 +1,39 @@
# 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">&lt;stuff&gt; with html &amp; special chars&lt;/danger&gt;</span> <span class="diff_out">other stuff &lt;script&gt;alert(&#39;foo&#39;);&lt;/alert&gt;</span>'
assert_equal computed_diff, expected_diff
end
end
# frozen_string_literal: true
# Redmine - project management software
# Copyright (C) 2006-2019 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">&lt;stuff&gt; with html &amp; special chars&lt;/danger&gt;</span> <span class="diff_out">other stuff &lt;script&gt;alert(&#39;foo&#39;);&lt;/alert&gt;</span>'
assert_equal computed_diff, expected_diff
end
end

View file

@ -1,5 +1,7 @@
# frozen_string_literal: true
# Redmine - project management software
# Copyright (C) 2006-2017 Jean-Philippe Lang
# Copyright (C) 2006-2019 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
@ -18,11 +20,14 @@
require File.expand_path('../../../../../test_helper', __FILE__)
class Redmine::Helpers::GanttHelperTest < Redmine::HelperTest
fixtures :projects, :trackers, :issue_statuses,
fixtures :projects, :trackers, :projects_trackers, :issue_statuses,
:enumerations, :users, :issue_categories
include ProjectsHelper
include IssuesHelper
include QueriesHelper
include AvatarsHelper
include ERB::Util
include Rails.application.routes.url_helpers
@ -152,7 +157,8 @@ class Redmine::Helpers::GanttHelperTest < Redmine::HelperTest
setup_subjects
@output_buffer = @gantt.subjects
assert_select "div.issue-subject", /#{@issue.subject}/
assert_select 'div.issue-subject[style*="left:44px"]'
# subject 56px: 44px + 12px(collapse/expand icon's width)
assert_select 'div.issue-subject[style*="left:56px"]'
end
test "#subjects issue assigned to a shared version of another project should be rendered" do
@ -200,9 +206,10 @@ class Redmine::Helpers::GanttHelperTest < Redmine::HelperTest
assert_select 'div.issue-subject[style*="left:44px"]', /#{@issue.subject}/
# children 64px
assert_select 'div.issue-subject[style*="left:64px"]', /child1/
assert_select 'div.issue-subject[style*="left:64px"]', /child2/
# grandchild 84px
assert_select 'div.issue-subject[style*="left:84px"]', /grandchild/, @output_buffer
# children 76px: 64px + 12px(collapse/expand icon's width)
assert_select 'div.issue-subject[style*="left:76px"]', /child2/
# grandchild 96px: 84px + 12px(collapse/expand icon's width)
assert_select 'div.issue-subject[style*="left:96px"]', /grandchild/, @output_buffer
end
test "#lines" do
@ -237,6 +244,17 @@ class Redmine::Helpers::GanttHelperTest < Redmine::HelperTest
assert_select "div.tooltip", /#{@issue.subject}/
end
test "#selected_column_content" do
create_gantt
issue = Issue.generate!
@gantt.query.column_names = [:assigned_to]
issue.update(:assigned_to_id => issue.assignable_users.first.id)
@project.issues << issue
# :column => assigned_to
@output_buffer = @gantt.selected_column_content({ :column => @gantt.query.columns.last })
assert_select "div.issue_assigned_to#assigned_to_issue_#{issue.id}"
end
test "#subject_for_project" do
create_gantt
@output_buffer = @gantt.subject_for_project(@project, :format => :html)
@ -298,7 +316,8 @@ class Redmine::Helpers::GanttHelperTest < Redmine::HelperTest
test "#subject should use the indent option to move the div to the right" do
create_gantt
@output_buffer = @gantt.subject('subject', :format => :html, :indent => 40)
assert_select 'div[style*="left:40"]'
# subject 52px: 40px(indent) + 12px(collapse/expand icon's width)
assert_select 'div[style*="left:52px"]'
end
test "#line_for_project" do
@ -314,7 +333,7 @@ class Redmine::Helpers::GanttHelperTest < Redmine::HelperTest
version = Version.generate!(:name => 'Foo', :project => @project)
version.stubs(:start_date).returns(today - 7)
version.stubs(:due_date).returns(today + 7)
version.stubs(:completed_percent).returns(30)
version.stubs(:visible_fixed_issues => stub(:completed_percent => 30))
@output_buffer = @gantt.line_for_version(version, :format => :html)
assert_select "div.version.label", :text => /Foo/
assert_select "div.version.label", :text => /30%/
@ -353,6 +372,20 @@ class Redmine::Helpers::GanttHelperTest < Redmine::HelperTest
assert_select 'div.task_late[style*="width:30px"]', 1
end
test "#line late line should be the same width as task_todo if start date and end date are the same day" do
create_gantt
@output_buffer = @gantt.line(today - 7, today - 7, 0, false, 'line', :format => :html, :zoom => 4)
assert_select 'div.task_late[style*="width:2px"]', 1
assert_select 'div.task_todo[style*="width:2px"]', 1
end
test "#line late line should be the same width as task_todo if start date and today are the same day" do
create_gantt
@output_buffer = @gantt.line(today, today, 0, false, 'line', :format => :html, :zoom => 4)
assert_select 'div.task_late[style*="width:2px"]', 1
assert_select 'div.task_todo[style*="width:2px"]', 1
end
test "#line done line should start from the starting point on the left" do
create_gantt
@output_buffer = @gantt.line(today - 7, today + 7, 30, false, 'line', :format => :html, :zoom => 4)
@ -418,6 +451,20 @@ class Redmine::Helpers::GanttHelperTest < Redmine::HelperTest
assert_select "div.label", :text => 'line'
end
test "#column_content_for_issue" do
create_gantt
@gantt.query.column_names = [:assigned_to]
issue = Issue.generate!
issue.update(:assigned_to_id => issue.assignable_users.first.id)
@project.issues << issue
# :column => assigned_to
options = { :column => @gantt.query.columns.last, :top => 64, :format => :html }
@output_buffer = @gantt.column_content_for_issue(issue, options)
assert_select "div.issue_assigned_to#assigned_to_issue_#{issue.id}"
assert_includes @output_buffer, column_content(options[:column], issue)
end
def test_sort_issues_no_date
project = Project.generate!
issue1 = Issue.generate!(:subject => "test", :project => project)
@ -435,7 +482,7 @@ class Redmine::Helpers::GanttHelperTest < Redmine::HelperTest
issues = [child3, child2, child1, issue2, issue1]
Redmine::Helpers::Gantt.sort_issues!(issues)
assert_equal [issue1.id, child1.id, child3.id, child2.id, issue2.id],
issues.map{|v| v.id}
issues.map{|v| v.id}
end
def test_sort_issues_root_only
@ -449,7 +496,7 @@ class Redmine::Helpers::GanttHelperTest < Redmine::HelperTest
issues = [issue4, issue3, issue2, issue1]
Redmine::Helpers::Gantt.sort_issues!(issues)
assert_equal [issue1.id, issue2.id, issue4.id, issue3.id],
issues.map{|v| v.id}
issues.map{|v| v.id}
end
def test_sort_issues_tree
@ -458,17 +505,17 @@ class Redmine::Helpers::GanttHelperTest < Redmine::HelperTest
issue2 = Issue.generate!(:subject => "test", :project => project,
:start_date => (today - 2))
issue1_child1 =
Issue.generate!(:parent_issue_id => issue1.id, :subject => 'child',
:project => project)
Issue.generate!(:parent_issue_id => issue1.id, :subject => 'child',
:project => project)
issue1_child2 =
Issue.generate!(:parent_issue_id => issue1.id, :subject => 'child',
:project => project, :start_date => (today - 10))
Issue.generate!(:parent_issue_id => issue1.id, :subject => 'child',
:project => project, :start_date => (today - 10))
issue1_child1_child1 =
Issue.generate!(:parent_issue_id => issue1_child1.id, :subject => 'child',
:project => project, :start_date => (today - 8))
Issue.generate!(:parent_issue_id => issue1_child1.id, :subject => 'child',
:project => project, :start_date => (today - 8))
issue1_child1_child2 =
Issue.generate!(:parent_issue_id => issue1_child1.id, :subject => 'child',
:project => project, :start_date => (today - 9))
Issue.generate!(:parent_issue_id => issue1_child1.id, :subject => 'child',
:project => project, :start_date => (today - 9))
issue1_child1_child1_logic = Redmine::Helpers::Gantt.sort_issue_logic(issue1_child1_child1)
assert_equal [[today - 10, issue1.id], [today - 9, issue1_child1.id],
[today - 8, issue1_child1_child1.id]],

View file

@ -0,0 +1,36 @@
# frozen_string_literal: true
# Redmine - project management software
# Copyright (C) 2006-2019 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 URLTest < ActiveSupport::TestCase
include Redmine::Helpers::URL
def test_uri_with_safe_scheme
assert uri_with_safe_scheme?("http://example.com/")
assert uri_with_safe_scheme?("https://example.com/")
assert uri_with_safe_scheme?("ftp://example.com/index.html")
assert uri_with_safe_scheme?("mailto:root@example.com")
end
def test_uri_with_safe_scheme_invalid_component
assert_not uri_with_safe_scheme?("httpx://example.com/")
assert_not uri_with_safe_scheme?("mailto:root@")
end
end