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 'Add possibility of reporting blog posts ' to v0.27 #11025

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
16 changes: 16 additions & 0 deletions decidim-blogs/app/models/decidim/blogs/post.rb
Expand Up @@ -14,6 +14,7 @@ class Post < Blogs::ApplicationRecord
include Decidim::Searchable
include Decidim::Endorsable
include Decidim::Followable
include Decidim::Reportable
include Decidim::TranslatableResource
include Traceable
include Loggable
Expand Down Expand Up @@ -73,6 +74,21 @@ def users_to_notify_on_comment_created
def attachment_context
:admin
end

# Public: Overrides the `reported_content_url` Reportable concern method.
def reported_content_url
ResourceLocatorPresenter.new(self).url
end

# Public: Overrides the `reported_attributes` Reportable concern method.
def reported_attributes
[:title, :body]
end

# Public: Overrides the `reported_searchable_content_extras` Reportable concern method.
def reported_searchable_content_extras
[normalized_author.name]
end
end
end
end
1 change: 1 addition & 0 deletions decidim-blogs/app/views/decidim/blogs/posts/show.html.erb
Expand Up @@ -59,3 +59,4 @@
</div>
<%= attachments_for post %>
<%= comments_for post %>
<%= cell("decidim/flag_modal", post) %>
21 changes: 21 additions & 0 deletions decidim-blogs/spec/system/report_post_spec.rb
@@ -0,0 +1,21 @@
# frozen_string_literal: true

require "spec_helper"

describe "Report a post", type: :system do
include_context "with a component"

let(:manifest_name) { "blogs" }
let!(:posts) { create_list(:post, 3, component: component) }
let(:reportable) { posts.first }
let(:reportable_path) { resource_locator(reportable).path }
let!(:user) { create(:user, :confirmed, organization: organization) }

let!(:component) do
create(:post_component,
manifest: manifest,
participatory_space: participatory_process)
end

include_examples "reports"
end