diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2015-01-18 11:43:58 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2015-01-18 11:43:58 +0000 |
commit | 0bcd5be0a585e835b04e6e88e69a87d5d94daf45 (patch) | |
tree | 2b359e49d203dff84d4856999cd694e736e07ad3 /app/models/changeset.rb | |
parent | 886b9c14d0cb16e5ae132bdea545ddea771f7284 (diff) | |
download | redmine-0bcd5be0a585e835b04e6e88e69a87d5d94daf45.tar.gz redmine-0bcd5be0a585e835b04e6e88e69a87d5d94daf45.zip |
Use attribute writers instead of before_create callback to normalize comments and committer (#14534).
Unlike other adapters, SQLite raises Encoding::UndefinedConversionError before the callback that reencodes attributes is called.
git-svn-id: http://svn.redmine.org/redmine/trunk@13896 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/changeset.rb')
-rw-r--r-- | app/models/changeset.rb | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/app/models/changeset.rb b/app/models/changeset.rb index 499191070..c03296451 100644 --- a/app/models/changeset.rb +++ b/app/models/changeset.rb @@ -69,6 +69,16 @@ class Changeset < ActiveRecord::Base end end + def committer=(arg) + write_attribute :committer, + self.class.to_utf8(arg, repository.try(:repo_log_encoding)) + end + + def comments=(arg) + write_attribute :comments, + self.class.normalize_comments(arg, repository.try(:repo_log_encoding)) + end + def committed_on=(date) self.commit_date = date super @@ -92,9 +102,7 @@ class Changeset < ActiveRecord::Base end def before_create_cs - self.committer = self.class.to_utf8(self.committer, repository.repo_log_encoding) - self.comments = self.class.normalize_comments( - self.comments, repository.repo_log_encoding) + self.comments ||= '' self.user = repository.find_committer_user(self.committer) end |