summaryrefslogtreecommitdiff
path: root/test/unit/phone_book_entry_test.rb
diff options
context:
space:
mode:
authorStefan Wintermeyer <stefan.wintermeyer@amooma.de>2012-12-17 12:05:14 +0100
committerStefan Wintermeyer <stefan.wintermeyer@amooma.de>2012-12-17 12:05:14 +0100
commiteaad37485fe59d0306c37cc038dda6d210052910 (patch)
tree072c4b0e33d442528555b82c415f5e7a1712b2b0 /test/unit/phone_book_entry_test.rb
parent3e706c2025ecc5523e81ad649639ef2ff75e7bac (diff)
parentb80bd744ad873f6fc43018bc4bfb90677de167bd (diff)
Merge branch 'develop'
Diffstat (limited to 'test/unit/phone_book_entry_test.rb')
-rw-r--r--test/unit/phone_book_entry_test.rb51
1 files changed, 51 insertions, 0 deletions
diff --git a/test/unit/phone_book_entry_test.rb b/test/unit/phone_book_entry_test.rb
new file mode 100644
index 0000000..c8d639b
--- /dev/null
+++ b/test/unit/phone_book_entry_test.rb
@@ -0,0 +1,51 @@
+require 'test_helper'
+
+class PhoneBookEntryTest < ActiveSupport::TestCase
+ def test_should_be_valid
+ assert Factory.build(:phone_book_entry).valid?
+ end
+
+ # TODO Fix this test.
+
+ # test "only user can read entries in private phone books" do
+ # user = Factory.create(:user)
+ # phone_book = Factory.create(:phone_book, :phone_bookable_type => 'User', :phone_bookable_id => user.id)
+ # phone_book_entry = Factory.create(:phone_book_entry, :phone_book_id => phone_book.id)
+
+ # evil_user = Factory.create(:user)
+
+ # user_ability = Ability.new( user )
+ # evil_user_ability = Ability.new( evil_user )
+
+ # [ :show, :index ].each { |action|
+ # assert user_ability.can? action, phone_book_entry
+ # assert evil_user_ability.cannot? action, phone_book_entry
+ # }
+ # end
+
+ def test_that_the_initial_state_should_be_active
+ @phone_book_entry = Factory.create(:phone_book_entry)
+ assert_equal 'active', @phone_book_entry.state
+ assert @phone_book_entry.active?
+ end
+
+ test "a destroyed phone_book will destroy all phone_book_entries" do
+ phone_book = Factory.create(:phone_book)
+ 10.times { Factory.create(:phone_book_entry, :phone_book_id => phone_book.id) }
+
+ phone_book2 = Factory.create(:phone_book)
+ 5.times { Factory.create(:phone_book_entry, :phone_book_id => phone_book2.id) }
+
+ assert_equal 15, PhoneBookEntry.all.count
+
+ phone_book.destroy
+
+ assert_equal 5, PhoneBookEntry.all.count
+ end
+
+ test "that the value_of_to_s field is filled" do
+ phone_book_entry = Factory.create(:phone_book_entry)
+ assert_equal phone_book_entry.value_of_to_s, phone_book_entry.to_s
+ end
+
+end