Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport 'Fix updating budget projects or other records containing attachments' to v0.27 #10451

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion decidim-core/app/commands/decidim/gallery_methods.rb
Expand Up @@ -24,7 +24,7 @@ def build_gallery(attached_to = nil)
end

def update_attachment_title_for(photo)
Decidim::Attachment.find(photo[:id]).update(title: title_for(photo))
Decidim::Attachment.find(photo[:id]).update(title: photos_title(photo))
end

def image?(signed_id)
Expand Down
19 changes: 19 additions & 0 deletions decidim-core/spec/commands/decidim/create_dummy_resource_spec.rb
Expand Up @@ -87,6 +87,25 @@ module Decidim
expect { subject.call }.to broadcast(:ok)
end
end

context "when existing attachments are updated" do
let(:attachment1) { create(:attachment, attached_to: current_component.organization) }
let(:attachment2) { create(:attachment, attached_to: current_component.organization) }

let(:uploaded_images) do
[
{ id: attachment1.id, title: "Updated title for attachment 1" },
{ id: attachment2.id, title: "Updated title for attachment 2" }
]
end

it "broadcasts ok and updates the titles" do
expect { subject.call }.to broadcast(:ok)

expect(attachment1.reload.title).to include("en" => "Updated title for attachment 1")
expect(attachment2.reload.title).to include("en" => "Updated title for attachment 2")
end
end
end
end
end
Expand Down