Skip to content

Commit

Permalink
Add possibility of reporting blog posts
Browse files Browse the repository at this point in the history
* fix report blogs

* lint

* lint
  • Loading branch information
eliegaboriau authored and alecslupu committed Jun 14, 2023
1 parent e2fe9ae commit ecfd795
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
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:) }
let(:reportable) { posts.first }
let(:reportable_path) { resource_locator(reportable).path }
let!(:user) { create(:user, :confirmed, organization:) }

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

include_examples "reports"
end

0 comments on commit ecfd795

Please sign in to comment.