diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2009-05-10 10:54:31 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2009-05-10 10:54:31 +0000 |
commit | 7dccf9fda6f30d8f4b0c5eaad9f6e2a1e67cd643 (patch) | |
tree | ba6a18abff6ca69af528b3d295263d049a22266f /test/unit/member_test.rb | |
parent | 814e138c2a1105f8d9d10c4362a889dd71aff32d (diff) | |
download | redmine-7dccf9fda6f30d8f4b0c5eaad9f6e2a1e67cd643.tar.gz redmine-7dccf9fda6f30d8f4b0c5eaad9f6e2a1e67cd643.zip |
Allows multiple roles on the same project (#706). Prerequisite for user groups feature.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2726 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit/member_test.rb')
-rw-r--r-- | test/unit/member_test.rb | 38 |
1 files changed, 29 insertions, 9 deletions
diff --git a/test/unit/member_test.rb b/test/unit/member_test.rb index 079782306..66f1283ca 100644 --- a/test/unit/member_test.rb +++ b/test/unit/member_test.rb @@ -18,34 +18,54 @@ require File.dirname(__FILE__) + '/../test_helper' class MemberTest < Test::Unit::TestCase - fixtures :users, :projects, :roles, :members + fixtures :users, :projects, :roles, :members, :member_roles def setup @jsmith = Member.find(1) end def test_create
- member = Member.new(:project_id => 1, :user_id => 4, :role_id => 1)
- assert member.save
+ member = Member.new(:project_id => 1, :user_id => 4, :role_ids => [1, 2])
+ assert member.save + member.reload + + assert_equal 2, member.roles.size + assert_equal Role.find(1), member.roles.sort.first
end
def test_update assert_equal "eCookbook", @jsmith.project.name
- assert_equal "Manager", @jsmith.role.name
+ assert_equal "Manager", @jsmith.roles.first.name
assert_equal "jsmith", @jsmith.user.login
- @jsmith.role = Role.find(2)
+ @jsmith.mail_notification = !@jsmith.mail_notification
assert @jsmith.save end + + def test_update_roles + assert_equal 1, @jsmith.roles.size + @jsmith.role_ids = [1, 2] + assert @jsmith.save + assert_equal 2, @jsmith.reload.roles.size + end def test_validate
- member = Member.new(:project_id => 1, :user_id => 2, :role_id =>2)
- # same use can't have more than one role for a project
+ member = Member.new(:project_id => 1, :user_id => 2, :role_ids => [2])
+ # same use can't have more than one membership for a project
+ assert !member.save + + member = Member.new(:project_id => 1, :user_id => 2, :role_ids => []) + # must have one role at least assert !member.save
end
- def test_destroy
- @jsmith.destroy
+ def test_destroy + assert_difference 'Member.count', -1 do + assert_difference 'MemberRole.count', -1 do
+ @jsmith.destroy + end + end +
assert_raise(ActiveRecord::RecordNotFound) { Member.find(@jsmith.id) }
end end |