Commit 986ad0df authored by Benjamin Neff's avatar Benjamin Neff Committed by Jonne Haß

fix validation for status-message when the author is missing

closes #5986
parent 8531b160
......@@ -14,6 +14,7 @@
* Remove two unused methods [#5970](https://github.com/diaspora/diaspora/pull/5970)
* Refactored the Logger to add basic logrotating and more useful timestamps [#5975](https://github.com/diaspora/diaspora/pull/5975)
* Gracefully handle mailer failures if a like is already deleted again [#5983](https://github.com/diaspora/diaspora/pull/5983)
* Ensure posts have an author [#5986](https://github.com/diaspora/diaspora/pull/5986)
## Bug fixes
* Disable auto follow back on aspect deletion [#5846](https://github.com/diaspora/diaspora/pull/5846)
......
......@@ -28,6 +28,8 @@ class Post < ActiveRecord::Base
validates_uniqueness_of :id
validates :author, presence: true
after_create do
self.touch(:interacted_at)
end
......
......@@ -13,7 +13,7 @@ class StatusMessage < Post
validates_length_of :text, :maximum => 65535, :message => proc {|p, v| I18n.t('status_messages.too_long', :count => 65535, :current_length => v[:value].length)}
# don't allow creation of empty status messages
validate :presence_of_content, on: :create, if: proc { |sm| sm.author.local? }
validate :presence_of_content, on: :create, if: proc {|sm| sm.author && sm.author.local? }
xml_name :status_message
xml_attr :raw_message
......
......@@ -70,7 +70,7 @@ describe StatusMessage, :type => :model do
expect(guids).to eq([sm1.guid])
end
end
describe '.before_validation' do
it 'calls build_tags' do
status = FactoryGirl.build(:status_message)
......@@ -443,4 +443,12 @@ STR
end
end
end
describe "validation" do
it "should not be valid if the author is missing" do
sm = FactoryGirl.build(:status_message, text: @message_text)
sm.author = nil
expect(sm).not_to be_valid
end
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment