summaryrefslogtreecommitdiff
path: root/test/unit/phone_test.rb
diff options
context:
space:
mode:
authorStefan Wintermeyer <stefan.wintermeyer@amooma.de>2012-12-17 12:01:45 +0100
committerStefan Wintermeyer <stefan.wintermeyer@amooma.de>2012-12-17 12:01:45 +0100
commitb80bd744ad873f6fc43018bc4bfb90677de167bd (patch)
tree072c4b0e33d442528555b82c415f5e7a1712b2b0 /test/unit/phone_test.rb
parent3e706c2025ecc5523e81ad649639ef2ff75e7bac (diff)
Start of GS5.
Diffstat (limited to 'test/unit/phone_test.rb')
-rw-r--r--test/unit/phone_test.rb49
1 files changed, 49 insertions, 0 deletions
diff --git a/test/unit/phone_test.rb b/test/unit/phone_test.rb
new file mode 100644
index 0000000..4ad21df
--- /dev/null
+++ b/test/unit/phone_test.rb
@@ -0,0 +1,49 @@
+require 'test_helper'
+
+class PhoneTest < ActiveSupport::TestCase
+
+ def test_should_have_a_valid_factory
+ assert Factory.build(:phone).valid?
+ end
+
+ # test "should destroy_all phones_sip_accounts if the phoneable changed" do
+ # sip_domain = Factory.create(:sip_domain)
+ # tenant = sip_domain.tenants.create(Factory.build(:tenant).attributes)
+ #
+ # user1 = Factory.create(:user)
+ # user2 = Factory.create(:user)
+ # tenant.tenant_memberships.create(:user_id => user1.id)
+ # tenant.tenant_memberships.create(:user_id => user2.id)
+ #
+ # phone = Factory.create(:phone, :phoneable => tenant)
+ #
+ # # Nothing there
+ # #
+ # assert_equal 0, phone.sip_accounts.count
+ #
+ # # move the phone to user1
+ # #
+ # phone.phoneable = user1
+ # phone.save
+ #
+ # # create some sip_accounts associated to phone
+ # #
+ # 3.times { Factory.create(:sip_account, :sip_accountable => user1, :tenant_id => tenant.id) }
+ # SipAccount.all.each do |sip_account|
+ # phone.phones_sip_accounts.create(:sip_account_id => sip_account.id)
+ # end
+ #
+ # # Should have 3 sip_accounts
+ # #
+ # assert_equal 3, phone.sip_accounts.count
+ #
+ # # Move to user2
+ # phone.phoneable = user2
+ # phone.save
+ #
+ # # Should have 0 sip_accounts
+ # #
+ # assert_equal 0, phone.sip_accounts.count
+ # end
+
+end