diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2014-12-03 20:21:03 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2014-12-03 20:21:03 +0000 |
commit | 5222650d952390d3435848397a46d8aa1dbda09e (patch) | |
tree | 6ef084faa30f3bba0d0d1e361247f86c1f4da21d /test/unit | |
parent | 1059f9a99ec41a8e320d4d66684e65d183270920 (diff) | |
download | redmine-5222650d952390d3435848397a46d8aa1dbda09e.tar.gz redmine-5222650d952390d3435848397a46d8aa1dbda09e.zip |
Adds a few tests.
git-svn-id: http://svn.redmine.org/redmine/trunk@13695 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit')
-rw-r--r-- | test/unit/group_test.rb | 26 | ||||
-rw-r--r-- | test/unit/project_test.rb | 25 | ||||
-rw-r--r-- | test/unit/version_test.rb | 6 |
3 files changed, 57 insertions, 0 deletions
diff --git a/test/unit/group_test.rb b/test/unit/group_test.rb index d2f09f9a7..6989680ec 100644 --- a/test/unit/group_test.rb +++ b/test/unit/group_test.rb @@ -132,4 +132,30 @@ class GroupTest < ActiveSupport::TestCase assert_equal nil, Issue.find(1).assigned_to_id end + + def test_builtin_groups_should_be_created_if_missing + Group.delete_all + + assert_difference 'Group.count', 2 do + group = Group.anonymous + assert_equal GroupAnonymous, group.class + + group = Group.non_member + assert_equal GroupNonMember, group.class + end + end + + def test_builtin_in_group_should_be_uniq + group = GroupAnonymous.new + group.name = 'Foo' + assert !group.save + end + + def test_builtin_in_group_should_not_accept_users + group = Group.anonymous + assert_raise RuntimeError do + group.users << User.find(1) + end + assert_equal 0, group.reload.users.count + end end diff --git a/test/unit/project_test.rb b/test/unit/project_test.rb index 4723b4638..02bcfccbd 100644 --- a/test/unit/project_test.rb +++ b/test/unit/project_test.rb @@ -647,6 +647,12 @@ class ProjectTest < ActiveSupport::TestCase end end + def test_enabled_modules_names_with_nil_should_clear_modules + p = Project.find(1) + p.enabled_module_names = nil + assert_equal [], p.enabled_modules + end + test "enabled_modules should define module by names and preserve ids" do @project = Project.find(1) # Remove one module @@ -947,4 +953,23 @@ class ProjectTest < ActiveSupport::TestCase assert_equal [Role.anonymous], project.override_roles(Role.anonymous) assert_equal [Role.non_member], project.override_roles(Role.non_member) end + + def test_css_classes + p = Project.new + assert_kind_of String, p.css_classes + assert_not_include 'archived', p.css_classes.split + assert_not_include 'closed', p.css_classes.split + end + + def test_css_classes_for_archived_project + p = Project.new + p.status = Project::STATUS_ARCHIVED + assert_include 'archived', p.css_classes.split + end + + def test_css_classes_for_closed_project + p = Project.new + p.status = Project::STATUS_CLOSED + assert_include 'closed', p.css_classes.split + end end diff --git a/test/unit/version_test.rb b/test/unit/version_test.rb index a1dddd905..85c1079d5 100644 --- a/test/unit/version_test.rb +++ b/test/unit/version_test.rb @@ -127,6 +127,12 @@ class VersionTest < ActiveSupport::TestCase assert_equal [v5, v3, v1, v2, v4], Version.sorted.to_a end + def test_should_sort_versions_with_same_date_by_name + v1 = Version.new(:effective_date => '2014-12-03', :name => 'v2') + v2 = Version.new(:effective_date => '2014-12-03', :name => 'v1') + assert_equal [v2, v1], [v1, v2].sort + end + def test_completed_should_be_false_when_due_today version = Version.create!(:project_id => 1, :effective_date => Date.today, :name => 'Due today') assert_equal false, version.completed? |