File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed
Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ class UserExportSerializer < Decidim::DownloadYourDataSerializers::DownloadYourD
77 # Public: Exports a hash with the serialized data for the user including
88 # extra user fields
99 def serialize
10- super . merge ( extra_user_fields )
10+ super . merge ( blocking_data ) . merge ( extra_user_fields )
1111 end
1212
1313 def extra_user_fields
@@ -18,6 +18,14 @@ def extra_user_fields
1818 end
1919 end
2020
21+ def blocking_data
22+ {
23+ blocked : resource . blocked ,
24+ blocked_at : resource . blocked_at ,
25+ blocking_justification : resource . blocking &.justification
26+ }
27+ end
28+
2129 def extra_fields
2230 [
2331 :gender ,
Original file line number Diff line number Diff line change 6767 expect ( serialized ) . to include ( location : resource . extended_data [ "location" ] )
6868 end
6969
70+ context "when users are blocked" do
71+ let ( :resource ) { create ( :user , :blocked , extended_data : registration_metadata , blocked_at :) }
72+ let ( :blocked_at ) { Time . zone . now }
73+ let ( :blocking_user ) { create ( :user , :admin , :confirmed , organization : resource . organization ) }
74+ let ( :blocking_justification ) { "This is a spam user with suspicious activities" }
75+ let ( :user_block ) { double ( justification : blocking_justification ) }
76+
77+ before do
78+ allow ( resource ) . to receive ( :blocking ) . and_return ( user_block )
79+ end
80+
81+ it "includes the blocked status and justification" do
82+ expect ( serialized ) . to include ( blocked : true )
83+ expect ( serialized ) . to include ( blocked_at :)
84+ expect ( serialized ) . to include ( blocking_justification :)
85+ end
86+ end
87+
7088 # Block ExtraUserFields IncludeExtraField
7189
7290 # EndBlock
You can’t perform that action at this time.
0 commit comments