annotate .svn/pristine/c5/c5eef695c607c92e30f00026dd7c86eab2c87b3e.svn-base @ 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
rev   line source
Chris@909 1 # Redmine - project management software
Chris@909 2 # Copyright (C) 2006-2011 Jean-Philippe Lang
Chris@909 3 #
Chris@909 4 # This program is free software; you can redistribute it and/or
Chris@909 5 # modify it under the terms of the GNU General Public License
Chris@909 6 # as published by the Free Software Foundation; either version 2
Chris@909 7 # of the License, or (at your option) any later version.
Chris@909 8 #
Chris@909 9 # This program is distributed in the hope that it will be useful,
Chris@909 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@909 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@909 12 # GNU General Public License for more details.
Chris@909 13 #
Chris@909 14 # You should have received a copy of the GNU General Public License
Chris@909 15 # along with this program; if not, write to the Free Software
Chris@909 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Chris@909 17
Chris@909 18 require File.expand_path('../../test_helper', __FILE__)
Chris@909 19
Chris@909 20 class CustomFieldVersionFormatTest < ActiveSupport::TestCase
Chris@909 21 fixtures :custom_fields, :projects, :members, :users, :member_roles, :trackers, :issues, :versions
Chris@909 22
Chris@909 23 def setup
Chris@909 24 @field = IssueCustomField.create!(:name => 'Tester', :field_format => 'version')
Chris@909 25 end
Chris@909 26
Chris@909 27 def test_possible_values_with_no_arguments
Chris@909 28 assert_equal [], @field.possible_values
Chris@909 29 assert_equal [], @field.possible_values(nil)
Chris@909 30 end
Chris@909 31
Chris@909 32 def test_possible_values_with_project_resource
Chris@909 33 project = Project.find(1)
Chris@909 34 possible_values = @field.possible_values(project.issues.first)
Chris@909 35 assert possible_values.any?
Chris@909 36 assert_equal project.shared_versions.sort.collect(&:id).map(&:to_s), possible_values
Chris@909 37 end
Chris@909 38
Chris@909 39 def test_possible_values_with_nil_project_resource
Chris@909 40 assert_equal [], @field.possible_values(Issue.new)
Chris@909 41 end
Chris@909 42
Chris@909 43 def test_possible_values_options_with_no_arguments
Chris@909 44 assert_equal [], @field.possible_values_options
Chris@909 45 assert_equal [], @field.possible_values_options(nil)
Chris@909 46 end
Chris@909 47
Chris@909 48 def test_possible_values_options_with_project_resource
Chris@909 49 project = Project.find(1)
Chris@909 50 possible_values_options = @field.possible_values_options(project.issues.first)
Chris@909 51 assert possible_values_options.any?
Chris@909 52 assert_equal project.shared_versions.sort.map {|u| [u.name, u.id.to_s]}, possible_values_options
Chris@909 53 end
Chris@909 54
Chris@909 55 def test_possible_values_options_with_array
Chris@909 56 projects = Project.find([1, 2])
Chris@909 57 possible_values_options = @field.possible_values_options(projects)
Chris@909 58 assert possible_values_options.any?
Chris@909 59 assert_equal (projects.first.shared_versions & projects.last.shared_versions).sort.map {|u| [u.name, u.id.to_s]}, possible_values_options
Chris@909 60 end
Chris@909 61
Chris@909 62 def test_cast_blank_value
Chris@909 63 assert_equal nil, @field.cast_value(nil)
Chris@909 64 assert_equal nil, @field.cast_value("")
Chris@909 65 end
Chris@909 66
Chris@909 67 def test_cast_valid_value
Chris@909 68 version = @field.cast_value("2")
Chris@909 69 assert_kind_of Version, version
Chris@909 70 assert_equal Version.find(2), version
Chris@909 71 end
Chris@909 72
Chris@909 73 def test_cast_invalid_value
Chris@909 74 assert_equal nil, @field.cast_value("187")
Chris@909 75 end
Chris@909 76 end