Fix spec files and report model
* Adopt pronto suggestions
This commit is contained in:
parent
a6c3f67ba2
commit
6bf47c7ff0
3 changed files with 16 additions and 14 deletions
|
|
@ -10,7 +10,7 @@ module ReportHelper
|
|||
when Comment
|
||||
raw t("report.comment_label", data: link_to(
|
||||
h(comment_message(item)),
|
||||
post_path(item.post.id, anchor: item.guid)
|
||||
post_path(item.post.id, anchor: item.author.guid)
|
||||
))
|
||||
else
|
||||
raw t("report.not_found")
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ class Report < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def reported_author
|
||||
item.author unless item.nil?
|
||||
item.author if item
|
||||
end
|
||||
|
||||
def entry_does_not_exist
|
||||
|
|
@ -50,9 +50,9 @@ class Report < ActiveRecord::Base
|
|||
end
|
||||
when Comment
|
||||
if item.author.local?
|
||||
item.author.owner.retract(comment)
|
||||
item.author.owner.retract(item)
|
||||
elsif item.parent.author.local?
|
||||
item.parent.author.owner.retract(comment)
|
||||
item.parent.author.owner.retract(item)
|
||||
else
|
||||
item.destroy
|
||||
end
|
||||
|
|
|
|||
|
|
@ -5,23 +5,25 @@ describe ReportHelper, type: :helper do
|
|||
@user = bob
|
||||
@post = @user.post(:status_message, text: "hello", to: @user.aspects.first.id)
|
||||
@comment = @user.comment!(@post, "welcome")
|
||||
end
|
||||
|
||||
describe "#get_reported_guid" do
|
||||
it "returns user guid from post" do
|
||||
expect(helper.get_reported_guid(@post, "post")) == @user.guid
|
||||
end
|
||||
it "returns user guid from comment" do
|
||||
expect(helper.get_reported_guid(@comment, "comment")) == @user.guid
|
||||
end
|
||||
@post_report = @user.reports.create(
|
||||
item_id: @post.id, item_type: "post",
|
||||
text: "offensive content"
|
||||
)
|
||||
@comment_report = @user.reports.create(
|
||||
item_id: @comment.id, item_type: "comment",
|
||||
text: "offensive content"
|
||||
)
|
||||
end
|
||||
|
||||
describe "#report_content" do
|
||||
it "contains a link to the post" do
|
||||
expect(helper.report_content(@post, "post")).to include %(href="#{post_path(@post)}")
|
||||
expect(helper.report_content(@post_report))
|
||||
.to include %(href="#{post_path(@post)}")
|
||||
end
|
||||
it "contains an anchor to the comment" do
|
||||
expect(helper.report_content(@comment, "comment")).to include %(href="#{post_path(@post, anchor: @comment.guid)}")
|
||||
expect(helper.report_content(@comment_report))
|
||||
.to include %(href="#{post_path(@post, anchor: @comment.author.guid)}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue