diff options
author | Azul <azul@riseup.net> | 2016-10-20 14:39:33 +0200 |
---|---|---|
committer | Azul <azul@riseup.net> | 2016-10-20 14:39:33 +0200 |
commit | b97daaed9b513006ace7e8eb5232a2211e965e77 (patch) | |
tree | e27002e8368e92410e5d4af2a945260c2ea6e2d1 /test/unit/temporary_user_test.rb | |
parent | c6c4d9fd10b8ca8e24889112727e44c9bf68dd60 (diff) | |
parent | 6eb2dae802e5453e2a4361ab28f614cce9294f4c (diff) |
Merge remote-tracking branch 'origin/develop'
We'll only use the master branch for development from now on.
Diffstat (limited to 'test/unit/temporary_user_test.rb')
-rw-r--r-- | test/unit/temporary_user_test.rb | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/test/unit/temporary_user_test.rb b/test/unit/temporary_user_test.rb new file mode 100644 index 0000000..2c9e70f --- /dev/null +++ b/test/unit/temporary_user_test.rb @@ -0,0 +1,53 @@ +require 'test_helper' + +class TemporaryUserTest < ActiveSupport::TestCase + + setup do + InviteCodeValidator.any_instance.stubs(:validate) + end + + test "TemporaryUser concern is applied" do + assert User.ancestors.include?(TemporaryUser) + end + + test "temporary user has tmp_users as db" do + tmp_user = User.new :login => 'tmp_user_'+SecureRandom.hex(5).downcase + assert_equal 'leap_web_tmp_users', tmp_user.database.name + end + + test "normal user has users as db" do + user = User.new :login => 'a'+SecureRandom.hex(5).downcase + assert_equal 'leap_web_users', user.database.name + end + + test "user saved to users" do + begin + assert_difference('User.database.info["doc_count"]') do + normal_user = User.create!(:login => 'a'+SecureRandom.hex(5).downcase, + :password_verifier => 'ABCDEF0010101', :password_salt => 'ABCDEF') + refute normal_user.database.to_s.include?('tmp') + end + ensure + begin + normal_user.destroy + rescue + end + end + end + + test "tmp_user saved to tmp_users" do + begin + assert_difference('User.tmp_database.info["doc_count"]') do + tmp_user = User.create!(:login => 'tmp_user_'+SecureRandom.hex(5).downcase, + :password_verifier => 'ABCDEF0010101', :password_salt => 'ABCDEF') + assert tmp_user.database.to_s.include?('tmp') + end + ensure + begin + tmp_user.destroy + rescue + end + end + end + +end |