Merged r1307 to r1369 from trunk.
git-svn-id: http://redmine.rubyforge.org/svn/branches/0.7-stable@1370 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -41,22 +41,22 @@ class ChangesetTest < Test::Unit::TestCase
|
||||
end
|
||||
|
||||
def test_previous
|
||||
changeset = Changeset.find_by_revision(3)
|
||||
assert_equal Changeset.find_by_revision(2), changeset.previous
|
||||
changeset = Changeset.find_by_revision('3')
|
||||
assert_equal Changeset.find_by_revision('2'), changeset.previous
|
||||
end
|
||||
|
||||
def test_previous_nil
|
||||
changeset = Changeset.find_by_revision(1)
|
||||
changeset = Changeset.find_by_revision('1')
|
||||
assert_nil changeset.previous
|
||||
end
|
||||
|
||||
def test_next
|
||||
changeset = Changeset.find_by_revision(2)
|
||||
assert_equal Changeset.find_by_revision(3), changeset.next
|
||||
changeset = Changeset.find_by_revision('2')
|
||||
assert_equal Changeset.find_by_revision('3'), changeset.next
|
||||
end
|
||||
|
||||
def test_next_nil
|
||||
changeset = Changeset.find_by_revision(4)
|
||||
changeset = Changeset.find_by_revision('4')
|
||||
assert_nil changeset.next
|
||||
end
|
||||
end
|
||||
|
||||
@@ -20,7 +20,7 @@ require File.dirname(__FILE__) + '/../../test_helper'
|
||||
class ApplicationHelperTest < HelperTestCase
|
||||
include ApplicationHelper
|
||||
include ActionView::Helpers::TextHelper
|
||||
fixtures :projects, :repositories, :changesets, :trackers, :issue_statuses, :issues, :documents, :versions, :wikis, :wiki_pages, :wiki_contents
|
||||
fixtures :projects, :repositories, :changesets, :trackers, :issue_statuses, :issues, :documents, :versions, :wikis, :wiki_pages, :wiki_contents, :roles, :enabled_modules
|
||||
|
||||
def setup
|
||||
super
|
||||
@@ -134,8 +134,9 @@ class ApplicationHelperTest < HelperTestCase
|
||||
|
||||
def test_html_tags
|
||||
to_test = {
|
||||
"<div>content</div>" => "<p><div>content</div></p>",
|
||||
"<script>some script;</script>" => "<p><script>some script;</script></p>",
|
||||
"<div>content</div>" => "<p><div>content</div></p>",
|
||||
"<div class=\"bold\">content</div>" => "<p><div class=\"bold\">content</div></p>",
|
||||
"<script>some script;</script>" => "<p><script>some script;</script></p>",
|
||||
# do not escape pre/code tags
|
||||
"<pre>\nline 1\nline2</pre>" => "<pre>\nline 1\nline2</pre>",
|
||||
"<pre><code>\nline 1\nline2</code></pre>" => "<pre><code>\nline 1\nline2</code></pre>",
|
||||
@@ -167,6 +168,24 @@ class ApplicationHelperTest < HelperTestCase
|
||||
assert_equal '<p>{{hello_world}}</p>', textilizable(text)
|
||||
end
|
||||
|
||||
def test_macro_include
|
||||
@project = Project.find(1)
|
||||
# include a page of the current project wiki
|
||||
text = "{{include(Another page)}}"
|
||||
assert textilizable(text).match(/This is a link to a ticket/)
|
||||
|
||||
@project = nil
|
||||
# include a page of a specific project wiki
|
||||
text = "{{include(ecookbook:Another page)}}"
|
||||
assert textilizable(text).match(/This is a link to a ticket/)
|
||||
|
||||
text = "{{include(ecookbook:)}}"
|
||||
assert textilizable(text).match(/CookBook documentation/)
|
||||
|
||||
text = "{{include(unknowidentifier:somepage)}}"
|
||||
assert textilizable(text).match(/Unknow project/)
|
||||
end
|
||||
|
||||
def test_date_format_default
|
||||
today = Date.today
|
||||
Setting.date_format = ''
|
||||
|
||||
@@ -20,6 +20,13 @@ require File.dirname(__FILE__) + '/../test_helper'
|
||||
class IssueTest < Test::Unit::TestCase
|
||||
fixtures :projects, :users, :members, :trackers, :projects_trackers, :issue_statuses, :issue_categories, :enumerations, :issues, :custom_fields, :custom_values, :time_entries
|
||||
|
||||
def test_create
|
||||
issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 3, :status_id => 1, :priority => Enumeration.get_values('IPRI').first, :subject => 'test_create', :description => 'IssueTest#test_create', :estimated_hours => '1:30')
|
||||
assert issue.save
|
||||
issue.reload
|
||||
assert_equal 1.5, issue.estimated_hours
|
||||
end
|
||||
|
||||
def test_category_based_assignment
|
||||
issue = Issue.create(:project_id => 1, :tracker_id => 1, :author_id => 3, :status_id => 1, :priority => Enumeration.get_values('IPRI').first, :subject => 'Assignment test', :description => 'Assignment test', :category_id => 1)
|
||||
assert_equal IssueCategory.find(1).assigned_to, issue.assigned_to
|
||||
@@ -48,6 +55,8 @@ class IssueTest < Test::Unit::TestCase
|
||||
IssueRelation.create(:issue_from => issue1, :issue_to => issue2, :relation_type => IssueRelation::TYPE_DUPLICATES)
|
||||
# And 3 is a dupe of 2
|
||||
IssueRelation.create(:issue_from => issue2, :issue_to => issue3, :relation_type => IssueRelation::TYPE_DUPLICATES)
|
||||
# And 3 is a dupe of 1 (circular duplicates)
|
||||
IssueRelation.create(:issue_from => issue1, :issue_to => issue3, :relation_type => IssueRelation::TYPE_DUPLICATES)
|
||||
|
||||
assert issue1.reload.duplicates.include?(issue2)
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
require File.dirname(__FILE__) + '/../test_helper'
|
||||
|
||||
class ProjectTest < Test::Unit::TestCase
|
||||
fixtures :projects, :issues, :issue_statuses, :journals, :journal_details, :users, :members, :roles, :projects_trackers, :trackers
|
||||
fixtures :projects, :issues, :issue_statuses, :journals, :journal_details, :users, :members, :roles, :projects_trackers, :trackers, :boards
|
||||
|
||||
def setup
|
||||
@ecookbook = Project.find(1)
|
||||
@@ -84,12 +84,15 @@ class ProjectTest < Test::Unit::TestCase
|
||||
assert_equal 2, @ecookbook.members.size
|
||||
# and 1 is locked
|
||||
assert_equal 3, Member.find(:all, :conditions => ['project_id = ?', @ecookbook.id]).size
|
||||
# some boards
|
||||
assert @ecookbook.boards.any?
|
||||
|
||||
@ecookbook.destroy
|
||||
# make sure that the project non longer exists
|
||||
assert_raise(ActiveRecord::RecordNotFound) { Project.find(@ecookbook.id) }
|
||||
# make sure all members have been removed
|
||||
assert_equal 0, Member.find(:all, :conditions => ['project_id = ?', @ecookbook.id]).size
|
||||
# make sure related data was removed
|
||||
assert Member.find(:all, :conditions => ['project_id = ?', @ecookbook.id]).empty?
|
||||
assert Board.find(:all, :conditions => ['project_id = ?', @ecookbook.id]).empty?
|
||||
end
|
||||
|
||||
def test_subproject_ok
|
||||
|
||||
+33
-3
@@ -1,5 +1,5 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006-2007 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2008 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
|
||||
@@ -18,12 +18,12 @@
|
||||
require File.dirname(__FILE__) + '/../test_helper'
|
||||
|
||||
class QueryTest < Test::Unit::TestCase
|
||||
fixtures :projects, :users, :trackers, :issue_statuses, :issue_categories, :enumerations, :issues, :custom_fields, :custom_values, :queries
|
||||
fixtures :projects, :users, :members, :roles, :trackers, :issue_statuses, :issue_categories, :enumerations, :issues, :custom_fields, :custom_values, :queries
|
||||
|
||||
def test_query_with_multiple_custom_fields
|
||||
query = Query.find(1)
|
||||
assert query.valid?
|
||||
assert query.statement.include?("custom_values.value IN ('MySQL')")
|
||||
assert query.statement.include?("#{CustomValue.table_name}.value IN ('MySQL')")
|
||||
issues = Issue.find :all,:include => [ :assigned_to, :status, :tracker, :project, :priority ], :conditions => query.statement
|
||||
assert_equal 1, issues.length
|
||||
assert_equal Issue.find(3), issues.first
|
||||
@@ -41,4 +41,34 @@ class QueryTest < Test::Unit::TestCase
|
||||
c = q.columns.first
|
||||
assert q.has_column?(c)
|
||||
end
|
||||
|
||||
def test_editable_by
|
||||
admin = User.find(1)
|
||||
manager = User.find(2)
|
||||
developer = User.find(3)
|
||||
|
||||
# Public query on project 1
|
||||
q = Query.find(1)
|
||||
assert q.editable_by?(admin)
|
||||
assert q.editable_by?(manager)
|
||||
assert !q.editable_by?(developer)
|
||||
|
||||
# Private query on project 1
|
||||
q = Query.find(2)
|
||||
assert q.editable_by?(admin)
|
||||
assert !q.editable_by?(manager)
|
||||
assert q.editable_by?(developer)
|
||||
|
||||
# Private query for all projects
|
||||
q = Query.find(3)
|
||||
assert q.editable_by?(admin)
|
||||
assert !q.editable_by?(manager)
|
||||
assert q.editable_by?(developer)
|
||||
|
||||
# Public query for all projects
|
||||
q = Query.find(4)
|
||||
assert q.editable_by?(admin)
|
||||
assert !q.editable_by?(manager)
|
||||
assert !q.editable_by?(developer)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -36,13 +36,13 @@ class RepositoryBazaarTest < Test::Unit::TestCase
|
||||
|
||||
assert_equal 4, @repository.changesets.count
|
||||
assert_equal 9, @repository.changes.count
|
||||
assert_equal 'Initial import', @repository.changesets.find_by_revision(1).comments
|
||||
assert_equal 'Initial import', @repository.changesets.find_by_revision('1').comments
|
||||
end
|
||||
|
||||
def test_fetch_changesets_incremental
|
||||
@repository.fetch_changesets
|
||||
# Remove changesets with revision > 5
|
||||
@repository.changesets.find(:all, :conditions => 'revision > 2').each(&:destroy)
|
||||
@repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 2}
|
||||
@repository.reload
|
||||
assert_equal 2, @repository.changesets.count
|
||||
|
||||
|
||||
@@ -35,13 +35,13 @@ class RepositoryDarcsTest < Test::Unit::TestCase
|
||||
|
||||
assert_equal 6, @repository.changesets.count
|
||||
assert_equal 13, @repository.changes.count
|
||||
assert_equal "Initial commit.", @repository.changesets.find_by_revision(1).comments
|
||||
assert_equal "Initial commit.", @repository.changesets.find_by_revision('1').comments
|
||||
end
|
||||
|
||||
def test_fetch_changesets_incremental
|
||||
@repository.fetch_changesets
|
||||
# Remove changesets with revision > 3
|
||||
@repository.changesets.find(:all, :conditions => 'revision > 3').each(&:destroy)
|
||||
@repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 3}
|
||||
@repository.reload
|
||||
assert_equal 3, @repository.changesets.count
|
||||
|
||||
|
||||
@@ -35,13 +35,13 @@ class RepositoryMercurialTest < Test::Unit::TestCase
|
||||
|
||||
assert_equal 6, @repository.changesets.count
|
||||
assert_equal 11, @repository.changes.count
|
||||
assert_equal "Initial import.\nThe repository contains 3 files.", @repository.changesets.find_by_revision(0).comments
|
||||
assert_equal "Initial import.\nThe repository contains 3 files.", @repository.changesets.find_by_revision('0').comments
|
||||
end
|
||||
|
||||
def test_fetch_changesets_incremental
|
||||
@repository.fetch_changesets
|
||||
# Remove changesets with revision > 2
|
||||
@repository.changesets.find(:all, :conditions => 'revision > 2').each(&:destroy)
|
||||
@repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 2}
|
||||
@repository.reload
|
||||
assert_equal 3, @repository.changesets.count
|
||||
|
||||
|
||||
@@ -35,13 +35,13 @@ class RepositorySubversionTest < Test::Unit::TestCase
|
||||
|
||||
assert_equal 8, @repository.changesets.count
|
||||
assert_equal 16, @repository.changes.count
|
||||
assert_equal 'Initial import.', @repository.changesets.find_by_revision(1).comments
|
||||
assert_equal 'Initial import.', @repository.changesets.find_by_revision('1').comments
|
||||
end
|
||||
|
||||
def test_fetch_changesets_incremental
|
||||
@repository.fetch_changesets
|
||||
# Remove changesets with revision > 5
|
||||
@repository.changesets.find(:all, :conditions => 'revision > 5').each(&:destroy)
|
||||
@repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 5}
|
||||
@repository.reload
|
||||
assert_equal 5, @repository.changesets.count
|
||||
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006-2008 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.dirname(__FILE__) + '/../test_helper'
|
||||
|
||||
class TimeEntryTest < Test::Unit::TestCase
|
||||
fixtures :issues, :projects, :users, :time_entries
|
||||
|
||||
def test_hours_format
|
||||
assertions = { "2" => 2.0,
|
||||
"21.1" => 21.1,
|
||||
"2,1" => 2.1,
|
||||
"7:12" => 7.2,
|
||||
"10h" => 10.0,
|
||||
"10 h" => 10.0,
|
||||
"45m" => 0.75,
|
||||
"45 m" => 0.75,
|
||||
"3h15" => 3.25,
|
||||
"3h 15" => 3.25,
|
||||
"3 h 15" => 3.25,
|
||||
"3 h 15m" => 3.25,
|
||||
"3 h 15 m" => 3.25,
|
||||
"3 hours" => 3.0,
|
||||
"12min" => 0.2,
|
||||
}
|
||||
|
||||
assertions.each do |k, v|
|
||||
t = TimeEntry.new(:hours => k)
|
||||
assert_equal v, t.hours
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user