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
|
when Comment
|
||||||
raw t("report.comment_label", data: link_to(
|
raw t("report.comment_label", data: link_to(
|
||||||
h(comment_message(item)),
|
h(comment_message(item)),
|
||||||
post_path(item.post.id, anchor: item.guid)
|
post_path(item.post.id, anchor: item.author.guid)
|
||||||
))
|
))
|
||||||
else
|
else
|
||||||
raw t("report.not_found")
|
raw t("report.not_found")
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ class Report < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def reported_author
|
def reported_author
|
||||||
item.author unless item.nil?
|
item.author if item
|
||||||
end
|
end
|
||||||
|
|
||||||
def entry_does_not_exist
|
def entry_does_not_exist
|
||||||
|
|
@ -50,9 +50,9 @@ class Report < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
when Comment
|
when Comment
|
||||||
if item.author.local?
|
if item.author.local?
|
||||||
item.author.owner.retract(comment)
|
item.author.owner.retract(item)
|
||||||
elsif item.parent.author.local?
|
elsif item.parent.author.local?
|
||||||
item.parent.author.owner.retract(comment)
|
item.parent.author.owner.retract(item)
|
||||||
else
|
else
|
||||||
item.destroy
|
item.destroy
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -5,23 +5,25 @@ describe ReportHelper, type: :helper do
|
||||||
@user = bob
|
@user = bob
|
||||||
@post = @user.post(:status_message, text: "hello", to: @user.aspects.first.id)
|
@post = @user.post(:status_message, text: "hello", to: @user.aspects.first.id)
|
||||||
@comment = @user.comment!(@post, "welcome")
|
@comment = @user.comment!(@post, "welcome")
|
||||||
end
|
|
||||||
|
|
||||||
describe "#get_reported_guid" do
|
@post_report = @user.reports.create(
|
||||||
it "returns user guid from post" do
|
item_id: @post.id, item_type: "post",
|
||||||
expect(helper.get_reported_guid(@post, "post")) == @user.guid
|
text: "offensive content"
|
||||||
end
|
)
|
||||||
it "returns user guid from comment" do
|
@comment_report = @user.reports.create(
|
||||||
expect(helper.get_reported_guid(@comment, "comment")) == @user.guid
|
item_id: @comment.id, item_type: "comment",
|
||||||
end
|
text: "offensive content"
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#report_content" do
|
describe "#report_content" do
|
||||||
it "contains a link to the post" 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
|
end
|
||||||
it "contains an anchor to the comment" do
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue