From ee1d9647b86f9e886cea07abe6e4e4126352a018 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Fri, 15 Feb 2013 07:48:37 +0000 Subject: [PATCH] Raised group name maximum length to 255 characters (#13174). git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11392 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/group.rb | 2 +- app/views/groups/_form.html.erb | 2 +- ...20130215073721_change_users_lastname_length_to_255.rb | 9 +++++++++ test/unit/group_test.rb | 8 ++++++++ 4 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20130215073721_change_users_lastname_length_to_255.rb diff --git a/app/models/group.rb b/app/models/group.rb index 23d2e39b4..fd0f583f7 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -25,7 +25,7 @@ class Group < Principal validates_presence_of :lastname validates_uniqueness_of :lastname, :case_sensitive => false - validates_length_of :lastname, :maximum => 30 + validates_length_of :lastname, :maximum => 255 before_destroy :remove_references_before_destroy diff --git a/app/views/groups/_form.html.erb b/app/views/groups/_form.html.erb index a5cb5d068..7dc224061 100644 --- a/app/views/groups/_form.html.erb +++ b/app/views/groups/_form.html.erb @@ -1,7 +1,7 @@ <%= error_messages_for @group %>
-

<%= f.text_field :name %>

+

<%= f.text_field :name, :required => true, :size => 60 %>

<% @group.custom_field_values.each do |value| %>

<%= custom_field_tag_with_label :group, value %>

<% end %> diff --git a/db/migrate/20130215073721_change_users_lastname_length_to_255.rb b/db/migrate/20130215073721_change_users_lastname_length_to_255.rb new file mode 100644 index 000000000..7d68e37d8 --- /dev/null +++ b/db/migrate/20130215073721_change_users_lastname_length_to_255.rb @@ -0,0 +1,9 @@ +class ChangeUsersLastnameLengthTo255 < ActiveRecord::Migration + def self.up + change_column :users, :lastname, :string, :limit => 255, :default => '', :null => false + end + + def self.down + change_column :users, :lastname, :string, :limit => 30, :default => '', :null => false + end +end diff --git a/test/unit/group_test.rb b/test/unit/group_test.rb index c04583ae6..53f1603e2 100644 --- a/test/unit/group_test.rb +++ b/test/unit/group_test.rb @@ -35,6 +35,14 @@ class GroupTest < ActiveSupport::TestCase assert_equal 'New group', g.name end + def test_name_should_accept_255_characters + name = 'a' * 255 + g = Group.new(:name => name) + assert g.save + g.reload + assert_equal name, g.name + end + def test_blank_name_error_message set_language_if_valid 'en' g = Group.new -- 2.39.5