FIX: don't validate topic title if it isn't changing. topic stats were failing to update, causing necro topic warnings and other problems.
This commit is contained in:
parent
436ea982ae
commit
b368667703
|
@ -48,7 +48,8 @@ class Topic < ActiveRecord::Base
|
||||||
rate_limit :limit_topics_per_day
|
rate_limit :limit_topics_per_day
|
||||||
rate_limit :limit_private_messages_per_day
|
rate_limit :limit_private_messages_per_day
|
||||||
|
|
||||||
validates :title, :presence => true,
|
validates :title, :if => Proc.new { |t| t.title_changed? },
|
||||||
|
:presence => true,
|
||||||
:topic_title_length => true,
|
:topic_title_length => true,
|
||||||
:quality_title => { :unless => :private_message? },
|
:quality_title => { :unless => :private_message? },
|
||||||
:unique_among => { :unless => Proc.new { |t| (SiteSetting.allow_duplicate_topic_titles? || t.private_message?) },
|
:unique_among => { :unless => Proc.new { |t| (SiteSetting.allow_duplicate_topic_titles? || t.private_message?) },
|
||||||
|
|
|
@ -1411,4 +1411,14 @@ describe Topic do
|
||||||
topic = Topic.find(topic.id)
|
topic = Topic.find(topic.id)
|
||||||
topic.custom_fields.should == {"bob" => "marley", "jack" => "black"}
|
topic.custom_fields.should == {"bob" => "marley", "jack" => "black"}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "doesn't validate the title again if it isn't changing" do
|
||||||
|
SiteSetting.stubs(:min_topic_title_length).returns(5)
|
||||||
|
topic = Fabricate(:topic, title: "Short")
|
||||||
|
topic.should be_valid
|
||||||
|
|
||||||
|
SiteSetting.stubs(:min_topic_title_length).returns(15)
|
||||||
|
topic.last_posted_at = 1.minute.ago
|
||||||
|
topic.save.should == true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue