Skip to content

Commit

Permalink
Fix check condition of script[src]/link[href] test to relaxed path re…
Browse files Browse the repository at this point in the history
…gexp.

Due to the asset pipeline integration using Propshaft introduced in redmine 6 (https://www.redmine.org/issues/39111), the plugin assert file path changes between redmine6 and previous versions. In addition, there is no common API to get the path beyond those versions. This change does not introduce ugly version branching if-else, just relaxed condition regexp.
  • Loading branch information
cat-in-136 committed Aug 3, 2024
1 parent 5ad0e66 commit 1455710
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 24 deletions.
8 changes: 4 additions & 4 deletions test/integration/hearts_hooked_boards_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ class HeartsHookedBoardsTest < Redmine::IntegrationTest
def test_index_shall_not_contain_hooks
get '/projects/1/boards/'
assert_response :success
assert_select 'script[src*="transplant_heart_link_with_counter.js"]', :count => 0
assert_select 'link[href*="redmine_hearts/stylesheets/application.css"]', :count => 0
assert_select 'script:match("src", ?)', /\/redmine_hearts\/.*transplant_heart_link_with_counter.*\.js/, :count => 0
assert_select 'link:match("href", ?)', /\/redmine_hearts\/.*application.*\.css/, :count => 0
assert_select '.heart-link-with-count', :count => 0
end

def test_topic_view
get '/boards/1/topics/1'
assert_response :success
assert_select 'script[src*="transplant_heart_link_with_counter.js"]', :count => 1
assert_select 'link[href*="redmine_hearts/stylesheets/application.css"]', :count => 1
assert_select 'script:match("src", ?)', /\/redmine_hearts\/.*transplant_heart_link_with_counter.*\.js/, :count => 1
assert_select 'link:match("href", ?)', /\/redmine_hearts\/.*application.*\.css/, :count => 1

assert_select '#content > .heart-link-with-count.message-1-heart', :count => 1
assert_select '#content > .heart-link-with-count.message-1-heart .heart-count-number', :text => "1"
Expand Down
12 changes: 6 additions & 6 deletions test/integration/hearts_hooked_issues_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ class HeartsHookedIssuesTest < Redmine::IntegrationTest
def test_index_shall_not_contain_hooks
get '/projects/1/issues/'
assert_response :success
assert_select 'script[src*="transplant_heart_link_with_counter.js"]', :count => 0
assert_select 'link[href*="redmine_hearts/stylesheets/application.css"]', :count => 0
assert_select 'script:match("src", ?)', /\/redmine_hearts\/.*transplant_heart_link_with_counter.*\.js/, :count => 0
assert_select 'link:match("href", ?)', /\/redmine_hearts\/.*application.*\.css/, :count => 0
assert_select '.heart-link-with-count', :count => 0
end

Expand All @@ -58,8 +58,8 @@ def test_index_with_heart_column
def test_view
get '/issues/1'
assert_response :success
assert_select 'script[src*="transplant_heart_link_with_counter.js"]', :count => 1
assert_select 'link[href*="redmine_hearts/stylesheets/application.css"]', :count => 1
assert_select 'script:match("src", ?)', /\/redmine_hearts\/.*transplant_heart_link_with_counter.*\.js/, :count => 1
assert_select 'link:match("href", ?)', /\/redmine_hearts\/.*application.*\.css/, :count => 1

assert_select '#content > .heart-link-with-count.issue-1-heart', :count => 1
assert_select '#content > .heart-link-with-count.issue-1-heart span.heart-count-number', :text => "0"
Expand All @@ -74,8 +74,8 @@ def test_view_by_hearted_user
log_user('dlopper', 'foo')
get '/issues/2'
assert_response :success
assert_select 'script[src*="transplant_heart_link_with_counter.js"]', :count => 1
assert_select 'link[href*="redmine_hearts/stylesheets/application.css"]', :count => 1
assert_select 'script:match("src", ?)', /\/redmine_hearts\/.*transplant_heart_link_with_counter.*\.js/, :count => 1
assert_select 'link:match("href", ?)', /\/redmine_hearts\/.*application.*\.css/, :count => 1

assert_select '#content > .heart-link-with-count.issue-2-heart', :count => 1
assert_select '#content > .heart-link-with-count.issue-2-heart a.heart-count-number', :text => "2"
Expand Down
12 changes: 6 additions & 6 deletions test/integration/hearts_hooked_news_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ class HeartsHookedNewsTest < Redmine::IntegrationTest
def test_index
get '/news/'
assert_response :success
assert_select 'script[src*="transplant_heart_link_with_counter.js"]', :count => 1
assert_select 'link[href*="redmine_hearts/stylesheets/application.css"]', :count => 1
assert_select 'script:match("src", ?)', /\/redmine_hearts\/.*transplant_heart_link_with_counter.*\.js/, :count => 1
assert_select 'link:match("href", ?)', /\/redmine_hearts\/.*application.*\.css/, :count => 1

assert_select '.heart-link-with-count', :count => 2
assert_select '#content .news-heart-holder .heart-link-with-count.news-2-heart', :count => 1
Expand All @@ -46,8 +46,8 @@ def test_view

get '/news/1'
assert_response :success
assert_select 'script[src*="transplant_heart_link_with_counter.js"]', :count => 1
assert_select 'link[href*="redmine_hearts/stylesheets/application.css"]', :count => 1
assert_select 'script:match("src", ?)', /\/redmine_hearts\/.*transplant_heart_link_with_counter.*\.js/, :count => 1
assert_select 'link:match("href", ?)', /\/redmine_hearts\/.*application.*\.css/, :count => 1

assert_select '#content > .heart-link-with-count.news-1-heart', :count => 1
assert_select '#content > .heart-link-with-count.news-1-heart span.heart-count-number', :text => "0"
Expand All @@ -59,8 +59,8 @@ def test_view_by_hearted_user

get '/news/1'
assert_response :success
assert_select 'script[src*="transplant_heart_link_with_counter.js"]', :count => 1
assert_select 'link[href*="redmine_hearts/stylesheets/application.css"]', :count => 1
assert_select 'script:match("src", ?)', /\/redmine_hearts\/.*transplant_heart_link_with_counter.*\.js/, :count => 1
assert_select 'link:match("href", ?)', /\/redmine_hearts\/.*application.*\.css/, :count => 1

assert_select '#content > .heart-link-with-count.news-1-heart', :count => 1
assert_select '#content > .heart-link-with-count.news-1-heart a.heart-count-number', :text => "1"
Expand Down
4 changes: 2 additions & 2 deletions test/integration/hearts_hooked_users_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ def test_show
log_user('dlopper', 'foo')
get '/users/1'
assert_response :success
assert_select 'script[src*="transplant_heart_link_with_counter.js"]', :count => 0
assert_select 'link[href*="redmine_hearts/stylesheets/application.css"]', :count => 0
assert_select 'script:match("src", ?)', /\/redmine_hearts\/.*transplant_heart_link_with_counter.*\.js/, :count => 0
assert_select 'link:match("href", ?)', /\/redmine_hearts\/.*application.*\.css/, :count => 0
assert_select 'a[href="/hearts/hearted_by/1"]', :count => 1, :text => "2 Likes"

Heart.where(:user_id => 1).destroy_all
Expand Down
12 changes: 6 additions & 6 deletions test/integration/hearts_hooked_wikis_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ class HeartsHookedWikisTest < Redmine::IntegrationTest
def test_index_shall_not_contain_hooks
get '/projects/ecookbook/wiki/index'
assert_response :success
assert_select 'script[src*="transplant_heart_link_with_counter.js"]', :count => 0
assert_select 'link[href*="redmine_hearts/stylesheets/application.css"]', :count => 0
assert_select 'script:match("src", ?)', /\/redmine_hearts\/.*transplant_heart_link_with_counter.*\.js/, :count => 0
assert_select 'link:match("href", ?)', /\/redmine_hearts\/.*application.*\.css/, :count => 0
assert_select '.heart-link-with-count', :count => 0
end

Expand All @@ -41,8 +41,8 @@ def test_view

get '/projects/ecookbook/wiki/CookBook_documentation'
assert_response :success
assert_select 'script[src*="transplant_heart_link_with_counter.js"]', :count => 1
assert_select 'link[href*="redmine_hearts/stylesheets/application.css"]', :count => 1
assert_select 'script:match("src", ?)', /\/redmine_hearts\/.*transplant_heart_link_with_counter.*\.js/, :count => 1
assert_select 'link:match("href", ?)', /\/redmine_hearts\/.*application.*\.css/, :count => 1

assert_select '#content > .heart-link-with-count.wiki_page-1-heart', :count => 1
assert_select '#content > .heart-link-with-count.wiki_page-1-heart span.heart-count-number', :text => "0"
Expand All @@ -55,8 +55,8 @@ def test_view_by_hearted_user

get '/projects/ecookbook/wiki/CookBook_documentation'
assert_response :success
assert_select 'script[src*="transplant_heart_link_with_counter.js"]', :count => 1
assert_select 'link[href*="redmine_hearts/stylesheets/application.css"]', :count => 1
assert_select 'script:match("src", ?)', /\/redmine_hearts\/.*transplant_heart_link_with_counter.*\.js/, :count => 1
assert_select 'link:match("href", ?)', /\/redmine_hearts\/.*application.*\.css/, :count => 1

assert_select '#content > .heart-link-with-count.wiki_page-1-heart', :count => 1
assert_select '#content > .heart-link-with-count.wiki_page-1-heart a.heart-count-number', :text => "1"
Expand Down

0 comments on commit 1455710

Please sign in to comment.