Merge pull request #1569 from balexand/fix_1567

Fix #1567; nil reference in spam_rules_enforcer.rb
This commit is contained in:
Sam 2013-10-22 23:08:09 -07:00
commit d069481235
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