Defect #25077 » set_blank_decriptions_to_nil.patch
| app/models/issue.rb | ||
|---|---|---|
|
if arg.is_a?(String)
|
||
|
arg = arg.gsub(/(\r\n|\n|\r)/, "\r\n")
|
||
|
end
|
||
|
write_attribute(:description, arg)
|
||
|
write_attribute(:description, arg.blank? ? nil : arg)
|
||
|
end
|
||
|
def deleted_attachment_ids
|
||
| db/migrate/20170218185644_migrate_blank_description_to_nil.rb | ||
|---|---|---|
|
class MigrateBlankDescriptionToNil < ActiveRecord::Migration
|
||
|
def up
|
||
|
Issue.where(:description => '').update_all(:description => nil)
|
||
|
end
|
||
|
def down
|
||
|
Issue.where(:description => nil).update_all(:description => '')
|
||
|
end
|
||
|
end
|
||
| test/unit/issue_test.rb | ||
|---|---|---|
|
assert_save issue
|
||
|
end
|
||
|
def test_create_with_blank_description_should_set_description_to_nil
|
||
|
issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 3, :subject => 'test_create', :description => '')
|
||
|
assert issue.save
|
||
|
assert issue.description.nil?
|
||
|
end
|
||
|
def test_start_date_format_should_be_validated
|
||
|
set_language_if_valid 'en'
|
||
|
['2012', 'ABC', '2012-15-20'].each do |invalid_date|
|
||
| ... | ... | |
|
:subject => 'Assignment test',
|
||
|
:assigned_to => group,
|
||
|
:is_private => true)
|
||
|
|
||
|
Role.find(2).update! :issues_visibility => 'default'
|
||
|
issues = Issue.visible(User.find(8)).to_a
|
||
|
assert issues.any?
|
||
|
assert issues.include?(issue)
|
||
|
|
||
|
Role.find(2).update! :issues_visibility => 'own'
|
||
|
issues = Issue.visible(User.find(8)).to_a
|
||
|
assert issues.any?
|
||