Skip to content
Snippets Groups Projects
Commit 15e5789a authored by pabois's avatar pabois
Browse files

test

parent d1cc6c6f
No related branches found
No related tags found
No related merge requests found
......@@ -7,7 +7,7 @@ module WithDependenciesSynchronization
attr_accessor :dependencies_before_save
before_save :compute_dependencies_before_save
after_save :cleanup_websites if :dependencies_missing_after_save?
after_save :cleanup_websites, if: :dependencies_missing_after_save?
after_destroy :cleanup_websites
end
......@@ -18,6 +18,7 @@ module WithDependenciesSynchronization
end
def dependencies_missing_after_save?
# byebug
(@dependencies_before_save - recursive_dependencies_syncable).any?
end
......
......@@ -2,14 +2,30 @@ require "test_helper"
# rails test test/models/communication/website/dependency_test.rb
class Communication::Website::DependencyTest < ActiveSupport::TestCase
test "page" do
def test_page_dependencies
# Rien : 0 dépendances
page = communication_website_pages(:page_with_no_dependency)
assert_equal 0, page.recursive_dependencies.count
# On ajoute un block "Chapitre" : 7 dépendances (les 6 composants du chapitre + le chapitre)
page = communication_website_pages(:page_with_no_dependency)
# On ajoute un block "Chapitre" : 7 dépendances (les 6 composants du chapitre + le block lui même)
page.blocks.create(position: 1, published: true, template_kind: :chapter)
assert_equal 7, page.recursive_dependencies.count
end
def test_change_block_dependencies
page = communication_website_pages(:page_with_no_dependency)
# On ajoute un block "OrganizationChart" lié à Arnaud : 9 dépendances (4 composants du organization_chart + 1 élément du organization_chart (arnaud) + 3 éléments liés à arnaud + le block lui-même)
block = page.blocks.create(position: 1, published: true, template_kind: :organization_chart)
block.data = "{ \"elements\": [ { \"id\": \"#{arnaud.id}\" } ] }"
block.save
page = page.reload
assert_equal 9, page.recursive_dependencies.count
# On modifie le target du block
block.data = "{ \"elements\": [ { \"id\": \"#{olivia.id}\" } ] }"
block.save
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment