diff options
Diffstat (limited to 'test/helpers')
-rw-r--r-- | test/helpers/application_helper_test.rb | 48 | ||||
-rw-r--r-- | test/helpers/avatars_helper_test.rb | 12 | ||||
-rw-r--r-- | test/helpers/icons_helper_test.rb | 7 | ||||
-rw-r--r-- | test/helpers/journals_helper_test.rb | 19 | ||||
-rw-r--r-- | test/helpers/reactions_helper_test.rb | 36 |
5 files changed, 113 insertions, 9 deletions
diff --git a/test/helpers/application_helper_test.rb b/test/helpers/application_helper_test.rb index f959744e2..2e2e8b933 100644 --- a/test/helpers/application_helper_test.rb +++ b/test/helpers/application_helper_test.rb @@ -1732,6 +1732,46 @@ class ApplicationHelperTest < Redmine::HelperTest end end + def test_section_edit_links_with_multiline_heading + raw = <<~RAW + # Wiki + + ## `Foo` Bar + + The heading above generates multiline HTML. + Don't assume heading tags are always single-line. + + ``` + <h2> + <code>Foo</code> Bar</h2> + ``` + RAW + @project = Project.find(1) + set_language_if_valid 'en' + with_settings :text_formatting => 'common_mark' do + result = + textilizable( + raw, + :edit_section_links => + {:controller => 'wiki', :action => 'edit', + :project_id => '1', :id => 'Test'} + ).delete("\n") + + assert_match( + Regexp.new( + '<div class="contextual heading-2" title="Edit this section" id="section-2">' \ + '<a class="icon-only icon-edit" href="/projects/1/wiki/Test/edit\?section=2">' \ + '<svg class="s18 icon-svg" aria-hidden="true"><use href="/assets/icons-.*\.svg#icon--edit"></use></svg>' \ + '<span class="icon-label">Edit this section</span>' \ + '</a></div>' \ + '<a name="Foo-Bar"></a>' \ + '<h2 ><code>Foo</code> Bar<a href="#Foo-Bar" class="wiki-anchor">¶</a></h2>' + ), + result + ) + end + end + def test_default_formatter with_settings :text_formatting => 'unknown' do text = 'a *link*: http://www.example.net/' @@ -2363,6 +2403,14 @@ class ApplicationHelperTest < Redmine::HelperTest assert_equal expected, format_activity_description(text) end + def test_render_flash_messages_should_ignore_non_string_values + flash[:array_value] = ['1', '2'] + flash[:hash_value] = { foo: 'bar' } + + result = render_flash_messages + assert_equal '', result + end + private def wiki_links_with_special_characters diff --git a/test/helpers/avatars_helper_test.rb b/test/helpers/avatars_helper_test.rb index f407ae09e..baa64a653 100644 --- a/test/helpers/avatars_helper_test.rb +++ b/test/helpers/avatars_helper_test.rb @@ -68,6 +68,18 @@ class AvatarsHelperTest < Redmine::HelperTest assert_include 'class="gravatar picture"', avatar('jsmith <jsmith@somenet.foo>', :class => 'picture') end + def test_avatar_with_initials + with_settings :gravatar_default => 'initials' do + assert_include 'initials="RA"', avatar(User.find(1)) + end + end + + def test_avatar_should_reject_initials_if_default_is_not_initials + with_settings :gravatar_default => 'identicon' do + assert_not_include 'initials="RA"', avatar(User.find(1)) + end + end + def test_avatar_disabled with_settings :gravatar_enabled => '0' do assert_equal '', avatar(User.find_by_mail('jsmith@somenet.foo')) diff --git a/test/helpers/icons_helper_test.rb b/test/helpers/icons_helper_test.rb index ab0b58db4..7ef071f86 100644 --- a/test/helpers/icons_helper_test.rb +++ b/test/helpers/icons_helper_test.rb @@ -71,6 +71,13 @@ class IconsHelperTest < Redmine::HelperTest assert_match expected, icon end + def test_sprite_icon_should_return_svg_with_filled_class_when_style_is_filled + expected = %r{<svg class="s18 icon-svg icon-svg-filled" aria-hidden="true"><use href="/assets/icons-\w+.svg#icon--edit"></use></svg>$} + icon = sprite_icon('edit', style: :filled) + + assert_match expected, icon + end + def test_file_icon_should_return_folder_icon_for_directory entry = stub(:is_dir? => true) expected = %r{<svg class="s18 icon-svg" aria-hidden="true"><use href="/assets/icons-\w+.svg#icon--folder"></use></svg><span class="icon-label">folder_name</span>} diff --git a/test/helpers/journals_helper_test.rb b/test/helpers/journals_helper_test.rb index 355d5ec6f..47f7b7749 100644 --- a/test/helpers/journals_helper_test.rb +++ b/test/helpers/journals_helper_test.rb @@ -47,10 +47,27 @@ class JournalsHelperTest < Redmine::HelperTest journals = issue.visible_journals_with_index # add indice journal_actions = render_journal_actions(issue, journals.first, {reply_links: true}) - assert_select_in journal_actions, 'a[title=?][class="icon icon-comment"]', 'Quote' + assert_select_in journal_actions, 'a[title=?][class="icon icon-quote"]', 'Quote' assert_select_in journal_actions, 'a[title=?][class="icon-only icon-edit"]', 'Edit' assert_select_in journal_actions, 'div[class="drdn-items"] a[class="icon icon-del"]' assert_select_in journal_actions, 'div[class="drdn-items"] a[class="icon icon-copy-link"]' + assert_select_in journal_actions, 'span.reaction-button-wrapper' + end + + def test_render_journal_actions_with_journal_without_notes + User.current = User.find(1) + issue = Issue.find(1) + issue.journals.first.update!(notes: '') + + journals = issue.visible_journals_with_index + + journal_actions = render_journal_actions(issue, journals.first, reply_links: true) + + assert_select_in journal_actions, 'span.reaction-button-wrapper' + assert_select_in journal_actions, 'span.drdn' + + assert_select_in journal_actions, 'a[class="icon-comment"]', false + assert_select_in journal_actions, 'a[class="icon-edit"]', false end def test_journal_thumbnail_attachments_should_be_in_the_same_order_as_the_journal_details diff --git a/test/helpers/reactions_helper_test.rb b/test/helpers/reactions_helper_test.rb index f3a4e38d8..1c5c82418 100644 --- a/test/helpers/reactions_helper_test.rb +++ b/test/helpers/reactions_helper_test.rb @@ -106,12 +106,30 @@ class ReactionsHelperTest < ActionView::TestCase assert_select_in result, 'a.reaction-button[title=?]', expected_tooltip end - test 'reaction_button displays non-visible users as "X other" in the tooltip' do + test 'reaction_button should be label less when no reactions' do + issue = issues(:issues_002) + + result = with_locale('en') do + reaction_button(issue) + end + assert_select_in result, 'a.reaction-button' do + assert_select 'span.icon-label', false + end + + # readonly + User.current = nil + result = with_locale('en') do + reaction_button(issue) + end + assert_select_in result, 'span.reaction-button.readonly' do + assert_select 'span.icon-label', false + end + end + + test 'reaction_button should not count and display non-visible users' do issue2 = issues(:issues_002) issue2.reaction_detail = Reaction::Detail.new( - # The remaining 3 users are non-visible users - reaction_count: 5, visible_users: users(:users_002, :users_003) ) @@ -119,11 +137,10 @@ class ReactionsHelperTest < ActionView::TestCase reaction_button(issue2) end - assert_select_in result, 'a.reaction-button[title=?]', 'John Smith, Dave Lopper, and 3 others' + assert_select_in result, 'a.reaction-button[title=?]', 'John Smith and Dave Lopper' # When all users are non-visible users issue2.reaction_detail = Reaction::Detail.new( - reaction_count: 2, visible_users: [] ) @@ -131,7 +148,10 @@ class ReactionsHelperTest < ActionView::TestCase reaction_button(issue2) end - assert_select_in result, 'a.reaction-button[title=?]', '2 others' + assert_select_in result, 'a.reaction-button[title]', false + assert_select_in result, 'a.reaction-button' do + assert_select 'span.icon-label', false + end end test 'reaction_button formats the tooltip content based on the support.array settings of each locale' do @@ -152,7 +172,7 @@ class ReactionsHelperTest < ActionView::TestCase end tooltip = 'Dave Lopper, John Smith, and Redmine Admin' - assert_select_in result, 'span[data-reaction-button-id=?]', 'reaction_issue_1' do + assert_select_in result, 'span.reaction-button-wrapper[data-reaction-button-id=?]', 'reaction_issue_1' do href = reaction_path(issue.reaction_detail.user_reaction, object_type: 'Issue', object_id: 1) assert_select 'a.icon.reaction-button.reacted[href=?]', href do @@ -174,7 +194,7 @@ class ReactionsHelperTest < ActionView::TestCase end tooltip = 'Dave Lopper, John Smith, and Redmine Admin' - assert_select_in result, 'span[data-reaction-button-id=?]', 'reaction_issue_1' do + assert_select_in result, 'span.reaction-button-wrapper[data-reaction-button-id=?]', 'reaction_issue_1' do href = reactions_path(object_type: 'Issue', object_id: 1) assert_select 'a.icon.reaction-button[href=?]', href do |