fix #1567; nil reference in spam_rules_enforcer.rb

This commit is contained in:
Brian Alexander 2013-10-22 19:14:31 -06:00
parent c1008f4359
commit e2a5415aca
2 changed files with 12 additions and 1 deletions

View File

@ -76,7 +76,7 @@ class PostCreator
{ user: @user,
limit_once_per: 24.hours,
message_params: {domains: @post.linked_hosts.keys.join(', ')} } )
else
elsif @post && !@post.errors.present?
SpamRulesEnforcer.enforce!(@post)
end

View File

@ -44,6 +44,17 @@ describe PostCreator do
end
context "invalid raw" do
let(:creator_invalid_raw) { PostCreator.new(user, basic_topic_params.merge(raw: '')) }
it "has errors" do
creator_invalid_raw.create
expect(creator_invalid_raw.errors).to be_present
end
end
context "success" do
it "doesn't return true for spam" do