diff options
author | Stefan Wintermeyer <stefan.wintermeyer@amooma.de> | 2012-12-17 12:01:45 +0100 |
---|---|---|
committer | Stefan Wintermeyer <stefan.wintermeyer@amooma.de> | 2012-12-17 12:01:45 +0100 |
commit | b80bd744ad873f6fc43018bc4bfb90677de167bd (patch) | |
tree | 072c4b0e33d442528555b82c415f5e7a1712b2b0 /test/unit/user_group_membership_test.rb | |
parent | 3e706c2025ecc5523e81ad649639ef2ff75e7bac (diff) |
Start of GS5.
Diffstat (limited to 'test/unit/user_group_membership_test.rb')
-rw-r--r-- | test/unit/user_group_membership_test.rb | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/test/unit/user_group_membership_test.rb b/test/unit/user_group_membership_test.rb new file mode 100644 index 0000000..251229f --- /dev/null +++ b/test/unit/user_group_membership_test.rb @@ -0,0 +1,39 @@ +require 'test_helper' + +class UserGroupMembershipTest < ActiveSupport::TestCase + def test_should_have_a_valid_factory + assert Factory.build(:user_group_membership).valid? + end + def test_should_have_unique_members_in_each_group + group1 = Factory.create(:user_group) + group2 = Factory.create(:user_group) + user1 = Factory.create(:user) + user2 = Factory.create(:user) + member = Factory.create( + :user_group_membership, + :user_id => user1.id, + :user_group_id => group1.id + ) + assert !Factory.build( + :user_group_membership, + :user_id => user1.id, + :user_group_id => group1.id + ).valid? + assert Factory.build( + :user_group_membership, + :user_id => user1.id, + :user_group_id => group2.id + ).valid? + assert Factory.build( + :user_group_membership, + :user_id => user2.id, + :user_group_id => group1.id + ).valid? + end + + def test_that_the_initial_state_should_be_active + @user_group_membership = Factory.create(:user_group_membership) + assert_equal 'active', @user_group_membership.state + assert @user_group_membership.active? + end +end |