diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/issues_controller_test.rb | 74 | ||||
-rw-r--r-- | test/helpers/application_helper_test.rb | 29 | ||||
-rw-r--r-- | test/unit/issue_priority_test.rb | 16 | ||||
-rw-r--r-- | test/unit/repository_bazaar_test.rb | 25 |
4 files changed, 114 insertions, 30 deletions
diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb index 2ed9ac9ea..1eff9b5d1 100644 --- a/test/functional/issues_controller_test.rb +++ b/test/functional/issues_controller_test.rb @@ -2642,18 +2642,47 @@ class IssuesControllerTest < Redmine::ControllerTest end def test_show_should_not_display_prev_next_links_for_issue_not_in_query_results - @request.session[:issue_query] = - { - :filters => { - 'status_id' => {:values => [''], :operator => 'c'} - }, - :project_id => 1, - :sort => [['id', 'asc']] + @request.session[:issue_query] = { + filters: { + 'status_id' => {operator: 'o', values: ['']} + }, + project_id: 1, + sort: [['id', 'asc']] + } + get(:show, params: {id: 8}) + + assert_response :success + assert_select 'a', text: /Previous/, count: 0 + assert_select 'a', text: /Next/, count: 0 + end + + def test_show_should_display_prev_next_links_for_issue_not_in_query_when_flash_contains_previous_and_next_issue_ids + @request.session[:issue_query] = { + filters: { + 'status_id' => {operator: 'o', values: ['']} + }, + project_id: 1, + sort: [['id', 'asc']] + } + get( + :show, + params: { id: 8 }, # The issue#8 is closed + flash: { + previous_and_next_issue_ids: { + prev_issue_id: 7, + next_issue_id: 9, + issue_position: 7, + issue_count: 10 + } } - get(:show, :params => {:id => 1}) + ) + assert_response :success - assert_select 'a', :text => /Previous/, :count => 0 - assert_select 'a', :text => /Next/, :count => 0 + assert_select 'div.next-prev-links' do + assert_select 'a[href="/issues/7"]', text: /Previous/ + assert_select 'a[href="/issues/9"]', text: /Next/ + assert_select 'span.position', text: "7 of 10" + end end def test_show_show_should_display_prev_next_links_with_query_sort_by_user_custom_field @@ -2684,25 +2713,6 @@ class IssuesControllerTest < Redmine::ControllerTest end end - def test_show_should_display_prev_next_links_when_request_has_previous_and_next_issue_ids_params - get( - :show, - :params => { - :id => 1, - :prev_issue_id => 1, - :next_issue_id => 3, - :issue_position => 2, - :issue_count => 4 - } - ) - assert_response :success - assert_select 'div.next-prev-links' do - assert_select 'a[href="/issues/1"]', :text => /Previous/ - assert_select 'a[href="/issues/3"]', :text => /Next/ - assert_select 'span.position', :text => "2 of 4" - end - end - def test_show_should_display_category_field_if_categories_are_defined Issue.update_all :category_id => nil get(:show, :params => {:id => 1}) @@ -6903,7 +6913,11 @@ class IssuesControllerTest < Redmine::ControllerTest :issue_count => 3 } ) - assert_redirected_to '/issues/11?issue_count=3&issue_position=2&next_issue_id=12&prev_issue_id=8' + assert_redirected_to '/issues/11' + assert_equal( + { issue_count: '3', issue_position: '2', next_issue_id: '12', prev_issue_id: '8' }, + flash[:previous_and_next_issue_ids] + ) end def test_update_with_permission_on_tracker_should_be_allowed diff --git a/test/helpers/application_helper_test.rb b/test/helpers/application_helper_test.rb index 9f2eb8405..31c87daea 100644 --- a/test/helpers/application_helper_test.rb +++ b/test/helpers/application_helper_test.rb @@ -2329,6 +2329,35 @@ class ApplicationHelperTest < Redmine::HelperTest end end + def test_format_activity_description_should_strip_quoted_text + text = <<~TEXT + John Smith wrote in #note-1: + > The quick brown fox + > jumps over the lazy dog. + + Brick quiz whangs jumpy veldt fox. + + > The five + + > boxing wizards + + > jump quickly. + + The quick onyx goblin jumps over the lazy dwarf. + TEXT + + expected = + 'John Smith wrote in #note-1:<br>' \ + '> The quick brown fox<br>' \ + '> ...<br>' \ + 'Brick quiz whangs jumpy veldt fox.<br>' \ + '> The five<br>' \ + '> ...<br>' \ + 'The quick onyx goblin jumps over the lazy dwarf.<br>' + + assert_equal expected, format_activity_description(text) + end + private def wiki_links_with_special_characters diff --git a/test/unit/issue_priority_test.rb b/test/unit/issue_priority_test.rb index e076afe67..80dc11e1c 100644 --- a/test/unit/issue_priority_test.rb +++ b/test/unit/issue_priority_test.rb @@ -156,4 +156,20 @@ class IssuePriorityTest < ActiveSupport::TestCase IssuePriority.find_by_position_name('highest').destroy assert_equal %w(lowest default high2 highest), IssuePriority.active.to_a.sort.map(&:position_name) end + + def test_high_should_return_false_when_no_default_priority_and_no_active_priorities + IssuePriority.update_all(active: false, is_default: false) + priority = IssuePriority.order(:position).last # Highest priority + assert_nothing_raised do + assert_equal false, priority.high? + end + end + + def test_low_should_return_false_when_no_default_priority_and_no_active_priorities + IssuePriority.update_all(active: false, is_default: false) + priority = IssuePriority.order(:position).first # Lowest priority + assert_nothing_raised do + assert_equal false, priority.low? + end + end end diff --git a/test/unit/repository_bazaar_test.rb b/test/unit/repository_bazaar_test.rb index 5af9e7f13..23f3ce48f 100644 --- a/test/unit/repository_bazaar_test.rb +++ b/test/unit/repository_bazaar_test.rb @@ -165,7 +165,22 @@ class RepositoryBazaarTest < ActiveSupport::TestCase end if File.directory?(REPOSITORY_PATH_NON_ASCII) && RUN_LATIN1_OUTPUT_TEST + # https://www.redmine.org/issues/42024 + def skip_bzr_failure_on_ubuntu24 + return unless File.exist?('/etc/os-release') + + os_release = File.read('/etc/os-release') + name = os_release[/^NAME="(.+?)"$/, 1] + version = os_release[/^VERSION_ID="(.+?)"$/, 1] + + if name == 'Ubuntu' && version == '24.04' + skip 'bzr command fails on Ubuntu 24.04, causing this test to fail' + end + end + def test_cat_latin1_path + skip_bzr_failure_on_ubuntu24 + latin1_repo = create_latin1_repo buf = latin1_repo.cat( @@ -186,6 +201,8 @@ class RepositoryBazaarTest < ActiveSupport::TestCase end def test_annotate_latin1_path + skip_bzr_failure_on_ubuntu24 + latin1_repo = create_latin1_repo ann1 = latin1_repo.annotate( @@ -206,6 +223,8 @@ class RepositoryBazaarTest < ActiveSupport::TestCase end def test_diff_latin1_path + skip_bzr_failure_on_ubuntu24 + latin1_repo = create_latin1_repo diff1 = latin1_repo.diff( @@ -217,6 +236,8 @@ class RepositoryBazaarTest < ActiveSupport::TestCase end def test_entries_latin1_path + skip_bzr_failure_on_ubuntu24 + latin1_repo = create_latin1_repo entries = latin1_repo.entries("test-#{CHAR_1_UTF8_HEX}-dir", 2) assert_kind_of Redmine::Scm::Adapters::Entries, entries @@ -227,6 +248,8 @@ class RepositoryBazaarTest < ActiveSupport::TestCase end def test_entry_latin1_path + skip_bzr_failure_on_ubuntu24 + latin1_repo = create_latin1_repo ["test-#{CHAR_1_UTF8_HEX}-dir", "/test-#{CHAR_1_UTF8_HEX}-dir", @@ -245,6 +268,8 @@ class RepositoryBazaarTest < ActiveSupport::TestCase end def test_changeset_latin1_path + skip_bzr_failure_on_ubuntu24 + latin1_repo = create_latin1_repo assert_equal 0, latin1_repo.changesets.count latin1_repo.fetch_changesets |