annotate test/unit/enumeration_test.rb @ 1082:997f6d7738f7 bug_531

In repo controller entry action, show the page for the file even if it's binary (so user still has access to history etc links). This makes it possible to use the entry action as the default when a file is clicked on
author Chris Cannam <chris.cannam@soundsoftware.ac.uk>
date Thu, 22 Nov 2012 18:04:17 +0000
parents cbb26bc654de
children 433d4f72a19b
rev   line source
Chris@909 1 # Redmine - project management software
Chris@0 2 # Copyright (C) 2006-2008 Jean-Philippe Lang
Chris@0 3 #
Chris@0 4 # This program is free software; you can redistribute it and/or
Chris@0 5 # modify it under the terms of the GNU General Public License
Chris@0 6 # as published by the Free Software Foundation; either version 2
Chris@0 7 # of the License, or (at your option) any later version.
Chris@909 8 #
Chris@0 9 # This program is distributed in the hope that it will be useful,
Chris@0 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@0 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@0 12 # GNU General Public License for more details.
Chris@909 13 #
Chris@0 14 # You should have received a copy of the GNU General Public License
Chris@0 15 # along with this program; if not, write to the Free Software
Chris@0 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Chris@0 17
Chris@119 18 require File.expand_path('../../test_helper', __FILE__)
Chris@0 19
Chris@0 20 class EnumerationTest < ActiveSupport::TestCase
Chris@0 21 fixtures :enumerations, :issues, :custom_fields, :custom_values
Chris@0 22
Chris@0 23 def setup
Chris@0 24 end
Chris@909 25
Chris@0 26 def test_objects_count
Chris@0 27 # low priority
Chris@0 28 assert_equal 6, Enumeration.find(4).objects_count
Chris@0 29 # urgent
Chris@0 30 assert_equal 0, Enumeration.find(7).objects_count
Chris@0 31 end
Chris@909 32
Chris@0 33 def test_in_use
Chris@0 34 # low priority
Chris@0 35 assert Enumeration.find(4).in_use?
Chris@0 36 # urgent
Chris@0 37 assert !Enumeration.find(7).in_use?
Chris@0 38 end
Chris@909 39
Chris@0 40 def test_default
Chris@0 41 e = Enumeration.default
Chris@0 42 assert e.is_a?(Enumeration)
Chris@0 43 assert e.is_default?
Chris@0 44 assert_equal 'Default Enumeration', e.name
Chris@0 45 end
Chris@909 46
Chris@0 47 def test_create
Chris@0 48 e = Enumeration.new(:name => 'Not default', :is_default => false)
Chris@0 49 e.type = 'Enumeration'
Chris@0 50 assert e.save
Chris@0 51 assert_equal 'Default Enumeration', Enumeration.default.name
Chris@0 52 end
Chris@909 53
Chris@0 54 def test_create_as_default
Chris@0 55 e = Enumeration.new(:name => 'Very urgent', :is_default => true)
Chris@0 56 e.type = 'Enumeration'
Chris@0 57 assert e.save
Chris@0 58 assert_equal e, Enumeration.default
Chris@0 59 end
Chris@909 60
Chris@0 61 def test_update_default
Chris@0 62 e = Enumeration.default
Chris@0 63 e.update_attributes(:name => 'Changed', :is_default => true)
Chris@0 64 assert_equal e, Enumeration.default
Chris@0 65 end
Chris@909 66
Chris@0 67 def test_update_default_to_non_default
Chris@0 68 e = Enumeration.default
Chris@0 69 e.update_attributes(:name => 'Changed', :is_default => false)
Chris@0 70 assert_nil Enumeration.default
Chris@0 71 end
Chris@909 72
Chris@0 73 def test_change_default
Chris@0 74 e = Enumeration.find_by_name('Default Enumeration')
Chris@0 75 e.update_attributes(:name => 'Changed Enumeration', :is_default => true)
Chris@0 76 assert_equal e, Enumeration.default
Chris@0 77 end
Chris@909 78
Chris@0 79 def test_destroy_with_reassign
Chris@0 80 Enumeration.find(4).destroy(Enumeration.find(6))
Chris@0 81 assert_nil Issue.find(:first, :conditions => {:priority_id => 4})
Chris@0 82 assert_equal 6, Enumeration.find(6).objects_count
Chris@0 83 end
Chris@0 84
Chris@0 85 def test_should_be_customizable
Chris@0 86 assert Enumeration.included_modules.include?(Redmine::Acts::Customizable::InstanceMethods)
Chris@0 87 end
Chris@0 88
Chris@0 89 def test_should_belong_to_a_project
Chris@0 90 association = Enumeration.reflect_on_association(:project)
Chris@0 91 assert association, "No Project association found"
Chris@0 92 assert_equal :belongs_to, association.macro
Chris@0 93 end
Chris@0 94
Chris@0 95 def test_should_act_as_tree
Chris@0 96 enumeration = Enumeration.find(4)
Chris@0 97
Chris@0 98 assert enumeration.respond_to?(:parent)
Chris@0 99 assert enumeration.respond_to?(:children)
Chris@0 100 end
Chris@0 101
Chris@0 102 def test_is_override
Chris@0 103 # Defaults to off
Chris@0 104 enumeration = Enumeration.find(4)
Chris@0 105 assert !enumeration.is_override?
Chris@0 106
Chris@0 107 # Setup as an override
Chris@0 108 enumeration.parent = Enumeration.find(5)
Chris@0 109 assert enumeration.is_override?
Chris@0 110 end
Chris@0 111 end