Add more tests

This commit is contained in:
Andy Allan 2018-03-28 11:05:21 +08:00
parent ab3150646c
commit 46c183ffeb
7 changed files with 121 additions and 4 deletions

View file

@ -0,0 +1,35 @@
require "application_system_test_case"
class ReportDiaryCommentTest < ApplicationSystemTestCase
def setup
create(:language, :code => "en")
@diary_entry = create(:diary_entry)
@comment = create(:diary_comment, :diary_entry => @diary_entry)
end
def test_no_link_when_not_logged_in
visit diary_entry_path(@diary_entry.user.display_name, @diary_entry)
assert page.has_content?(@comment.body)
assert !page.has_content?(I18n.t("diary_entry.diary_comment.report"))
end
def test_it_works
sign_in_as(create(:user))
visit diary_entry_path(@diary_entry.user.display_name, @diary_entry)
assert page.has_content? @diary_entry.title
click_on I18n.t("diary_entry.diary_comment.report")
assert page.has_content? "Report"
assert page.has_content? I18n.t("issues.new.disclaimer.intro")
choose I18n.t("reports.categories.diary_comment.spam")
fill_in "report_details", :with => "This comment is spam"
click_on "Create Report"
assert page.has_content? "Your report has been registered sucessfully"
assert_equal 1, Issue.count
assert Issue.last.reportable == @comment
end
end