Add status traits to user factory.
authorAndy Allan <git@gravitystorm.co.uk>
Thu, 2 Feb 2017 12:55:32 +0000 (12:55 +0000)
committerAndy Allan <git@gravitystorm.co.uk>
Thu, 2 Feb 2017 12:55:32 +0000 (12:55 +0000)
test/factories/user.rb
test/models/user_test.rb

index 6376659ab0b9ec76c696f156cbe1cb0fa0bb7d75..9ec4e20306a966b4e52bfd29efc978ef8064bd9b 100644 (file)
@@ -9,6 +9,26 @@ FactoryGirl.define do
       home_lon { rand(-180.0...180.0) }
     end
 
+    trait :pending do
+      status "pending"
+    end
+
+    trait :active do
+      status "active"
+    end
+
+    trait :confirmed do
+      status "confirmed"
+    end
+
+    trait :suspended do
+      status "suspended"
+    end
+
+    trait :deleted do
+      status "deleted"
+    end
+
     factory :moderator_user do
       after(:create) do |user, _evaluator|
         create(:user_role, :role => "moderator", :user => user)
index 6632702e59518867c8e8af1049fa7ca43e8d4276..356f469c0c7314a25a2056c4fc397fe908ca28e6 100644 (file)
@@ -207,19 +207,19 @@ class UserTest < ActiveSupport::TestCase
   end
 
   def test_visible?
-    assert_equal true, users(:inactive_user).visible?
-    assert_equal true, users(:normal_user).visible?
-    assert_equal true, users(:confirmed_user).visible?
-    assert_equal false, users(:suspended_user).visible?
-    assert_equal false, users(:deleted_user).visible?
+    assert_equal true, build(:user, :pending).visible?
+    assert_equal true, build(:user, :active).visible?
+    assert_equal true, build(:user, :confirmed).visible?
+    assert_equal false, build(:user, :suspended).visible?
+    assert_equal false, build(:user, :deleted).visible?
   end
 
   def test_active?
-    assert_equal false, users(:inactive_user).active?
-    assert_equal true, users(:normal_user).active?
-    assert_equal true, users(:confirmed_user).active?
-    assert_equal false, users(:suspended_user).active?
-    assert_equal false, users(:deleted_user).active?
+    assert_equal false, build(:user, :pending).active?
+    assert_equal true, build(:user, :active).active?
+    assert_equal true, build(:user, :confirmed).active?
+    assert_equal false, build(:user, :suspended).active?
+    assert_equal false, build(:user, :deleted).active?
   end
 
   def test_moderator?