##// END OF EJS Templates
Speeds up rendering of the project list for users who belong to hundreds of projects....
Speeds up rendering of the project list for users who belong to hundreds of projects. git-svn-id: http://svn.redmine.org/redmine/trunk@16123 e93f8b46-1217-0410-a6f0-8f06a7374b81

File last commit:

r14856:cda9c63d9c21
r15741:f8df935dcada
Show More
time_entry_activity_test.rb
130 lines | 4.7 KiB | text/x-ruby | RubyLexer
/ test / unit / time_entry_activity_test.rb
Toshi MARUYAMA
remove trailing white-spaces from test/unit/time_entry_activity_test.rb....
r6652 # Redmine - project management software
Jean-Philippe Lang
Updates copyright for 2016....
r14856 # Copyright (C) 2006-2016 Jean-Philippe Lang
Eric Davis
Changed Enumerations to use a Single Table Inheritance...
r2677 #
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
Toshi MARUYAMA
remove trailing white-spaces from test/unit/time_entry_activity_test.rb....
r6652 #
Eric Davis
Changed Enumerations to use a Single Table Inheritance...
r2677 # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
Toshi MARUYAMA
remove trailing white-spaces from test/unit/time_entry_activity_test.rb....
r6652 #
Eric Davis
Changed Enumerations to use a Single Table Inheritance...
r2677 # You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Jean-Baptiste Barth
Use absolute paths in test/**/* requires for Ruby 1.9.2 compatibility. #4050...
r4395 require File.expand_path('../../test_helper', __FILE__)
Eric Davis
Changed Enumerations to use a Single Table Inheritance...
r2677
Eric Davis
Upgraded to Rails 2.3.4 (#3597)...
r2773 class TimeEntryActivityTest < ActiveSupport::TestCase
Toshi MARUYAMA
add missing fixtures to TimeEntryActivityTest...
r13025 fixtures :enumerations, :time_entries, :custom_fields,
:issues, :projects, :users,
:members, :roles, :member_roles,
:trackers, :issue_statuses,
:projects_trackers,
:issue_categories,
:groups_users,
:enabled_modules
Eric Davis
Changed Enumerations to use a Single Table Inheritance...
r2677
Jean-Philippe Lang
Extracts custom field values validation from CustomValue so that they can be validated globally from the customized object (#1189)....
r8597 include Redmine::I18n
Eric Davis
Changed Enumerations to use a Single Table Inheritance...
r2677 def test_should_be_an_enumeration
assert TimeEntryActivity.ancestors.include?(Enumeration)
end
Toshi MARUYAMA
add functional tests for bulk edit time entries (#7996)....
r5195
Eric Davis
Changed Enumerations to use a Single Table Inheritance...
r2677 def test_objects_count
assert_equal 3, TimeEntryActivity.find_by_name("Design").objects_count
Toshi MARUYAMA
add functional tests for bulk edit time entries (#7996)....
r5195 assert_equal 2, TimeEntryActivity.find_by_name("Development").objects_count
Eric Davis
Changed Enumerations to use a Single Table Inheritance...
r2677 end
def test_option_name
assert_equal :enumeration_activities, TimeEntryActivity.new.option_name
end
Eric Davis
Enumerations can now have custom fields defined on them. #4077...
r2831
def test_create_with_custom_field
field = TimeEntryActivityCustomField.find_by_name('Billable')
e = TimeEntryActivity.new(:name => 'Custom Data')
e.custom_field_values = {field.id => "1"}
assert e.save
e.reload
assert_equal "1", e.custom_value_for(field).value
end
def test_create_without_required_custom_field_should_fail
Jean-Philippe Lang
Extracts custom field values validation from CustomValue so that they can be validated globally from the customized object (#1189)....
r8597 set_language_if_valid 'en'
Eric Davis
Enumerations can now have custom fields defined on them. #4077...
r2831 field = TimeEntryActivityCustomField.find_by_name('Billable')
field.update_attribute(:is_required, true)
e = TimeEntryActivity.new(:name => 'Custom Data')
assert !e.save
Jean-Philippe Lang
Replaced "can't" with "cannot" in error messages....
r13399 assert_equal ["Billable cannot be blank"], e.errors.full_messages
Eric Davis
Enumerations can now have custom fields defined on them. #4077...
r2831 end
def test_create_with_required_custom_field_should_succeed
field = TimeEntryActivityCustomField.find_by_name('Billable')
field.update_attribute(:is_required, true)
e = TimeEntryActivity.new(:name => 'Custom Data')
e.custom_field_values = {field.id => "1"}
assert e.save
end
Jean-Philippe Lang
Extracts custom field values validation from CustomValue so that they can be validated globally from the customized object (#1189)....
r8597 def test_update_with_required_custom_field_change
set_language_if_valid 'en'
Eric Davis
Enumerations can now have custom fields defined on them. #4077...
r2831 field = TimeEntryActivityCustomField.find_by_name('Billable')
field.update_attribute(:is_required, true)
e = TimeEntryActivity.find(10)
assert e.available_custom_fields.include?(field)
# No change to custom field, record can be saved
assert e.save
# Blanking custom field, save should fail
e.custom_field_values = {field.id => ""}
assert !e.save
Jean-Philippe Lang
Replaced "can't" with "cannot" in error messages....
r13399 assert_equal ["Billable cannot be blank"], e.errors.full_messages
Toshi MARUYAMA
remove trailing white-spaces from test/unit/time_entry_activity_test.rb....
r6652
Eric Davis
Enumerations can now have custom fields defined on them. #4077...
r2831 # Update custom field to valid value, save should succeed
e.custom_field_values = {field.id => "0"}
assert e.save
e.reload
assert_equal "0", e.custom_value_for(field).value
end
Eric Davis
Changed Enumerations to use a Single Table Inheritance...
r2677
Jean-Philippe Lang
Fixed that deleting a system activity with children in use raises an error (#13783)....
r11533 def test_system_activity_with_child_in_use_should_be_in_use
project = Project.generate!
system_activity = TimeEntryActivity.create!(:name => 'Activity')
project_activity = TimeEntryActivity.create!(:name => 'Activity', :project => project, :parent_id => system_activity.id)
TimeEntry.generate!(:project => project, :activity => project_activity)
assert project_activity.in_use?
assert system_activity.in_use?
end
def test_destroying_a_system_activity_should_reassign_children_activities
project = Project.generate!
Jean-Philippe Lang
Fixed test failures introduced by r14288 (#19656)....
r13909 entries = []
Jean-Philippe Lang
Fixed that deleting a system activity with children in use raises an error (#13783)....
r11533 system_activity = TimeEntryActivity.create!(:name => 'Activity')
Jean-Philippe Lang
Fixed test failures introduced by r14288 (#19656)....
r13909 entries << TimeEntry.generate!(:project => project, :activity => system_activity)
Jean-Philippe Lang
Fixed that deleting a system activity with children in use raises an error (#13783)....
r11533 project_activity = TimeEntryActivity.create!(:name => 'Activity', :project => project, :parent_id => system_activity.id)
Jean-Philippe Lang
Fixed test failures introduced by r14288 (#19656)....
r13909 entries << TimeEntry.generate!(:project => project.reload, :activity => project_activity)
Jean-Philippe Lang
Fixed that deleting a system activity with children in use raises an error (#13783)....
r11533
assert_difference 'TimeEntryActivity.count', -2 do
assert_nothing_raised do
assert system_activity.destroy(TimeEntryActivity.find_by_name('Development'))
end
end
assert entries.all? {|entry| entry.reload.activity.name == 'Development'}
end
Jean-Philippe Lang
Fixed that project activity without parent hides system activities and removed duplicated code....
r13910
def test_project_activity_without_parent_should_not_disable_system_activities
project = Project.find(1)
activity = TimeEntryActivity.create!(:name => 'Csutom', :project => project)
assert_include activity, project.activities
assert_include TimeEntryActivity.find(9), project.activities
end
Jean-Philippe Lang
Fixed that deleting a system activity with children in use raises an error (#13783)....
r11533 end