Replaced group[lastname] parameter with group[name].

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9745 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2012-06-01 18:24:33 +00:00
parent 121ce2a390
commit 733fef458c
5 changed files with 18 additions and 9 deletions

View File

@ -31,7 +31,13 @@ class Group < Principal
lastname.to_s lastname.to_s
end end
alias :name :to_s def name
lastname
end
def name=(arg)
self.lastname = arg
end
def user_added(user) def user_added(user)
members.each do |member| members.each do |member|

View File

@ -1,7 +1,7 @@
<%= error_messages_for @group %> <%= error_messages_for @group %>
<div class="box tabular"> <div class="box tabular">
<p><%= f.text_field :lastname, :label => :field_name %></p> <p><%= f.text_field :name %></p>
<% @group.custom_field_values.each do |value| %> <% @group.custom_field_values.each do |value| %>
<p><%= custom_field_tag_with_label :group, value %></p> <p><%= custom_field_tag_with_label :group, value %></p>
<% end %> <% end %>

View File

@ -40,11 +40,12 @@ class GroupsControllerTest < ActionController::TestCase
get :new get :new
assert_response :success assert_response :success
assert_template 'new' assert_template 'new'
assert_select 'input[name=?]', 'group[name]'
end end
def test_create def test_create
assert_difference 'Group.count' do assert_difference 'Group.count' do
post :create, :group => {:lastname => 'New group'} post :create, :group => {:name => 'New group'}
end end
assert_redirected_to '/groups' assert_redirected_to '/groups'
group = Group.first(:order => 'id DESC') group = Group.first(:order => 'id DESC')
@ -54,7 +55,7 @@ class GroupsControllerTest < ActionController::TestCase
def test_create_and_continue def test_create_and_continue
assert_difference 'Group.count' do assert_difference 'Group.count' do
post :create, :group => {:lastname => 'New group'}, :continue => 'Create and continue' post :create, :group => {:name => 'New group'}, :continue => 'Create and continue'
end end
assert_redirected_to '/groups/new' assert_redirected_to '/groups/new'
group = Group.first(:order => 'id DESC') group = Group.first(:order => 'id DESC')
@ -63,7 +64,7 @@ class GroupsControllerTest < ActionController::TestCase
def test_create_with_failure def test_create_with_failure
assert_no_difference 'Group.count' do assert_no_difference 'Group.count' do
post :create, :group => {:lastname => ''} post :create, :group => {:name => ''}
end end
assert_response :success assert_response :success
assert_template 'new' assert_template 'new'
@ -79,14 +80,14 @@ class GroupsControllerTest < ActionController::TestCase
def test_update def test_update
new_name = 'New name' new_name = 'New name'
put :update, :id => 10, :group => {:lastname => new_name} put :update, :id => 10, :group => {:name => new_name}
assert_redirected_to '/groups' assert_redirected_to '/groups'
group = Group.find(10) group = Group.find(10)
assert_equal new_name, group.name assert_equal new_name, group.name
end end
def test_update_with_failure def test_update_with_failure
put :update, :id => 10, :group => {:lastname => ''} put :update, :id => 10, :group => {:name => ''}
assert_response :success assert_response :success
assert_template 'edit' assert_template 'edit'
end end

View File

@ -21,7 +21,7 @@ module ObjectHelpers
@generated_group_name ||= 'Group 0' @generated_group_name ||= 'Group 0'
@generated_group_name.succ! @generated_group_name.succ!
group = Group.new(attributes) group = Group.new(attributes)
group.lastname = @generated_group_name if group.lastname.blank? group.name = @generated_group_name if group.name.blank?
yield group if block_given? yield group if block_given?
group.save! group.save!
group group

View File

@ -31,8 +31,10 @@ class GroupTest < ActiveSupport::TestCase
include Redmine::I18n include Redmine::I18n
def test_create def test_create
g = Group.new(:lastname => 'New group') g = Group.new(:name => 'New group')
assert g.save assert g.save
g.reload
assert_equal 'New group', g.name
end end
def test_blank_name_error_message def test_blank_name_error_message