]> source.dussan.org Git - redmine.git/commitdiff
Make common_mark the default text formatting for new installations (#34863).
authorMarius Balteanu <marius.balteanu@zitec.com>
Tue, 4 Oct 2022 19:19:15 +0000 (19:19 +0000)
committerMarius Balteanu <marius.balteanu@zitec.com>
Tue, 4 Oct 2022 19:19:15 +0000 (19:19 +0000)
git-svn-id: https://svn.redmine.org/redmine/trunk@21897 e93f8b46-1217-0410-a6f0-8f06a7374b81

config/settings.yml
db/migrate/017_create_settings.rb
db/migrate/20221004172825_ensure_text_formatting_setting_is_stored_in_db.rb [new file with mode: 0644]
test/functional/attachments_controller_test.rb
test/unit/setting_test.rb

index 0c41b7eda14a3b87374e808ea7f2955ec22787d9..78025b2e76f30a5c2884ba4efa668be1e5237360 100644 (file)
@@ -95,7 +95,7 @@ mail_from:
 plain_text_mail:
   default: 0
 text_formatting:
-  default: textile
+  default: common_mark
 cache_formatted_text:
   default: 0
 wiki_compression:
index 777e36ed63ed9cabe48be10310278705e9105984..4c18329cc9dd090abe95ae15528b726d0cd0ce59 100644 (file)
@@ -4,6 +4,10 @@ class CreateSettings < ActiveRecord::Migration[4.2]
       t.column "name", :string, :limit => 30, :default => "", :null => false
       t.column "value", :text
     end
+
+    # Persist text_formatting default setting for new installations
+    setting = Setting.new(:name => "text_formatting", :value => Setting.text_formatting)
+    setting.save!
   end
 
   def self.down
diff --git a/db/migrate/20221004172825_ensure_text_formatting_setting_is_stored_in_db.rb b/db/migrate/20221004172825_ensure_text_formatting_setting_is_stored_in_db.rb
new file mode 100644 (file)
index 0000000..bcb8130
--- /dev/null
@@ -0,0 +1,8 @@
+class EnsureTextFormattingSettingIsStoredInDb < ActiveRecord::Migration[6.1]
+  def change
+    unless Setting.where(name: "text_formatting").exists?
+      setting = Setting.new(:name => "text_formatting", :value => 'textile')
+      setting.save!
+    end
+  end
+end
index 43d7c35e05027e043344b4ac9baeae2566b8ef3a..71c54a774d51cb691a061144ff251f64deb47d12 100644 (file)
@@ -219,7 +219,7 @@ class AttachmentsControllerTest < Redmine::ControllerTest
     get(:show, :params => {:id => a.id})
     assert_response :success
     assert_equal 'text/html', @response.media_type
-    assert_select 'div.wiki', :html => "<h1>Header 1</h1>\n\n<h2>Header 2</h2>\n\n<h3>Header 3</h3>"
+    assert_select 'div.wiki', :html => "<h1>Header 1</h1>\n<h2>Header 2</h2>\n<h3>Header 3</h3>"
   end
 
   def test_show_text_file_formatted_textile
index f8d35a6a64777cebec25505df7b031c57967176f..5d4986760b303f40631f64f26fb809e5cbd3dc30 100644 (file)
@@ -145,4 +145,9 @@ class SettingTest < ActiveSupport::TestCase
       end
     end
   end
+
+  def test_default_text_formatting_for_new_installations_is_common_mark
+    assert_equal 'common_mark', Setting.text_formatting
+    assert_equal 'common_mark', Setting.find_by(:name => 'text_formatting').value
+  end
 end