diff --git a/ancestry.gemspec b/ancestry.gemspec index 388a2e03..fc7efec7 100644 --- a/ancestry.gemspec +++ b/ancestry.gemspec @@ -43,6 +43,7 @@ EOF s.required_ruby_version = '>= 2.5' s.add_runtime_dependency 'activerecord', '>= 5.2.6' + s.add_runtime_dependency 'logger' s.add_development_dependency 'appraisal' s.add_development_dependency 'minitest' s.add_development_dependency 'rake', '~> 13.0' diff --git a/test/concerns/db_test.rb b/test/concerns/db_test.rb index 67878bd8..a31b1de8 100644 --- a/test/concerns/db_test.rb +++ b/test/concerns/db_test.rb @@ -13,5 +13,6 @@ def self.connection end c.send(:has_ancestry) + assert true, "this should not connect to the database" end end diff --git a/test/concerns/depth_virtual_test.rb b/test/concerns/depth_virtual_test.rb index fe79aae4..5e613691 100644 --- a/test/concerns/depth_virtual_test.rb +++ b/test/concerns/depth_virtual_test.rb @@ -3,7 +3,8 @@ # These are only valid for postgres class DepthVirtualTest < ActiveSupport::TestCase def test_depth_caching - return unless test_virtual_column? + assert true, "only runs for postgres and recent rails versions" + return unless only_test_virtual_column? AncestryTestDatabase.with_model :depth => 3, :width => 3, :cache_depth => :virtual do |_model, roots| roots.each do |lvl0_node, lvl0_children| @@ -19,7 +20,8 @@ def test_depth_caching end def test_depth_caching_after_subtree_movement - return unless test_virtual_column? + assert true, "only runs for postgres and recent rails versions" + return unless only_test_virtual_column? AncestryTestDatabase.with_model :depth => 6, :width => 1, :cache_depth => :virtual do |model, _roots| node = model.at_depth(3).first @@ -35,7 +37,8 @@ def test_depth_caching_after_subtree_movement end def test_depth_scopes - return unless test_virtual_column? + assert true, "only runs for postgres and recent rails versions" + return unless only_test_virtual_column? AncestryTestDatabase.with_model :depth => 4, :width => 2, :cache_depth => true do |model, _roots| model.before_depth(2).all? { |node| assert node.depth < 2 } @@ -47,7 +50,8 @@ def test_depth_scopes end def test_depth_scopes_without_depth_cache - return unless test_virtual_column? + assert true, "only runs for postgres and recent rails versions" + return unless only_test_virtual_column? AncestryTestDatabase.with_model :depth => 4, :width => 2 do |model, _roots| model.before_depth(2).all? { |node| assert node.depth < 2 } @@ -59,7 +63,8 @@ def test_depth_scopes_without_depth_cache end def test_exception_when_rebuilding_depth_cache_for_model_without_depth_caching - return unless test_virtual_column? + assert true, "only runs for postgres and recent rails versions" + return unless only_test_virtual_column? AncestryTestDatabase.with_model do |model| assert_raise Ancestry::AncestryException do @@ -69,7 +74,8 @@ def test_exception_when_rebuilding_depth_cache_for_model_without_depth_caching end def test_exception_on_unknown_depth_column - return unless test_virtual_column? + assert true, "only runs for postgres and recent rails versions" + return unless only_test_virtual_column? AncestryTestDatabase.with_model :cache_depth => true do |model| assert_raise Ancestry::AncestryException do @@ -81,7 +87,8 @@ def test_exception_on_unknown_depth_column # we are already testing generate and parse against static values # this assumes those are methods are tested and working def test_ancestry_depth_change - return unless test_virtual_column? + assert true, "only runs for postgres and recent rails versions" + return unless only_test_virtual_column? AncestryTestDatabase.with_model do |model| { @@ -98,7 +105,7 @@ def test_ancestry_depth_change end end - def test_virtual_column? + def only_test_virtual_column? AncestryTestDatabase.postgres? && ActiveRecord.version.to_s >= "7.0" end end diff --git a/test/concerns/materialized_path2_test.rb b/test/concerns/materialized_path2_test.rb index aa566267..b4920448 100644 --- a/test/concerns/materialized_path2_test.rb +++ b/test/concerns/materialized_path2_test.rb @@ -4,6 +4,7 @@ class MaterializedPath2Test < ActiveSupport::TestCase def test_ancestry_column_mp2 + assert true, "this runs if materialized path2" return unless AncestryTestDatabase.materialized_path2? AncestryTestDatabase.with_model do |model| @@ -37,6 +38,7 @@ def test_ancestry_column_mp2 end def test_ancestry_column_validation + assert true, "this runs if materialized path2" return unless AncestryTestDatabase.materialized_path2? AncestryTestDatabase.with_model do |model| @@ -50,6 +52,7 @@ def test_ancestry_column_validation end def test_ancestry_column_validation_fails + assert true, "this runs if materialized path2" return unless AncestryTestDatabase.materialized_path2? AncestryTestDatabase.with_model do |model| @@ -63,6 +66,7 @@ def test_ancestry_column_validation_fails end def test_ancestry_column_validation_string_key + assert true, "this runs if materialized path2" return unless AncestryTestDatabase.materialized_path2? AncestryTestDatabase.with_model(:id => :string, :primary_key_format => /[a-z]/) do |model| @@ -75,6 +79,7 @@ def test_ancestry_column_validation_string_key end def test_ancestry_column_validation_string_key_fails + assert true, "this runs if materialized path2" return unless AncestryTestDatabase.materialized_path2? AncestryTestDatabase.with_model(:id => :string, :primary_key_format => /[a-z]/) do |model| @@ -87,6 +92,7 @@ def test_ancestry_column_validation_string_key_fails end def test_ancestry_validation_exclude_self + assert true, "this runs if materialized path2" return unless AncestryTestDatabase.materialized_path2? AncestryTestDatabase.with_model do |model| diff --git a/test/concerns/materialized_path_test.rb b/test/concerns/materialized_path_test.rb index 9a2c1a38..e5da58c3 100644 --- a/test/concerns/materialized_path_test.rb +++ b/test/concerns/materialized_path_test.rb @@ -4,6 +4,7 @@ class MaterializedPathTest < ActiveSupport::TestCase def test_ancestry_column_values + assert true, "this runs if materialized path" return if AncestryTestDatabase.materialized_path2? AncestryTestDatabase.with_model do |model| @@ -37,6 +38,7 @@ def test_ancestry_column_values end def test_ancestry_column_validation + assert true, "this runs if materialized path" return if AncestryTestDatabase.materialized_path2? AncestryTestDatabase.with_model do |model| @@ -50,6 +52,7 @@ def test_ancestry_column_validation end def test_ancestry_column_validation_fails + assert true, "this runs if materialized path" return if AncestryTestDatabase.materialized_path2? AncestryTestDatabase.with_model do |model| @@ -63,6 +66,7 @@ def test_ancestry_column_validation_fails end def test_ancestry_column_validation_string_key + assert true, "this runs if materialized path" return if AncestryTestDatabase.materialized_path2? AncestryTestDatabase.with_model(:id => :string, :primary_key_format => /[a-z]/) do |model| @@ -76,6 +80,7 @@ def test_ancestry_column_validation_string_key end def test_ancestry_column_validation_string_key_fails + assert true, "this runs if materialized path" return if AncestryTestDatabase.materialized_path2? AncestryTestDatabase.with_model(:id => :string, :primary_key_format => /[a-z]/) do |model| @@ -89,6 +94,7 @@ def test_ancestry_column_validation_string_key_fails end def test_ancestry_validation_exclude_self + assert true, "this runs if materialized path" return if AncestryTestDatabase.materialized_path2? AncestryTestDatabase.with_model do |model| diff --git a/test/concerns/scopes_test.rb b/test/concerns/scopes_test.rb index b31b168e..a6184475 100644 --- a/test/concerns/scopes_test.rb +++ b/test/concerns/scopes_test.rb @@ -121,8 +121,8 @@ def test_create_children_from_root AncestryTestDatabase.with_model(:extra_columns => {:name => :string}) do |model| root = model.create record = root.children.create - # this should not throw an exception record.reload.parent.children.find_or_create_by! :name => 'abc' + assert true, "this should not throw an exception" end end end diff --git a/test/concerns/tree_navigation_test.rb b/test/concerns/tree_navigation_test.rb index be61967d..86853173 100644 --- a/test/concerns/tree_navigation_test.rb +++ b/test/concerns/tree_navigation_test.rb @@ -225,6 +225,7 @@ def test_node_in_database_children # please create PR or issue if you have a better idea def test_node_before_last_save AncestryTestDatabase.with_model do |model| + assert true, "this runs for integer primary keys" skip "only written for integer keys" unless model.primary_key_is_an_integer? model.delete_all