Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class UserExportSerializer < Decidim::DownloadYourDataSerializers::DownloadYourD
# Public: Exports a hash with the serialized data for the user including
# extra user fields
def serialize
super.merge(extra_user_fields)
super.merge(blocking_data).merge(extra_user_fields)
end

def extra_user_fields
Expand All @@ -18,6 +18,14 @@ def extra_user_fields
end
end

def blocking_data
{
blocked: resource.blocked,
blocked_at: resource.blocked_at,
blocking_justification: resource.blocking&.justification
}
end

def extra_fields
[
:gender,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,24 @@
expect(serialized).to include(location: resource.extended_data["location"])
end

context "when users are blocked" do
let(:resource) { create(:user, :blocked, extended_data: registration_metadata, blocked_at:) }
let(:blocked_at) { Time.zone.now }
let(:blocking_user) { create(:user, :admin, :confirmed, organization: resource.organization) }
let(:blocking_justification) { "This is a spam user with suspicious activities" }
let(:user_block) { double(justification: blocking_justification) }

before do
allow(resource).to receive(:blocking).and_return(user_block)
end

it "includes the blocked status and justification" do
expect(serialized).to include(blocked: true)
expect(serialized).to include(blocked_at:)
expect(serialized).to include(blocking_justification:)
end
end

# Block ExtraUserFields IncludeExtraField

# EndBlock
Expand Down