diff options
Diffstat (limited to 'users/test/unit/identity_test.rb')
-rw-r--r-- | users/test/unit/identity_test.rb | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/users/test/unit/identity_test.rb b/users/test/unit/identity_test.rb index 3130ddc..a5d30b0 100644 --- a/users/test/unit/identity_test.rb +++ b/users/test/unit/identity_test.rb @@ -6,7 +6,11 @@ class IdentityTest < ActiveSupport::TestCase @user = FactoryGirl.create(:user) end - test "user has identity to start with" do + teardown do + @user.destroy + end + + test "initial identity for a user" do id = @user.build_identity assert_equal @user.email_address, id.address assert_equal @user.email_address, id.destination @@ -14,18 +18,32 @@ class IdentityTest < ActiveSupport::TestCase end test "add alias" do - skip - @user.create_identity address: @alias + id = @user.build_identity address: alias_name + assert_equal LocalEmail.new(alias_name), id.address + assert_equal @user.email_address, id.destination + assert_equal @user, id.user end test "add forward" do - skip - @user.create_identity destination: @external + id = @user.build_identity destination: forward_address + assert_equal @user.email_address, id.address + assert_equal Email.new(forward_address), id.destination + assert_equal @user, id.user end test "forward alias" do - skip - @user.create_identity address: @alias, destination: @external + id = @user.build_identity address: alias_name, destination: forward_address + assert_equal LocalEmail.new(alias_name), id.address + assert_equal Email.new(forward_address), id.destination + assert_equal @user, id.user + id.save end + def alias_name + @alias_name ||= Faker::Internet.user_name + end + + def forward_address + @forward_address ||= Faker::Internet.email + end end |