##// END OF EJS Templates
Remove some inline styling and some depreciated table cell attributes and replace them with proper class names....
Remove some inline styling and some depreciated table cell attributes and replace them with proper class names. Contributed by Andrew Smith. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9252 e93f8b46-1217-0410-a6f0-8f06a7374b81

File last commit:

r8986:d4372ab74748
r9132:103cd46f7814
Show More
time_entry_activity_test.rb
88 lines | 3.0 KiB | text/x-ruby | RubyLexer
/ test / unit / time_entry_activity_test.rb
# Redmine - project management software
# Copyright (C) 2006-2012 Jean-Philippe Lang
#
# 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.
#
# 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.
#
# 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.
require File.expand_path('../../test_helper', __FILE__)
class TimeEntryActivityTest < ActiveSupport::TestCase
fixtures :enumerations, :time_entries
include Redmine::I18n
def test_should_be_an_enumeration
assert TimeEntryActivity.ancestors.include?(Enumeration)
end
def test_objects_count
assert_equal 3, TimeEntryActivity.find_by_name("Design").objects_count
assert_equal 2, TimeEntryActivity.find_by_name("Development").objects_count
end
def test_option_name
assert_equal :enumeration_activities, TimeEntryActivity.new.option_name
end
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
set_language_if_valid 'en'
field = TimeEntryActivityCustomField.find_by_name('Billable')
field.update_attribute(:is_required, true)
e = TimeEntryActivity.new(:name => 'Custom Data')
assert !e.save
assert_equal ["Billable can't be blank"], e.errors.full_messages
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
def test_update_with_required_custom_field_change
set_language_if_valid 'en'
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
assert_equal ["Billable can't be blank"], e.errors.full_messages
# 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
end