Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
Admin
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
osuny
Admin
Commits
15e5789a
Commit
15e5789a
authored
1 year ago
by
pabois
Browse files
Options
Downloads
Patches
Plain Diff
test
parent
d1cc6c6f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/models/concerns/with_dependencies_synchronization.rb
+2
-1
2 additions, 1 deletion
app/models/concerns/with_dependencies_synchronization.rb
test/models/communication/website/dependency_test.rb
+19
-3
19 additions, 3 deletions
test/models/communication/website/dependency_test.rb
with
21 additions
and
4 deletions
app/models/concerns/with_dependencies_synchronization.rb
+
2
−
1
View file @
15e5789a
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
test/models/communication/website/dependency_test.rb
+
19
−
3
View file @
15e5789a
...
...
@@ -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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment