Commit 6451452da486563d7503582584ebb86e0d189764
1 parent
3a035835
Exists in
master
and in
29 other branches
Writing more tests for User#data_hash
(ActionItem1608)
Showing
1 changed file
with
13 additions
and
2 deletions
Show diff stats
test/unit/user_test.rb
@@ -314,7 +314,7 @@ class UserTest < Test::Unit::TestCase | @@ -314,7 +314,7 @@ class UserTest < Test::Unit::TestCase | ||
314 | 314 | ||
315 | should "data_hash method have the following keys" do | 315 | should "data_hash method have the following keys" do |
316 | person = create_user('coldplay').person | 316 | person = create_user('coldplay').person |
317 | - expected_keys = ['login','is_admin','since_month', 'since_year', 'email_domain','friends_list','amount_of_friends'] | 317 | + expected_keys = ['login','is_admin','since_month', 'since_year', 'email_domain','friends_list','amount_of_friends', 'enterprises'] |
318 | assert_equal [], expected_keys - person.user.data_hash.keys | 318 | assert_equal [], expected_keys - person.user.data_hash.keys |
319 | assert_equal [], person.user.data_hash.keys - expected_keys | 319 | assert_equal [], person.user.data_hash.keys - expected_keys |
320 | end | 320 | end |
@@ -334,7 +334,7 @@ class UserTest < Test::Unit::TestCase | @@ -334,7 +334,7 @@ class UserTest < Test::Unit::TestCase | ||
334 | Person.any_instance.stubs(:created_at).returns(DateTime.parse('16-08-2010')) | 334 | Person.any_instance.stubs(:created_at).returns(DateTime.parse('16-08-2010')) |
335 | expected_hash = { | 335 | expected_hash = { |
336 | 'login' => 'x_and_y', 'is_admin' => true, 'since_month' => 8, 'since_year' => 2010, 'email_domain' => nil, 'amount_of_friends' => 0, | 336 | 'login' => 'x_and_y', 'is_admin' => true, 'since_month' => 8, 'since_year' => 2010, 'email_domain' => nil, 'amount_of_friends' => 0, |
337 | - 'friends_list' => {} | 337 | + 'friends_list' => {}, 'enterprises' => [], |
338 | } | 338 | } |
339 | assert_equal expected_hash, person.user.data_hash | 339 | assert_equal expected_hash, person.user.data_hash |
340 | end | 340 | end |
@@ -382,6 +382,17 @@ class UserTest < Test::Unit::TestCase | @@ -382,6 +382,17 @@ class UserTest < Test::Unit::TestCase | ||
382 | assert_equal 'chat', person.user.data_hash['friends_list'][friend.identifier]['status'] | 382 | assert_equal 'chat', person.user.data_hash['friends_list'][friend.identifier]['status'] |
383 | end | 383 | end |
384 | 384 | ||
385 | + should 'return empty list of enterprises on data_hash for newly created user' do | ||
386 | + assert_equal [], create_user('testuser').data_hash['enterprises'] | ||
387 | + end | ||
388 | + | ||
389 | + should 'return list of enterprises in data_hash' do | ||
390 | + user = create_user('testuser') | ||
391 | + enterprise = fast_create(Enterprise, :name => "My enterprise", :identifier => 'my-enterprise') | ||
392 | + user.person.expects(:enterprises).returns([enterprise]) | ||
393 | + assert_includes user.data_hash['enterprises'], {'name' => 'My enterprise', 'identifier' => 'my-enterprise'} | ||
394 | + end | ||
395 | + | ||
385 | should 'update chat status every 15 minutes' do | 396 | should 'update chat status every 15 minutes' do |
386 | assert_equal 15, User.expires_chat_status_every | 397 | assert_equal 15, User.expires_chat_status_every |
387 | end | 398 | end |