mirror of
https://github.com/discourse/discourse.git
synced 2025-03-03 23:49:10 +08:00
FIX: Topic#fancy_title
should not write in readonly mode.
This commit is contained in:
parent
9d6449ae92
commit
5b9ddaf972
@ -311,11 +311,10 @@ class Topic < ActiveRecord::Base
|
||||
return ERB::Util.html_escape(title) unless SiteSetting.title_fancy_entities?
|
||||
|
||||
unless fancy_title = read_attribute(:fancy_title)
|
||||
|
||||
fancy_title = Topic.fancy_title(title)
|
||||
write_attribute(:fancy_title, fancy_title)
|
||||
|
||||
unless new_record?
|
||||
if !new_record? && !Discourse.readonly_mode?
|
||||
# make sure data is set in table, this also allows us to change algorithm
|
||||
# by simply nulling this column
|
||||
exec_sql("UPDATE topics SET fancy_title = :fancy_title where id = :id", id: self.id, fancy_title: fancy_title)
|
||||
|
@ -327,6 +327,27 @@ describe Topic do
|
||||
topic.title = "this is another edge case"
|
||||
expect(topic.fancy_title).to eq("this is another edge case")
|
||||
end
|
||||
|
||||
context 'readonly mode' do
|
||||
before do
|
||||
Discourse.enable_readonly_mode
|
||||
end
|
||||
|
||||
after do
|
||||
Discourse.disable_readonly_mode
|
||||
end
|
||||
|
||||
it 'should not attempt to update `fancy_title`' do
|
||||
topic.save!
|
||||
expect(topic.fancy_title).to eq('“this topic” – has “fancy stuff”')
|
||||
|
||||
topic.title = "This is a test testing testing"
|
||||
expect(topic.fancy_title).to eq("This is a test testing testing")
|
||||
|
||||
expect(topic.reload.read_attribute(:fancy_title))
|
||||
.to eq('“this topic” – has “fancy stuff”')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user