summaryrefslogtreecommitdiff
path: root/users/test
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2013-07-18 12:12:07 +0200
committerAzul <azul@leap.se>2013-07-24 10:55:50 +0200
commitcc96c60c4617c09379d5e1ddbefa42407329c19a (patch)
tree1f51c6a1c76ca283c9ddafe6b5d940fe2fe29ea4 /users/test
parent4a071ef1b33525fa2d1052aa7f21b549447fe767 (diff)
testing all versions of emial identities, emails are now strings
Diffstat (limited to 'users/test')
-rw-r--r--users/test/unit/identity_test.rb32
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