summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/factories/api_rows.rb17
-rw-r--r--test/factories/area_codes.rb7
-rw-r--r--test/factories/call_forwards.rb16
-rw-r--r--test/factories/conference_invitees.rb8
-rw-r--r--test/factories/conferences.rb8
-rw-r--r--test/factories/countries.rb8
-rw-r--r--test/factories/gemeinschaft_setups.rb8
-rw-r--r--test/factories/gui_function_memberships.rb10
-rw-r--r--test/factories/languages.rb6
-rw-r--r--test/factories/manufacturers.rb6
-rw-r--r--test/factories/ouis.rb6
-rw-r--r--test/factories/phone_book_entries.rb7
-rw-r--r--test/factories/phone_books.rb6
-rw-r--r--test/factories/phone_models.rb6
-rw-r--r--test/factories/phone_number_ranges.rb6
-rw-r--r--test/factories/phone_numbers.rb7
-rw-r--r--test/factories/phones.rb15
-rw-r--r--test/factories/sip_accounts.rb17
-rw-r--r--test/factories/sip_domains.rb6
-rw-r--r--test/factories/softkey_functions.rb7
-rw-r--r--test/factories/tenant_memberships.rb6
-rw-r--r--test/factories/tenants.rb8
-rw-r--r--test/factories/user_group_memberships.rb14
-rw-r--r--test/factories/user_groups.rb6
-rw-r--r--test/factories/users.rb11
-rw-r--r--test/fixtures/.gitkeep0
-rw-r--r--test/functional/.gitkeep0
-rw-r--r--test/functional/access_authorizations_controller_test.rb49
-rw-r--r--test/functional/acd_agents_controller_test.rb49
-rw-r--r--test/functional/acd_callers_controller_test.rb49
-rw-r--r--test/functional/addresses_controller_test.rb49
-rw-r--r--test/functional/api/rows_controller_test.rb49
-rw-r--r--test/functional/automatic_call_distributors_controller_test.rb49
-rw-r--r--test/functional/call_forwards_controller_test.rb91
-rw-r--r--test/functional/callthroughs_controller_test.rb49
-rw-r--r--test/functional/conference_invitees_controller_test.rb49
-rw-r--r--test/functional/conferences_controller_test.rb49
-rw-r--r--test/functional/config_siemens_controller_test.rb7
-rw-r--r--test/functional/fax_accounts_controller_test.rb49
-rw-r--r--test/functional/fax_documents_controller_test.rb49
-rw-r--r--test/functional/gemeinschaft_setups_controller_test.rb50
-rw-r--r--test/functional/gs_cluster_sync_log_entries_controller_test.rb49
-rw-r--r--test/functional/gs_nodes_controller_test.rb49
-rw-r--r--test/functional/gui_functions_controller_test.rb49
-rw-r--r--test/functional/hunt_group_members_controller_test.rb49
-rw-r--r--test/functional/hunt_groups_controller_test.rb49
-rw-r--r--test/functional/manufacturers_controller_test.rb77
-rw-r--r--test/functional/notifications_test.rb12
-rw-r--r--test/functional/page_controller_test.rb35
-rw-r--r--test/functional/phone_book_entries_controller_test.rb103
-rw-r--r--test/functional/phone_books_controller_test.rb71
-rw-r--r--test/functional/phone_models_controller_test.rb143
-rw-r--r--test/functional/phone_number_ranges_controller_test.rb78
-rw-r--r--test/functional/phone_numbers_controller_test.rb115
-rw-r--r--test/functional/phone_sip_accounts_controller_test.rb49
-rw-r--r--test/functional/phones_controller_test.rb55
-rw-r--r--test/functional/phones_sip_accounts_controller_test.rb49
-rw-r--r--test/functional/ringtones_controller_test.rb49
-rw-r--r--test/functional/sessions_controller_test.rb7
-rw-r--r--test/functional/sip_accounts_controller_test.rb76
-rw-r--r--test/functional/sip_domains_controller_test.rb49
-rw-r--r--test/functional/softkeys_controller_test.rb49
-rw-r--r--test/functional/system_messages_controller_test.rb49
-rw-r--r--test/functional/tenants_controller_test.rb51
-rw-r--r--test/functional/user_groups_controller_test.rb51
-rw-r--r--test/functional/users_controller_test.rb65
-rw-r--r--test/functional/whitelists_controller_test.rb49
-rw-r--r--test/integration/.gitkeep0
-rw-r--r--test/performance/browsing_test.rb12
-rw-r--r--test/test_helper.rb13
-rw-r--r--test/unit/.gitkeep0
-rw-r--r--test/unit/access_authorization_test.rb7
-rw-r--r--test/unit/acd_agent_test.rb7
-rw-r--r--test/unit/acd_caller_test.rb7
-rw-r--r--test/unit/address_test.rb7
-rw-r--r--test/unit/api/row_test.rb7
-rw-r--r--test/unit/area_code_test.rb7
-rw-r--r--test/unit/automatic_call_distributor_test.rb7
-rw-r--r--test/unit/call_forward_case_test.rb7
-rw-r--r--test/unit/call_forward_test.rb9
-rw-r--r--test/unit/callthrough_test.rb134
-rw-r--r--test/unit/conference_invitee_test.rb17
-rw-r--r--test/unit/conference_test.rb48
-rw-r--r--test/unit/country_test.rb7
-rw-r--r--test/unit/dial_in_number_store_test.rb7
-rw-r--r--test/unit/fax_account_test.rb7
-rw-r--r--test/unit/fax_document_test.rb7
-rw-r--r--test/unit/fax_page_test.rb7
-rw-r--r--test/unit/fax_resolution_test.rb7
-rw-r--r--test/unit/fax_thumbnail_test.rb7
-rw-r--r--test/unit/gemeinschaft_setup_test.rb7
-rw-r--r--test/unit/gs_cluster_sync_log_entry_test.rb7
-rw-r--r--test/unit/gs_node_test.rb7
-rw-r--r--test/unit/gui_function_membership_test.rb7
-rw-r--r--test/unit/gui_function_test.rb7
-rw-r--r--test/unit/helpers/api/rows_helper_test.rb4
-rw-r--r--test/unit/helpers/config_siemens_helper_test.rb4
-rw-r--r--test/unit/helpers/page_helper_test.rb4
-rw-r--r--test/unit/helpers/sessions_helper_test.rb4
-rw-r--r--test/unit/hunt_group_member_test.rb7
-rw-r--r--test/unit/hunt_group_test.rb7
-rw-r--r--test/unit/language_test.rb7
-rw-r--r--test/unit/manufacturer_test.rb27
-rw-r--r--test/unit/oui_test.rb14
-rw-r--r--test/unit/phone_book_entry_test.rb51
-rw-r--r--test/unit/phone_book_test.rb119
-rw-r--r--test/unit/phone_model_test.rb9
-rw-r--r--test/unit/phone_number_range_test.rb9
-rw-r--r--test/unit/phone_number_test.rb260
-rw-r--r--test/unit/phone_sip_account_test.rb7
-rw-r--r--test/unit/phone_test.rb49
-rw-r--r--test/unit/ringtone_test.rb7
-rw-r--r--test/unit/sip_account_test.rb34
-rw-r--r--test/unit/sip_domain_test.rb9
-rw-r--r--test/unit/softkey_function_test.rb7
-rw-r--r--test/unit/softkey_test.rb7
-rw-r--r--test/unit/system_message_test.rb7
-rw-r--r--test/unit/tenant_membership_test.rb14
-rw-r--r--test/unit/tenant_test.rb33
-rw-r--r--test/unit/user_group_membership_test.rb39
-rw-r--r--test/unit/user_group_test.rb38
-rw-r--r--test/unit/user_test.rb82
-rw-r--r--test/unit/whitelist_test.rb7
123 files changed, 3675 insertions, 0 deletions
diff --git a/test/factories/api_rows.rb b/test/factories/api_rows.rb
new file mode 100644
index 0000000..42428ae
--- /dev/null
+++ b/test/factories/api_rows.rb
@@ -0,0 +1,17 @@
+# Read about factories at http://github.com/thoughtbot/factory_girl
+
+FactoryGirl.define do
+ factory :row do
+ user_name "MyString"
+ last_name "MyString"
+ middle_name "MyString"
+ first_name "MyString"
+ office_phone_number "MyString"
+ internal_extension "MyString"
+ mobile_phone_number "MyString"
+ fax_phone_number "MyString"
+ email "MyString"
+ pin "MyString"
+ photo_file_name "MyString"
+ end
+end
diff --git a/test/factories/area_codes.rb b/test/factories/area_codes.rb
new file mode 100644
index 0000000..87b2271
--- /dev/null
+++ b/test/factories/area_codes.rb
@@ -0,0 +1,7 @@
+# Read about factories at http://github.com/thoughtbot/factory_girl
+
+Factory.define :area_code do |f|
+ f.sequence(:name) { |n| "AreaCode #{n}" }
+ f.sequence(:area_code) { |n| "#{n}" }
+ f.association :country
+end \ No newline at end of file
diff --git a/test/factories/call_forwards.rb b/test/factories/call_forwards.rb
new file mode 100644
index 0000000..d275e9d
--- /dev/null
+++ b/test/factories/call_forwards.rb
@@ -0,0 +1,16 @@
+# Read about factories at http://github.com/thoughtbot/factory_girl
+
+Factory.define :call_forward do |f|
+ f.association :phone_number
+ #OPTIMIZE Make sure that the phone_number's phone_numberable
+ # isn't a phone_book_entry but a sip_account.
+ #f.sequence( :call_forward_case_id ) { |n| CallForwardCase.where(:value => "always").first.id }
+ #f.association :call_forward_case
+ f.sequence( :call_forward_case_id ) { |n| 1 }
+ f.sequence( :destination ) { |n| "20#{n}" }
+ f.sequence( :to_voicemail ) { |n| false }
+ f.sequence( :timeout ) { |n| nil }
+ f.sequence( :source ) { |n| nil }
+ f.sequence( :depth ) { |n| 5 }
+ f.sequence( :active ) { |n| false }
+end
diff --git a/test/factories/conference_invitees.rb b/test/factories/conference_invitees.rb
new file mode 100644
index 0000000..4e1eb68
--- /dev/null
+++ b/test/factories/conference_invitees.rb
@@ -0,0 +1,8 @@
+# Read about factories at http://github.com/thoughtbot/factory_girl
+
+Factory.define :conference_invitee do |f|
+ f.phone_number { Factory.build(:phone_number) }
+ f.association :conference
+ f.speaker true
+ f.moderator false
+end \ No newline at end of file
diff --git a/test/factories/conferences.rb b/test/factories/conferences.rb
new file mode 100644
index 0000000..3c49a7a
--- /dev/null
+++ b/test/factories/conferences.rb
@@ -0,0 +1,8 @@
+# Read about factories at http://github.com/thoughtbot/factory_girl
+
+Factory.define :conference do |f|
+ f.sequence(:name) { |n| "Conference room #{n}" }
+ f.open_for_anybody true
+ f.association :conferenceable, :factory => :tenant
+ f.max_members 10
+end \ No newline at end of file
diff --git a/test/factories/countries.rb b/test/factories/countries.rb
new file mode 100644
index 0000000..cc3fc88
--- /dev/null
+++ b/test/factories/countries.rb
@@ -0,0 +1,8 @@
+# Read about factories at http://github.com/thoughtbot/factory_girl
+
+Factory.define :country do |f|
+ f.sequence(:name) { |n| "Country #{n}" }
+ f.sequence(:country_code) { |n| "#{n}" }
+ f.sequence(:international_call_prefix) { |n| "#{n}" }
+ f.sequence(:trunk_prefix) { |n| "#{n}" }
+end \ No newline at end of file
diff --git a/test/factories/gemeinschaft_setups.rb b/test/factories/gemeinschaft_setups.rb
new file mode 100644
index 0000000..ed69bc3
--- /dev/null
+++ b/test/factories/gemeinschaft_setups.rb
@@ -0,0 +1,8 @@
+# Read about factories at http://github.com/thoughtbot/factory_girl
+
+Factory.define :gemeinschaft_setup do |f|
+ f.association :user
+ f.association :sip_domain
+ f.association :country
+ f.association :language
+end \ No newline at end of file
diff --git a/test/factories/gui_function_memberships.rb b/test/factories/gui_function_memberships.rb
new file mode 100644
index 0000000..c6f6d4a
--- /dev/null
+++ b/test/factories/gui_function_memberships.rb
@@ -0,0 +1,10 @@
+# Read about factories at https://github.com/thoughtbot/factory_girl
+
+FactoryGirl.define do
+ factory :gui_function_membership do
+ gui_function_id 1
+ user_group_id 1
+ activated false
+ output "MyString"
+ end
+end
diff --git a/test/factories/languages.rb b/test/factories/languages.rb
new file mode 100644
index 0000000..29d2ece
--- /dev/null
+++ b/test/factories/languages.rb
@@ -0,0 +1,6 @@
+# Read about factories at http://github.com/thoughtbot/factory_girl
+
+Factory.define :language do |f|
+ f.name 'Deutsch'
+ f.code 'de'
+end \ No newline at end of file
diff --git a/test/factories/manufacturers.rb b/test/factories/manufacturers.rb
new file mode 100644
index 0000000..f091dd2
--- /dev/null
+++ b/test/factories/manufacturers.rb
@@ -0,0 +1,6 @@
+# Read about factories at http://github.com/thoughtbot/factory_girl
+
+Factory.define :manufacturer do |f|
+ f.sequence(:name) { |n| "#{n}. manufacturer" }
+ f.sequence(:ieee_name) { |n| "#{n}. ieee" }
+end \ No newline at end of file
diff --git a/test/factories/ouis.rb b/test/factories/ouis.rb
new file mode 100644
index 0000000..3a90fd4
--- /dev/null
+++ b/test/factories/ouis.rb
@@ -0,0 +1,6 @@
+# Read about factories at http://github.com/thoughtbot/factory_girl
+
+Factory.define :oui do |f|
+ f.association :manufacturer
+ f.sequence(:value) { |n| (n + 11184810).to_s(16).upcase }
+end \ No newline at end of file
diff --git a/test/factories/phone_book_entries.rb b/test/factories/phone_book_entries.rb
new file mode 100644
index 0000000..7427886
--- /dev/null
+++ b/test/factories/phone_book_entries.rb
@@ -0,0 +1,7 @@
+# Read about factories at http://github.com/thoughtbot/factory_girl
+
+Factory.define :phone_book_entry do |f|
+ f.sequence(:last_name) { |n| "Lastname #{n}" }
+ f.sequence(:is_male) { |n| true }
+ f.association :phone_book
+end
diff --git a/test/factories/phone_books.rb b/test/factories/phone_books.rb
new file mode 100644
index 0000000..4aa8d07
--- /dev/null
+++ b/test/factories/phone_books.rb
@@ -0,0 +1,6 @@
+# Read about factories at http://github.com/thoughtbot/factory_girl
+
+Factory.define :phone_book do |f|
+ f.sequence(:name) { |n| "Phone book #{n}" }
+ f.association :phone_bookable, :factory => :user
+end
diff --git a/test/factories/phone_models.rb b/test/factories/phone_models.rb
new file mode 100644
index 0000000..8e6a50f
--- /dev/null
+++ b/test/factories/phone_models.rb
@@ -0,0 +1,6 @@
+# Read about factories at http://github.com/thoughtbot/factory_girl
+
+Factory.define :phone_model do |f|
+ f.sequence(:name) { |n| "Phone Model #{n}" }
+ f.association :manufacturer
+end
diff --git a/test/factories/phone_number_ranges.rb b/test/factories/phone_number_ranges.rb
new file mode 100644
index 0000000..cb2f7ee
--- /dev/null
+++ b/test/factories/phone_number_ranges.rb
@@ -0,0 +1,6 @@
+# Read about factories at http://github.com/thoughtbot/factory_girl
+
+Factory.define :phone_number_range do |f|
+ f.name INTERNAL_EXTENSIONS
+ f.association :phone_number_rangeable, :factory => :tenant
+end
diff --git a/test/factories/phone_numbers.rb b/test/factories/phone_numbers.rb
new file mode 100644
index 0000000..74b43cc
--- /dev/null
+++ b/test/factories/phone_numbers.rb
@@ -0,0 +1,7 @@
+# Read about factories at http://github.com/thoughtbot/factory_girl
+
+Factory.define :phone_number do |f|
+ f.sequence(:name) { |n| "Name #{n}" }
+ f.sequence(:number) { |n| "(0)30 227 #{n}" }
+ f.association :phone_numberable, :factory => :phone_book_entry
+end \ No newline at end of file
diff --git a/test/factories/phones.rb b/test/factories/phones.rb
new file mode 100644
index 0000000..646d548
--- /dev/null
+++ b/test/factories/phones.rb
@@ -0,0 +1,15 @@
+# Read about factories at http://github.com/thoughtbot/factory_girl
+
+Factory.define :phone do |f|
+ f.sequence(:mac_address) { |n| ('%06d' % n).to_s + ('%06d' % n).to_s }
+ f.association :phone_model
+ f.association :phoneable, :factory => :tenant
+
+ # We have to make sure that the OUI is created as well.
+ f.after_build do |instance|
+ Factory.create(:oui,
+ :manufacturer => instance.phone_model.manufacturer,
+ :value => instance.mac_address.slice(0, 6)
+ )
+ end
+end \ No newline at end of file
diff --git a/test/factories/sip_accounts.rb b/test/factories/sip_accounts.rb
new file mode 100644
index 0000000..2f91717
--- /dev/null
+++ b/test/factories/sip_accounts.rb
@@ -0,0 +1,17 @@
+# Read about factories at http://github.com/thoughtbot/factory_girl
+
+Factory.define :sip_account do |f|
+ f.association :sip_accountable, :factory => :user
+ f.sequence(:auth_name) {|n| "auth_name#{n}" }
+ f.sequence(:caller_name) {|n| "Foo Account #{n}" }
+ f.sequence(:password) {|n| "12345678" }
+
+ f.after_build do |sip_account|
+ if sip_account.tenant_id.blank?
+ tenant = sip_account.create_tenant(FactoryGirl.build(:tenant).attributes)
+ sip_domain = tenant.create_sip_domain(FactoryGirl.build(:sip_domain).attributes)
+ sip_account.tenant.tenant_memberships.create(:user_id => sip_account.sip_accountable.id)
+ sip_account.tenant_id = tenant.id
+ end
+ end
+end
diff --git a/test/factories/sip_domains.rb b/test/factories/sip_domains.rb
new file mode 100644
index 0000000..347b6a6
--- /dev/null
+++ b/test/factories/sip_domains.rb
@@ -0,0 +1,6 @@
+# Read about factories at http://github.com/thoughtbot/factory_girl
+
+Factory.define :sip_domain do |f|
+ f.sequence(:host ) {|n| "host#{n}.localdomain" }
+ f.sequence(:realm ) {|n| "host#{n}.localdomain" }
+end
diff --git a/test/factories/softkey_functions.rb b/test/factories/softkey_functions.rb
new file mode 100644
index 0000000..6af7cac
--- /dev/null
+++ b/test/factories/softkey_functions.rb
@@ -0,0 +1,7 @@
+# Read about factories at http://github.com/thoughtbot/factory_girl
+
+FactoryGirl.define do
+ factory :softkey_function do
+ name "MyString"
+ end
+end
diff --git a/test/factories/tenant_memberships.rb b/test/factories/tenant_memberships.rb
new file mode 100644
index 0000000..ee52367
--- /dev/null
+++ b/test/factories/tenant_memberships.rb
@@ -0,0 +1,6 @@
+# Read about factories at http://github.com/thoughtbot/factory_girl
+
+Factory.define :tenant_membership do |f|
+ f.association :user
+ f.association :tenant
+end \ No newline at end of file
diff --git a/test/factories/tenants.rb b/test/factories/tenants.rb
new file mode 100644
index 0000000..9a62e93
--- /dev/null
+++ b/test/factories/tenants.rb
@@ -0,0 +1,8 @@
+# Read about factories at http://github.com/thoughtbot/factory_girl
+
+Factory.define :tenant do |f|
+ f.sequence(:name) { |n| "Tenant #{n}" }
+ f.association :country
+ f.association :language
+# f.association :sip_domain
+end
diff --git a/test/factories/user_group_memberships.rb b/test/factories/user_group_memberships.rb
new file mode 100644
index 0000000..7904f2f
--- /dev/null
+++ b/test/factories/user_group_memberships.rb
@@ -0,0 +1,14 @@
+# Read about factories at http://github.com/thoughtbot/factory_girl
+
+Factory.define :user_group_membership do |f|
+ f.association :user_group
+ f.association :user
+
+ # Make sure that the User is a member of the Tenant.
+ f.after_build do |instance|
+ Factory.create(:tenant_membership,
+ :tenant_id => instance.user_group.tenant.id,
+ :user_id => instance.user.id
+ )
+ end
+end \ No newline at end of file
diff --git a/test/factories/user_groups.rb b/test/factories/user_groups.rb
new file mode 100644
index 0000000..9a448ec
--- /dev/null
+++ b/test/factories/user_groups.rb
@@ -0,0 +1,6 @@
+# Read about factories at http://github.com/thoughtbot/factory_girl
+
+Factory.define :user_group do |f|
+ f.sequence(:name) { |n| "UserGroup #{n}" }
+ f.association :tenant
+end \ No newline at end of file
diff --git a/test/factories/users.rb b/test/factories/users.rb
new file mode 100644
index 0000000..3d53141
--- /dev/null
+++ b/test/factories/users.rb
@@ -0,0 +1,11 @@
+# Read about factories at http://github.com/thoughtbot/factory_girl
+
+Factory.define :user do |f|
+ f.sequence(:user_name) { |n| "User #{n}" }
+ f.sequence(:first_name) { |n| "John #{n}" }
+ f.sequence(:last_name) { |n| "Smith #{n}" }
+ f.sequence(:email) { |n| "john.smith#{n}@company.com" }
+ f.sequence(:password) { |n| "Testpassword#{n}" }
+ f.sequence(:password_confirmation) { |n| "Testpassword#{n}" }
+ f.association :language
+end \ No newline at end of file
diff --git a/test/fixtures/.gitkeep b/test/fixtures/.gitkeep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/fixtures/.gitkeep
diff --git a/test/functional/.gitkeep b/test/functional/.gitkeep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/functional/.gitkeep
diff --git a/test/functional/access_authorizations_controller_test.rb b/test/functional/access_authorizations_controller_test.rb
new file mode 100644
index 0000000..98761fd
--- /dev/null
+++ b/test/functional/access_authorizations_controller_test.rb
@@ -0,0 +1,49 @@
+require 'test_helper'
+
+class AccessAuthorizationsControllerTest < ActionController::TestCase
+ setup do
+ @access_authorization = access_authorizations(:one)
+ end
+
+ test "should get index" do
+ get :index
+ assert_response :success
+ assert_not_nil assigns(:access_authorizations)
+ end
+
+ test "should get new" do
+ get :new
+ assert_response :success
+ end
+
+ test "should create access_authorization" do
+ assert_difference('AccessAuthorization.count') do
+ post :create, access_authorization: @access_authorization.attributes
+ end
+
+ assert_redirected_to access_authorization_path(assigns(:access_authorization))
+ end
+
+ test "should show access_authorization" do
+ get :show, id: @access_authorization.to_param
+ assert_response :success
+ end
+
+ test "should get edit" do
+ get :edit, id: @access_authorization.to_param
+ assert_response :success
+ end
+
+ test "should update access_authorization" do
+ put :update, id: @access_authorization.to_param, access_authorization: @access_authorization.attributes
+ assert_redirected_to access_authorization_path(assigns(:access_authorization))
+ end
+
+ test "should destroy access_authorization" do
+ assert_difference('AccessAuthorization.count', -1) do
+ delete :destroy, id: @access_authorization.to_param
+ end
+
+ assert_redirected_to access_authorizations_path
+ end
+end
diff --git a/test/functional/acd_agents_controller_test.rb b/test/functional/acd_agents_controller_test.rb
new file mode 100644
index 0000000..11355eb
--- /dev/null
+++ b/test/functional/acd_agents_controller_test.rb
@@ -0,0 +1,49 @@
+require 'test_helper'
+
+class AcdAgentsControllerTest < ActionController::TestCase
+ setup do
+ @acd_agent = acd_agents(:one)
+ end
+
+ test "should get index" do
+ get :index
+ assert_response :success
+ assert_not_nil assigns(:acd_agents)
+ end
+
+ test "should get new" do
+ get :new
+ assert_response :success
+ end
+
+ test "should create acd_agent" do
+ assert_difference('AcdAgent.count') do
+ post :create, acd_agent: @acd_agent.attributes
+ end
+
+ assert_redirected_to acd_agent_path(assigns(:acd_agent))
+ end
+
+ test "should show acd_agent" do
+ get :show, id: @acd_agent.to_param
+ assert_response :success
+ end
+
+ test "should get edit" do
+ get :edit, id: @acd_agent.to_param
+ assert_response :success
+ end
+
+ test "should update acd_agent" do
+ put :update, id: @acd_agent.to_param, acd_agent: @acd_agent.attributes
+ assert_redirected_to acd_agent_path(assigns(:acd_agent))
+ end
+
+ test "should destroy acd_agent" do
+ assert_difference('AcdAgent.count', -1) do
+ delete :destroy, id: @acd_agent.to_param
+ end
+
+ assert_redirected_to acd_agents_path
+ end
+end
diff --git a/test/functional/acd_callers_controller_test.rb b/test/functional/acd_callers_controller_test.rb
new file mode 100644
index 0000000..960de7d
--- /dev/null
+++ b/test/functional/acd_callers_controller_test.rb
@@ -0,0 +1,49 @@
+require 'test_helper'
+
+class AcdCallersControllerTest < ActionController::TestCase
+ setup do
+ @acd_caller = acd_callers(:one)
+ end
+
+ test "should get index" do
+ get :index
+ assert_response :success
+ assert_not_nil assigns(:acd_callers)
+ end
+
+ test "should get new" do
+ get :new
+ assert_response :success
+ end
+
+ test "should create acd_caller" do
+ assert_difference('AcdCaller.count') do
+ post :create, acd_caller: @acd_caller.attributes
+ end
+
+ assert_redirected_to acd_caller_path(assigns(:acd_caller))
+ end
+
+ test "should show acd_caller" do
+ get :show, id: @acd_caller.to_param
+ assert_response :success
+ end
+
+ test "should get edit" do
+ get :edit, id: @acd_caller.to_param
+ assert_response :success
+ end
+
+ test "should update acd_caller" do
+ put :update, id: @acd_caller.to_param, acd_caller: @acd_caller.attributes
+ assert_redirected_to acd_caller_path(assigns(:acd_caller))
+ end
+
+ test "should destroy acd_caller" do
+ assert_difference('AcdCaller.count', -1) do
+ delete :destroy, id: @acd_caller.to_param
+ end
+
+ assert_redirected_to acd_callers_path
+ end
+end
diff --git a/test/functional/addresses_controller_test.rb b/test/functional/addresses_controller_test.rb
new file mode 100644
index 0000000..b1f5c83
--- /dev/null
+++ b/test/functional/addresses_controller_test.rb
@@ -0,0 +1,49 @@
+require 'test_helper'
+
+class AddressesControllerTest < ActionController::TestCase
+# setup do
+# @address = addresses(:one)
+# end
+#
+# test "should get index" do
+# get :index
+# assert_response :success
+# assert_not_nil assigns(:addresses)
+# end
+#
+# test "should get new" do
+# get :new
+# assert_response :success
+# end
+#
+# test "should create address" do
+# assert_difference('Address.count') do
+# post :create, address: @address.attributes
+# end
+#
+# assert_redirected_to address_path(assigns(:address))
+# end
+#
+# test "should show address" do
+# get :show, id: @address.to_param
+# assert_response :success
+# end
+#
+# test "should get edit" do
+# get :edit, id: @address.to_param
+# assert_response :success
+# end
+#
+# test "should update address" do
+# put :update, id: @address.to_param, address: @address.attributes
+# assert_redirected_to address_path(assigns(:address))
+# end
+#
+# test "should destroy address" do
+# assert_difference('Address.count', -1) do
+# delete :destroy, id: @address.to_param
+# end
+#
+# assert_redirected_to addresses_path
+# end
+end
diff --git a/test/functional/api/rows_controller_test.rb b/test/functional/api/rows_controller_test.rb
new file mode 100644
index 0000000..ca1926c
--- /dev/null
+++ b/test/functional/api/rows_controller_test.rb
@@ -0,0 +1,49 @@
+require 'test_helper'
+
+class Api::RowsControllerTest < ActionController::TestCase
+ setup do
+ @api_row = api_rows(:one)
+ end
+
+ test "should get index" do
+ get :index
+ assert_response :success
+ assert_not_nil assigns(:api_rows)
+ end
+
+ test "should get new" do
+ get :new
+ assert_response :success
+ end
+
+ test "should create api_row" do
+ assert_difference('Api::Row.count') do
+ post :create, api_row: @api_row.attributes
+ end
+
+ assert_redirected_to api_row_path(assigns(:api_row))
+ end
+
+ test "should show api_row" do
+ get :show, id: @api_row
+ assert_response :success
+ end
+
+ test "should get edit" do
+ get :edit, id: @api_row
+ assert_response :success
+ end
+
+ test "should update api_row" do
+ put :update, id: @api_row, api_row: @api_row.attributes
+ assert_redirected_to api_row_path(assigns(:api_row))
+ end
+
+ test "should destroy api_row" do
+ assert_difference('Api::Row.count', -1) do
+ delete :destroy, id: @api_row
+ end
+
+ assert_redirected_to api_rows_path
+ end
+end
diff --git a/test/functional/automatic_call_distributors_controller_test.rb b/test/functional/automatic_call_distributors_controller_test.rb
new file mode 100644
index 0000000..e8914fd
--- /dev/null
+++ b/test/functional/automatic_call_distributors_controller_test.rb
@@ -0,0 +1,49 @@
+require 'test_helper'
+
+class AutomaticCallDistributorsControllerTest < ActionController::TestCase
+ setup do
+ @automatic_call_distributor = automatic_call_distributors(:one)
+ end
+
+ test "should get index" do
+ get :index
+ assert_response :success
+ assert_not_nil assigns(:automatic_call_distributors)
+ end
+
+ test "should get new" do
+ get :new
+ assert_response :success
+ end
+
+ test "should create automatic_call_distributor" do
+ assert_difference('AutomaticCallDistributor.count') do
+ post :create, automatic_call_distributor: @automatic_call_distributor.attributes
+ end
+
+ assert_redirected_to automatic_call_distributor_path(assigns(:automatic_call_distributor))
+ end
+
+ test "should show automatic_call_distributor" do
+ get :show, id: @automatic_call_distributor.to_param
+ assert_response :success
+ end
+
+ test "should get edit" do
+ get :edit, id: @automatic_call_distributor.to_param
+ assert_response :success
+ end
+
+ test "should update automatic_call_distributor" do
+ put :update, id: @automatic_call_distributor.to_param, automatic_call_distributor: @automatic_call_distributor.attributes
+ assert_redirected_to automatic_call_distributor_path(assigns(:automatic_call_distributor))
+ end
+
+ test "should destroy automatic_call_distributor" do
+ assert_difference('AutomaticCallDistributor.count', -1) do
+ delete :destroy, id: @automatic_call_distributor.to_param
+ end
+
+ assert_redirected_to automatic_call_distributors_path
+ end
+end
diff --git a/test/functional/call_forwards_controller_test.rb b/test/functional/call_forwards_controller_test.rb
new file mode 100644
index 0000000..0993623
--- /dev/null
+++ b/test/functional/call_forwards_controller_test.rb
@@ -0,0 +1,91 @@
+require 'test_helper'
+
+class CallForwardsControllerTest < ActionController::TestCase
+
+ setup do
+ @user = Factory.create(:user)
+
+ #@tenant = Factory.create(:tenant)
+ #@tenant.tenant_memberships.create(:user_id => @user.id)
+ #@user.update_attributes!(:current_tenant_id => @tenant.id)
+
+ @sip_account = Factory.create(
+ :sip_account,
+ :sip_accountable => @user,
+ )
+ @user.sip_accounts << @sip_account
+ @sip_account = @user.sip_accounts.last
+
+ @phone_number = Factory.create(
+ :phone_number,
+ :phone_numberable => @sip_account,
+ )
+ @sip_account.phone_numbers << @phone_number
+ @phone_number = @sip_account.phone_numbers.last
+
+ @call_forward = Factory.create(
+ :call_forward,
+ :phone_number => @phone_number,
+ )
+ @phone_number.call_forwards << @call_forward
+ @call_forward = @phone_number.call_forwards.last
+ end
+
+ test "should get index" do
+ session[:user_id] = @user.id
+ get :index,
+ :phone_number_id => @phone_number.to_param
+ assert_response :success
+ assert_not_nil assigns(:call_forwards)
+ end
+
+ test "should get new" do
+ get :new,
+ :phone_number_id => @phone_number.to_param
+ assert_response :success
+ end
+
+ #TODO
+# test "should create call_forward" do
+# assert_difference('CallForward.count') do
+# post :create,
+# :phone_number_id => @phone_number.to_param,
+# :call_forward => Factory.attributes_for(
+# :call_forward
+# )
+# end
+# assert_redirected_to( phone_number_call_forward_path( @phone_number, @call_forward ) )
+# end
+
+ test "should show call_forward" do
+ session[:user_id] = @user.id
+ get :show,
+ :phone_number_id => @phone_number.to_param,
+ :id => @call_forward.to_param
+ assert_response :success
+ end
+
+ test "should get edit" do
+ get :edit,
+ :phone_number_id => @phone_number.to_param,
+ :id => @call_forward.to_param
+ assert_response :success
+ end
+
+ test "should update call_forward" do
+ put :update,
+ :phone_number_id => @phone_number.to_param,
+ :id => @call_forward.to_param, call_forward: @call_forward.attributes
+ assert_redirected_to( phone_number_call_forward_path( @phone_number, @call_forward ) )
+ end
+
+ test "should destroy call_forward" do
+ assert_difference('CallForward.count', -1) do
+ delete :destroy,
+ :phone_number_id => @phone_number.to_param,
+ :id => @call_forward.to_param
+ end
+ assert_redirected_to( phone_number_call_forwards_path( @phone_number ) )
+ end
+
+end
diff --git a/test/functional/callthroughs_controller_test.rb b/test/functional/callthroughs_controller_test.rb
new file mode 100644
index 0000000..330629c
--- /dev/null
+++ b/test/functional/callthroughs_controller_test.rb
@@ -0,0 +1,49 @@
+require 'test_helper'
+
+class CallthroughsControllerTest < ActionController::TestCase
+ setup do
+ @callthrough = callthroughs(:one)
+ end
+
+ test "should get index" do
+ get :index
+ assert_response :success
+ assert_not_nil assigns(:callthroughs)
+ end
+
+ test "should get new" do
+ get :new
+ assert_response :success
+ end
+
+ test "should create callthrough" do
+ assert_difference('Callthrough.count') do
+ post :create, callthrough: @callthrough.attributes
+ end
+
+ assert_redirected_to callthrough_path(assigns(:callthrough))
+ end
+
+ test "should show callthrough" do
+ get :show, id: @callthrough.to_param
+ assert_response :success
+ end
+
+ test "should get edit" do
+ get :edit, id: @callthrough.to_param
+ assert_response :success
+ end
+
+ test "should update callthrough" do
+ put :update, id: @callthrough.to_param, callthrough: @callthrough.attributes
+ assert_redirected_to callthrough_path(assigns(:callthrough))
+ end
+
+ test "should destroy callthrough" do
+ assert_difference('Callthrough.count', -1) do
+ delete :destroy, id: @callthrough.to_param
+ end
+
+ assert_redirected_to callthroughs_path
+ end
+end
diff --git a/test/functional/conference_invitees_controller_test.rb b/test/functional/conference_invitees_controller_test.rb
new file mode 100644
index 0000000..72d2e2c
--- /dev/null
+++ b/test/functional/conference_invitees_controller_test.rb
@@ -0,0 +1,49 @@
+require 'test_helper'
+
+class ConferenceInviteesControllerTest < ActionController::TestCase
+
+ setup do
+ @conference_invitee = Factory.create(:conference_invitee)
+ end
+
+# test "should get index" do
+# get :index
+# assert_response :success
+# assert_not_nil assigns(:conference_invitees)
+# end
+#
+# test "should get new" do
+# get :new
+# assert_response :success
+# end
+#
+# test "should create conference_invitee" do
+# assert_difference('ConferenceInvitee.count') do
+# post :create, conference_invitee: @conference_invitee.attributes
+# end
+# assert_redirected_to conference_invitee_path(assigns(:conference_invitee))
+# end
+#
+# test "should show conference_invitee" do
+# get :show, id: @conference_invitee.to_param
+# assert_response :success
+# end
+#
+# test "should get edit" do
+# get :edit, id: @conference_invitee.to_param
+# assert_response :success
+# end
+#
+# test "should update conference_invitee" do
+# put :update, id: @conference_invitee.to_param, conference_invitee: @conference_invitee.attributes
+# assert_redirected_to conference_invitee_path(assigns(:conference_invitee))
+# end
+#
+# test "should destroy conference_invitee" do
+# assert_difference('ConferenceInvitee.count', -1) do
+# delete :destroy, id: @conference_invitee.to_param
+# end
+# assert_redirected_to conference_invitees_path
+# end
+
+end
diff --git a/test/functional/conferences_controller_test.rb b/test/functional/conferences_controller_test.rb
new file mode 100644
index 0000000..954838b
--- /dev/null
+++ b/test/functional/conferences_controller_test.rb
@@ -0,0 +1,49 @@
+require 'test_helper'
+
+class ConferencesControllerTest < ActionController::TestCase
+
+ setup do
+ @conference = Factory.create(:conference)
+ end
+
+# test "should get index" do
+# get :index
+# assert_response :success
+# assert_not_nil assigns(:conferences)
+# end
+#
+# test "should get new" do
+# get :new
+# assert_response :success
+# end
+#
+# test "should create conference" do
+# assert_difference('Conference.count') do
+# post :create, conference: @conference.attributes
+# end
+# assert_redirected_to conference_path(assigns(:conference))
+# end
+#
+# test "should show conference" do
+# get :show, id: @conference.to_param
+# assert_response :success
+# end
+#
+# test "should get edit" do
+# get :edit, id: @conference.to_param
+# assert_response :success
+# end
+#
+# test "should update conference" do
+# put :update, id: @conference.to_param, conference: @conference.attributes
+# assert_redirected_to conference_path(assigns(:conference))
+# end
+#
+# test "should destroy conference" do
+# assert_difference('Conference.count', -1) do
+# delete :destroy, id: @conference.to_param
+# end
+# assert_redirected_to conferences_path
+# end
+
+end
diff --git a/test/functional/config_siemens_controller_test.rb b/test/functional/config_siemens_controller_test.rb
new file mode 100644
index 0000000..949f776
--- /dev/null
+++ b/test/functional/config_siemens_controller_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class ConfigSiemensControllerTest < ActionController::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/test/functional/fax_accounts_controller_test.rb b/test/functional/fax_accounts_controller_test.rb
new file mode 100644
index 0000000..64b781d
--- /dev/null
+++ b/test/functional/fax_accounts_controller_test.rb
@@ -0,0 +1,49 @@
+require 'test_helper'
+
+class FaxAccountsControllerTest < ActionController::TestCase
+ setup do
+ @fax_account = fax_accounts(:one)
+ end
+
+ test "should get index" do
+ get :index
+ assert_response :success
+ assert_not_nil assigns(:fax_accounts)
+ end
+
+ test "should get new" do
+ get :new
+ assert_response :success
+ end
+
+ test "should create fax_account" do
+ assert_difference('FaxAccount.count') do
+ post :create, fax_account: @fax_account.attributes
+ end
+
+ assert_redirected_to fax_account_path(assigns(:fax_account))
+ end
+
+ test "should show fax_account" do
+ get :show, id: @fax_account.to_param
+ assert_response :success
+ end
+
+ test "should get edit" do
+ get :edit, id: @fax_account.to_param
+ assert_response :success
+ end
+
+ test "should update fax_account" do
+ put :update, id: @fax_account.to_param, fax_account: @fax_account.attributes
+ assert_redirected_to fax_account_path(assigns(:fax_account))
+ end
+
+ test "should destroy fax_account" do
+ assert_difference('FaxAccount.count', -1) do
+ delete :destroy, id: @fax_account.to_param
+ end
+
+ assert_redirected_to fax_accounts_path
+ end
+end
diff --git a/test/functional/fax_documents_controller_test.rb b/test/functional/fax_documents_controller_test.rb
new file mode 100644
index 0000000..0322c61
--- /dev/null
+++ b/test/functional/fax_documents_controller_test.rb
@@ -0,0 +1,49 @@
+require 'test_helper'
+
+class FaxDocumentsControllerTest < ActionController::TestCase
+ setup do
+ @fax_document = fax_documents(:one)
+ end
+
+ test "should get index" do
+ get :index
+ assert_response :success
+ assert_not_nil assigns(:fax_documents)
+ end
+
+ test "should get new" do
+ get :new
+ assert_response :success
+ end
+
+ test "should create fax_document" do
+ assert_difference('FaxDocument.count') do
+ post :create, fax_document: @fax_document.attributes
+ end
+
+ assert_redirected_to fax_document_path(assigns(:fax_document))
+ end
+
+ test "should show fax_document" do
+ get :show, id: @fax_document.to_param
+ assert_response :success
+ end
+
+ test "should get edit" do
+ get :edit, id: @fax_document.to_param
+ assert_response :success
+ end
+
+ test "should update fax_document" do
+ put :update, id: @fax_document.to_param, fax_document: @fax_document.attributes
+ assert_redirected_to fax_document_path(assigns(:fax_document))
+ end
+
+ test "should destroy fax_document" do
+ assert_difference('FaxDocument.count', -1) do
+ delete :destroy, id: @fax_document.to_param
+ end
+
+ assert_redirected_to fax_documents_path
+ end
+end
diff --git a/test/functional/gemeinschaft_setups_controller_test.rb b/test/functional/gemeinschaft_setups_controller_test.rb
new file mode 100644
index 0000000..b23a878
--- /dev/null
+++ b/test/functional/gemeinschaft_setups_controller_test.rb
@@ -0,0 +1,50 @@
+require 'test_helper'
+
+class GemeinschaftSetupsControllerTest < ActionController::TestCase
+
+ setup do
+ @gemeinschaft_setup = Factory.build(:gemeinschaft_setup)
+ end
+
+# test "should get index" do
+# get :index
+# assert_response :success
+# assert_not_nil assigns(:gemeinschaft_setups)
+# end
+
+ test "should get new" do
+ get :new
+ assert_response :success
+ end
+
+# test "should create gemeinschaft_setup" do
+# assert_difference('GemeinschaftSetup.count') do
+# post :create,
+# gemeinschaft_setup: Factory.attributes_for(:gemeinschaft_setup)
+# end
+# assert_redirected_to gemeinschaft_setup_path(assigns(:gemeinschaft_setup))
+# end
+
+# test "should show gemeinschaft_setup" do
+# get :show, id: @gemeinschaft_setup.to_param
+# assert_response :success
+# end
+
+# test "should get edit" do
+# get :edit, id: @gemeinschaft_setup.to_param
+# assert_response :success
+# end
+
+# test "should update gemeinschaft_setup" do
+# put :update, id: @gemeinschaft_setup.to_param, gemeinschaft_setup: @gemeinschaft_setup.attributes
+# assert_redirected_to gemeinschaft_setup_path(assigns(:gemeinschaft_setup))
+# end
+
+# test "should destroy gemeinschaft_setup" do
+# assert_difference('GemeinschaftSetup.count', -1) do
+# delete :destroy, id: @gemeinschaft_setup.to_param
+# end
+# assert_redirected_to gemeinschaft_setups_path
+# end
+
+end
diff --git a/test/functional/gs_cluster_sync_log_entries_controller_test.rb b/test/functional/gs_cluster_sync_log_entries_controller_test.rb
new file mode 100644
index 0000000..f8fa336
--- /dev/null
+++ b/test/functional/gs_cluster_sync_log_entries_controller_test.rb
@@ -0,0 +1,49 @@
+require 'test_helper'
+
+class GsClusterSyncLogEntriesControllerTest < ActionController::TestCase
+ setup do
+ @gs_cluster_sync_log_entry = gs_cluster_sync_log_entries(:one)
+ end
+
+ test "should get index" do
+ get :index
+ assert_response :success
+ assert_not_nil assigns(:gs_cluster_sync_log_entries)
+ end
+
+ test "should get new" do
+ get :new
+ assert_response :success
+ end
+
+ test "should create gs_cluster_sync_log_entry" do
+ assert_difference('GsClusterSyncLogEntry.count') do
+ post :create, gs_cluster_sync_log_entry: @gs_cluster_sync_log_entry.attributes
+ end
+
+ assert_redirected_to gs_cluster_sync_log_entry_path(assigns(:gs_cluster_sync_log_entry))
+ end
+
+ test "should show gs_cluster_sync_log_entry" do
+ get :show, id: @gs_cluster_sync_log_entry.to_param
+ assert_response :success
+ end
+
+ test "should get edit" do
+ get :edit, id: @gs_cluster_sync_log_entry.to_param
+ assert_response :success
+ end
+
+ test "should update gs_cluster_sync_log_entry" do
+ put :update, id: @gs_cluster_sync_log_entry.to_param, gs_cluster_sync_log_entry: @gs_cluster_sync_log_entry.attributes
+ assert_redirected_to gs_cluster_sync_log_entry_path(assigns(:gs_cluster_sync_log_entry))
+ end
+
+ test "should destroy gs_cluster_sync_log_entry" do
+ assert_difference('GsClusterSyncLogEntry.count', -1) do
+ delete :destroy, id: @gs_cluster_sync_log_entry.to_param
+ end
+
+ assert_redirected_to gs_cluster_sync_log_entries_path
+ end
+end
diff --git a/test/functional/gs_nodes_controller_test.rb b/test/functional/gs_nodes_controller_test.rb
new file mode 100644
index 0000000..f5349ed
--- /dev/null
+++ b/test/functional/gs_nodes_controller_test.rb
@@ -0,0 +1,49 @@
+require 'test_helper'
+
+class GsNodesControllerTest < ActionController::TestCase
+ setup do
+ @gs_node = gs_nodes(:one)
+ end
+
+ test "should get index" do
+ get :index
+ assert_response :success
+ assert_not_nil assigns(:gs_nodes)
+ end
+
+ test "should get new" do
+ get :new
+ assert_response :success
+ end
+
+ test "should create gs_node" do
+ assert_difference('GsNode.count') do
+ post :create, gs_node: @gs_node.attributes
+ end
+
+ assert_redirected_to gs_node_path(assigns(:gs_node))
+ end
+
+ test "should show gs_node" do
+ get :show, id: @gs_node.to_param
+ assert_response :success
+ end
+
+ test "should get edit" do
+ get :edit, id: @gs_node.to_param
+ assert_response :success
+ end
+
+ test "should update gs_node" do
+ put :update, id: @gs_node.to_param, gs_node: @gs_node.attributes
+ assert_redirected_to gs_node_path(assigns(:gs_node))
+ end
+
+ test "should destroy gs_node" do
+ assert_difference('GsNode.count', -1) do
+ delete :destroy, id: @gs_node.to_param
+ end
+
+ assert_redirected_to gs_nodes_path
+ end
+end
diff --git a/test/functional/gui_functions_controller_test.rb b/test/functional/gui_functions_controller_test.rb
new file mode 100644
index 0000000..9a6326f
--- /dev/null
+++ b/test/functional/gui_functions_controller_test.rb
@@ -0,0 +1,49 @@
+require 'test_helper'
+
+class GuiFunctionsControllerTest < ActionController::TestCase
+ setup do
+ @gui_function = gui_functions(:one)
+ end
+
+ test "should get index" do
+ get :index
+ assert_response :success
+ assert_not_nil assigns(:gui_functions)
+ end
+
+ test "should get new" do
+ get :new
+ assert_response :success
+ end
+
+ test "should create gui_function" do
+ assert_difference('GuiFunction.count') do
+ post :create, gui_function: @gui_function.attributes
+ end
+
+ assert_redirected_to gui_function_path(assigns(:gui_function))
+ end
+
+ test "should show gui_function" do
+ get :show, id: @gui_function.to_param
+ assert_response :success
+ end
+
+ test "should get edit" do
+ get :edit, id: @gui_function.to_param
+ assert_response :success
+ end
+
+ test "should update gui_function" do
+ put :update, id: @gui_function.to_param, gui_function: @gui_function.attributes
+ assert_redirected_to gui_function_path(assigns(:gui_function))
+ end
+
+ test "should destroy gui_function" do
+ assert_difference('GuiFunction.count', -1) do
+ delete :destroy, id: @gui_function.to_param
+ end
+
+ assert_redirected_to gui_functions_path
+ end
+end
diff --git a/test/functional/hunt_group_members_controller_test.rb b/test/functional/hunt_group_members_controller_test.rb
new file mode 100644
index 0000000..9830c99
--- /dev/null
+++ b/test/functional/hunt_group_members_controller_test.rb
@@ -0,0 +1,49 @@
+require 'test_helper'
+
+class HuntGroupMembersControllerTest < ActionController::TestCase
+ setup do
+ @hunt_group_member = hunt_group_members(:one)
+ end
+
+ test "should get index" do
+ get :index
+ assert_response :success
+ assert_not_nil assigns(:hunt_group_members)
+ end
+
+ test "should get new" do
+ get :new
+ assert_response :success
+ end
+
+ test "should create hunt_group_member" do
+ assert_difference('HuntGroupMember.count') do
+ post :create, hunt_group_member: @hunt_group_member.attributes
+ end
+
+ assert_redirected_to hunt_group_member_path(assigns(:hunt_group_member))
+ end
+
+ test "should show hunt_group_member" do
+ get :show, id: @hunt_group_member.to_param
+ assert_response :success
+ end
+
+ test "should get edit" do
+ get :edit, id: @hunt_group_member.to_param
+ assert_response :success
+ end
+
+ test "should update hunt_group_member" do
+ put :update, id: @hunt_group_member.to_param, hunt_group_member: @hunt_group_member.attributes
+ assert_redirected_to hunt_group_member_path(assigns(:hunt_group_member))
+ end
+
+ test "should destroy hunt_group_member" do
+ assert_difference('HuntGroupMember.count', -1) do
+ delete :destroy, id: @hunt_group_member.to_param
+ end
+
+ assert_redirected_to hunt_group_members_path
+ end
+end
diff --git a/test/functional/hunt_groups_controller_test.rb b/test/functional/hunt_groups_controller_test.rb
new file mode 100644
index 0000000..0234e12
--- /dev/null
+++ b/test/functional/hunt_groups_controller_test.rb
@@ -0,0 +1,49 @@
+require 'test_helper'
+
+class HuntGroupsControllerTest < ActionController::TestCase
+ setup do
+ @hunt_group = hunt_groups(:one)
+ end
+
+ test "should get index" do
+ get :index
+ assert_response :success
+ assert_not_nil assigns(:hunt_groups)
+ end
+
+ test "should get new" do
+ get :new
+ assert_response :success
+ end
+
+ test "should create hunt_group" do
+ assert_difference('HuntGroup.count') do
+ post :create, hunt_group: @hunt_group.attributes
+ end
+
+ assert_redirected_to hunt_group_path(assigns(:hunt_group))
+ end
+
+ test "should show hunt_group" do
+ get :show, id: @hunt_group.to_param
+ assert_response :success
+ end
+
+ test "should get edit" do
+ get :edit, id: @hunt_group.to_param
+ assert_response :success
+ end
+
+ test "should update hunt_group" do
+ put :update, id: @hunt_group.to_param, hunt_group: @hunt_group.attributes
+ assert_redirected_to hunt_group_path(assigns(:hunt_group))
+ end
+
+ test "should destroy hunt_group" do
+ assert_difference('HuntGroup.count', -1) do
+ delete :destroy, id: @hunt_group.to_param
+ end
+
+ assert_redirected_to hunt_groups_path
+ end
+end
diff --git a/test/functional/manufacturers_controller_test.rb b/test/functional/manufacturers_controller_test.rb
new file mode 100644
index 0000000..dad38e5
--- /dev/null
+++ b/test/functional/manufacturers_controller_test.rb
@@ -0,0 +1,77 @@
+require 'test_helper'
+
+class ManufacturersControllerTest < ActionController::TestCase
+ setup do
+ @tenant = Factory.create(:tenant)
+ @user = Factory.create(:user)
+
+ @tenant.tenant_memberships.create(:user_id => @user.id)
+
+ @user.update_attributes!(:current_tenant_id => @tenant.id)
+
+ @manufacturer = Factory.create(:manufacturer)
+
+ @expected_status_if_not_authorized = :redirect
+ end
+
+ test "should not do anything for a normal user" do
+ session[:user_id] = @user.id
+ get :index
+ assert_response :redirect
+
+ get :new
+ assert_response :redirect
+
+ get :show, id: @manufacturer.to_param
+ assert_response :redirect
+
+ get :edit, id: @manufacturer.to_param
+ assert_response :redirect
+ end
+
+ # Maybe some sort of SuperUser Group should have access.
+ # Needs some more thinking.
+ #
+ # test "should get index" do
+ # session[:user_id] = @user.id
+ # get :index
+ # assert_response :success
+ # assert_not_nil assigns(:manufacturers)
+ # end
+ #
+ # test "should get new" do
+ # get :new
+ # assert_response :success
+ # end
+ #
+ # test "should create manufacturer" do
+ # assert_difference('Manufacturer.count') do
+ # post :create, manufacturer: Factory.build(:manufacturer).attributes
+ # end
+ #
+ # assert_redirected_to manufacturer_path(assigns(:manufacturer))
+ # end
+ #
+ # test "should show manufacturer" do
+ # get :show, id: @manufacturer.to_param
+ # assert_response :success
+ # end
+ #
+ # test "should get edit" do
+ # get :edit, id: @manufacturer.to_param
+ # assert_response :success
+ # end
+ #
+ # test "should update manufacturer" do
+ # put :update, id: @manufacturer.to_param, manufacturer: @manufacturer.attributes
+ # assert_redirected_to manufacturer_path(assigns(:manufacturer))
+ # end
+ #
+ # test "should destroy manufacturer" do
+ # assert_difference('Manufacturer.count', -1) do
+ # delete :destroy, id: @manufacturer.to_param
+ # end
+ #
+ # assert_redirected_to manufacturers_path
+ # end
+end
diff --git a/test/functional/notifications_test.rb b/test/functional/notifications_test.rb
new file mode 100644
index 0000000..d84bda2
--- /dev/null
+++ b/test/functional/notifications_test.rb
@@ -0,0 +1,12 @@
+require 'test_helper'
+
+class NotificationsTest < ActionMailer::TestCase
+ test "new_pin" do
+ mail = Notifications.new_pin
+ assert_equal "New pin", mail.subject
+ assert_equal ["to@example.org"], mail.to
+ assert_equal ["from@example.com"], mail.from
+ assert_match "Hi", mail.body.encoded
+ end
+
+end
diff --git a/test/functional/page_controller_test.rb b/test/functional/page_controller_test.rb
new file mode 100644
index 0000000..a5ae5ad
--- /dev/null
+++ b/test/functional/page_controller_test.rb
@@ -0,0 +1,35 @@
+require 'test_helper'
+
+class PageControllerTest < ActionController::TestCase
+
+ #test "on a fresh system you should not get index but be redirected to the setup wizard" do
+ test "should be redirected to setup wizard on a fresh system" do
+ session[:user_id] = nil
+ get :index
+ assert_redirected_to wizards_new_initial_setup_path
+ end
+
+
+ test "a logged in user should get index" do
+ @tenant = Factory.create(:tenant)
+ @user = Factory.create(:user)
+
+ @tenant.users << @user
+
+ session[:user_id] = @user.id
+ get :index
+ assert_response :success
+ end
+
+ test "a logged out user should be redirected to the login" do
+ @tenant = Factory.create(:tenant)
+ @user = Factory.create(:user)
+
+ @tenant.users << @user
+
+ session[:user_id] = nil
+ get :index
+ assert_redirected_to log_in_path
+ end
+
+end
diff --git a/test/functional/phone_book_entries_controller_test.rb b/test/functional/phone_book_entries_controller_test.rb
new file mode 100644
index 0000000..81c5b61
--- /dev/null
+++ b/test/functional/phone_book_entries_controller_test.rb
@@ -0,0 +1,103 @@
+require 'test_helper'
+
+class PhoneBookEntriesControllerTest < ActionController::TestCase
+
+ setup do
+ @user1 = Factory.create(:user)
+ pb = @user1.phone_books.first
+ @user1_phone_book_entry = Factory.create(
+ :phone_book_entry,
+ :phone_book_id => pb.id
+ )
+
+ @expected_status_if_not_authorized = :redirect
+ end
+
+ test "should not get index (not logged in)" do
+ get :index
+ assert_response @expected_status_if_not_authorized
+ end
+
+ test "should get index" do
+ session[:user_id] = @user1.id
+ get :index
+ assert_response :success
+ assert_not_nil assigns(:phone_book_entries)
+ end
+
+
+# test "should get new" do
+# get :new
+# assert_response :success
+# end
+
+ test "should not have a route for new" do
+ assert_raises(ActionController::RoutingError) {
+ get :new
+ }
+ end
+
+#
+# test "should create phone_book_entry" do
+# assert_difference('PhoneBookEntry.count') do
+# post :create, phone_book_entry: @user1_phone_book_entry.attributes
+# end
+#
+# assert_redirected_to phone_book_entry_path(assigns(:phone_book_entry))
+# end
+#
+ test "should not show phone_book_entry (not logged in)" do
+ get :show, id: @user1_phone_book_entry.to_param
+ assert_response @expected_status_if_not_authorized
+ end
+
+ test "should show phone_book_entry without nesting" do
+ session[:user_id] = @user1.id
+ get :show, id: @user1_phone_book_entry.to_param
+ assert_response :success
+ end
+
+ test "should show phone_book_entry nested in phone_book" do
+ session[:user_id] = @user1.id
+ get :show, phone_book_id: @user1_phone_book_entry.phone_book.id, id: @user1_phone_book_entry.to_param
+ assert_response :success
+ end
+#
+# test "should get edit" do
+# get :edit, id: @user1_phone_book_entry.to_param
+# assert_response :success
+# end
+
+ test "should not have a route for edit" do
+ assert_raises(ActionController::RoutingError) {
+ get :edit, id: @user1_phone_book_entry.to_param
+ }
+ end
+
+#
+# test "should update phone_book_entry" do
+# put :update, id: @user1_phone_book_entry.to_param, phone_book_entry: @user1_phone_book_entry.attributes
+# assert_redirected_to phone_book_entry_path(assigns(:phone_book_entry))
+# end
+
+ test "should not have a route for update" do
+ assert_raises(ActionController::RoutingError) {
+ put :update, id: @user1_phone_book_entry.to_param, phone_book_entry: @user1_phone_book_entry.attributes
+ }
+ end
+
+#
+# test "should destroy phone_book_entry" do
+# assert_difference('PhoneBookEntry.count', -1) do
+# delete :destroy, id: @user1_phone_book_entry.to_param
+# end
+# assert_redirected_to phone_book_entries_path
+# end
+
+ test "should not have a route for destroy" do
+ assert_raises(ActionController::RoutingError) {
+ delete :destroy, id: @user1_phone_book_entry.to_param
+ }
+ end
+
+end
diff --git a/test/functional/phone_books_controller_test.rb b/test/functional/phone_books_controller_test.rb
new file mode 100644
index 0000000..a00f597
--- /dev/null
+++ b/test/functional/phone_books_controller_test.rb
@@ -0,0 +1,71 @@
+require 'test_helper'
+
+class PhoneBooksControllerTest < ActionController::TestCase
+ setup do
+ @tenant = Factory.create(:tenant)
+ @admins = @tenant.user_groups.find_or_create_by_name('Admins')
+ @users = @tenant.user_groups.find_or_create_by_name('Users')
+ @user = Factory.create(:user)
+
+ @tenant.users << @user
+ @users.users << @user
+
+ @personal_phone_book = Factory.create(:phone_book,
+ :phone_bookable_type => @user.class.to_s,
+ :phone_bookable_id => @user.id
+ )
+ phone_book_entry = Factory.create(:phone_book_entry)
+ @personal_phone_book.phone_book_entries << phone_book_entry
+
+ @expected_status_if_not_authorized = :redirect
+
+ session[:user_id] = @user.id
+ end
+
+ test "should get index" do
+ get :index, user_id: @user.id
+ assert_response :success
+ assert_not_nil assigns(:phone_books)
+ end
+
+ test "should get new" do
+ get :new, user_id: @user.id
+ assert_response :success
+ end
+
+ test "should create phone_book" do
+ phone_book2 = Factory.build(:phone_book,
+ :phone_bookable_type => @user.class.to_s,
+ :phone_bookable_id => @user.id
+ )
+ assert_difference('PhoneBook.count') do
+ post :create, phone_book: phone_book2.attributes, user_id: @user.id
+ end
+ assert_redirected_to( user_phone_book_path( @user, assigns(:phone_book)))
+ end
+
+ test "should show phone_book" do
+ get :show, id: @personal_phone_book.to_param, user_id: @user.id
+ assert_response :success
+ end
+
+ test "should get edit" do
+ get :edit, id: @personal_phone_book.to_param, user_id: @user.id
+ assert_response :success
+ end
+
+ test "should update phone_book" do
+ put :update, id: @personal_phone_book.to_param, phone_book: @personal_phone_book.attributes, user_id: @user.id
+ assert_redirected_to( user_phone_book_path(@user, assigns(:phone_book)))
+ end
+
+ # TODO: Fix this test
+ #
+ # test "should destroy phone_book" do
+ # assert_difference('PhoneBook.count', -1) do
+ # delete :destroy, id: @personal_phone_book.to_param, user_id: @user.id
+ # end
+ # assert_redirected_to( user_phone_books_path( @user ))
+ # end
+
+end
diff --git a/test/functional/phone_models_controller_test.rb b/test/functional/phone_models_controller_test.rb
new file mode 100644
index 0000000..2d1a87a
--- /dev/null
+++ b/test/functional/phone_models_controller_test.rb
@@ -0,0 +1,143 @@
+require 'test_helper'
+
+class PhoneModelsControllerTest < ActionController::TestCase
+
+ setup do
+ # Create a tenant:
+ @tenant = Factory.create(:tenant)
+
+ # Create a User who is member of the Tenant but has no special rights:
+ @user = Factory.create(:user)
+ @tenant.tenant_memberships.create(:user_id => @user.id)
+ @user.update_attributes!(:current_tenant_id => @tenant.id)
+
+ # Create a User who is member of the Tenant and has super admin rights:
+ @super_admin = Factory.create(:user)
+ @tenant.tenant_memberships.create(:user_id => @super_admin.id)
+ @super_admin.update_attributes!(:current_tenant_id => @tenant.id)
+
+ # Create a PhoneModel
+ #
+ @phone_model = Factory.create(:phone_model)
+ end
+
+ [ '@user.id', '' ].each do |user_id_code|
+ # Note: Do *not* actually create the user outside of tests.
+
+ explanation = user_id_code.blank? ?
+ "if not logged in" :
+ "if logged in as an ordinary user"
+
+ test "should not get index #{explanation}" do
+ session[:user_id] = eval( user_id_code )
+ get :index, manufacturer_id: @phone_model.manufacturer_id
+ assert_response :redirect
+ end
+
+ test "should not get new #{explanation}" do
+ session[:user_id] = eval( user_id_code )
+ get :new, manufacturer_id: @phone_model.manufacturer_id
+ assert_response :redirect
+ end
+
+ test "should not create phone_model #{explanation}" do
+ session[:user_id] = eval( user_id_code )
+
+ assert_no_difference('PhoneModel.count') do
+ post :create, manufacturer_id: @phone_model.manufacturer_id, phone_model: Factory.build(:phone_model,
+ :manufacturer_id => @phone_model.manufacturer_id).attributes
+ end
+ end
+
+ test "should not show phone_model #{explanation}" do
+ session[:user_id] = eval( user_id_code )
+ get :show, manufacturer_id: @phone_model.manufacturer_id, id: @phone_model.to_param
+ assert_response :redirect
+ end
+
+ test "should not get edit #{explanation}" do
+ session[:user_id] = eval( user_id_code )
+ get :edit, manufacturer_id: @phone_model.manufacturer_id, id: @phone_model.to_param
+ assert_response :redirect
+ end
+
+ test "should not update phone_model #{explanation}" do
+ session[:user_id] = eval( user_id_code )
+
+ # save the old name:
+ old_name = PhoneModel.find(@phone_model.id).name
+ # try to make an update:
+ put :update, manufacturer_id: @phone_model.manufacturer_id, id: @phone_model.to_param, phone_model: @phone_model.attributes.merge({
+ 'name' => @phone_model.name.reverse
+ })
+ # check that the update didn't work:
+ assert_equal old_name, PhoneModel.find(@phone_model.id).name
+
+ assert_response :redirect
+ end
+
+ test "should not destroy phone_model #{explanation}" do
+ session[:user_id] = eval( user_id_code )
+
+ assert_no_difference('PhoneModel.count') do
+ delete :destroy, manufacturer_id: @phone_model.manufacturer_id, id: @phone_model.to_param
+ end
+ assert_response :redirect
+ end
+
+ end
+
+
+ test "should get index as super admin" do
+ session[:user_id] = @super_admin.id
+ get :index, manufacturer_id: @phone_model.manufacturer_id
+ assert_response :success
+ assert_not_nil assigns(:phone_models)
+ end
+
+ test "should get new as super admin" do
+ session[:user_id] = @super_admin.id
+ get :new, manufacturer_id: @phone_model.manufacturer_id
+ assert_response :success
+ end
+
+
+ # # We don't have access to manufacturer_id. We'll need to
+ # # add routes first.
+ # test "should create phone_model as super admin" do
+ # assert_difference('PhoneModel.count') do
+ # post :create, phone_model: Factory.build(:phone_model,
+ # :manufacturer_id => @phone_model.manufacturer_id).attributes
+ # end
+ #
+ # assert_redirected_to manufacturer_phone_model_path( @phone_model.manufacturer_id, assigns(:phone_model))
+ # end
+
+ test "should show phone_model as super admin" do
+ session[:user_id] = @super_admin.id
+ get :show, manufacturer_id: @phone_model.manufacturer_id, id: @phone_model.to_param
+ assert_response :success
+ end
+
+ test "should get edit as super admin" do
+ session[:user_id] = @super_admin.id
+ get :edit, manufacturer_id: @phone_model.manufacturer_id, id: @phone_model.to_param
+ assert_response :success
+ end
+
+ test "should update phone_model as super admin" do
+ session[:user_id] = @super_admin.id
+ put :update, manufacturer_id: @phone_model.manufacturer_id, id: @phone_model.to_param, phone_model: @phone_model.attributes
+ assert_redirected_to manufacturer_phone_model_path( @phone_model.manufacturer_id, assigns(:phone_model))
+ end
+
+ test "should destroy phone_model as super admin" do
+ session[:user_id] = @super_admin.id
+ assert_difference('PhoneModel.count', -1) do
+ delete :destroy, manufacturer_id: @phone_model.manufacturer_id, id: @phone_model.to_param
+ end
+
+ assert_redirected_to manufacturer_phone_models_path( @phone_model.manufacturer_id )
+ end
+
+end
diff --git a/test/functional/phone_number_ranges_controller_test.rb b/test/functional/phone_number_ranges_controller_test.rb
new file mode 100644
index 0000000..39f28c4
--- /dev/null
+++ b/test/functional/phone_number_ranges_controller_test.rb
@@ -0,0 +1,78 @@
+require 'test_helper'
+
+class PhoneNumberRangesControllerTest < ActionController::TestCase
+
+ #TODO Uncomment tests once the views are implemented.
+
+ setup do
+ @phone_number_range = Factory.create(:phone_number_range)
+ end
+
+ test "should get index" do
+ get :index,
+ :"#{@phone_number_range.phone_number_rangeable_type.underscore}_id" => @phone_number_range.phone_number_rangeable.try(:to_param)
+ assert_response :success
+ assert_not_nil assigns(:phone_number_ranges)
+ end
+
+# test "should get new" do
+# get :new,
+# :"#{@phone_number_range.phone_number_rangeable_type.underscore}_id" => @phone_number_range.phone_number_rangeable.try(:to_param)
+# assert_response :success
+# end
+
+# test "should create phone_number_range" do
+# assert_difference('PhoneNumberRange.count') do
+# post :create,
+# :"#{@phone_number_range.phone_number_rangeable_type.underscore}_id" => @phone_number_range.phone_number_rangeable.try(:to_param),
+# :phone_number_range => @phone_number_range.attributes
+# end
+# assert_redirected_to(
+# method( :"#{@phone_number_range.phone_number_rangeable_type.underscore}_phone_number_range_path" ).(
+# @phone_number_range.phone_number_rangeable,
+# @phone_number_range
+# )
+# )
+# end
+
+# test "should show phone_number_range" do
+# get :show,
+# :"#{@phone_number_range.phone_number_rangeable_type.underscore}_id" => @phone_number_range.phone_number_rangeable.try(:to_param),
+# :id => @phone_number_range.to_param
+# assert_response :success
+# end
+
+# test "should get edit" do
+# get :edit,
+# :"#{@phone_number_range.phone_number_rangeable_type.underscore}_id" => @phone_number_range.phone_number_rangeable.try(:to_param),
+# :id => @phone_number_range.to_param
+# assert_response :success
+# end
+
+ test "should update phone_number_range" do
+ put :update,
+ :"#{@phone_number_range.phone_number_rangeable_type.underscore}_id" => @phone_number_range.phone_number_rangeable.try(:to_param),
+ :id => @phone_number_range.to_param,
+ :phone_number_range => @phone_number_range.attributes
+# assert_redirected_to(
+# method( :"#{@phone_number_range.phone_number_rangeable_type.underscore}_phone_number_range_path" ).(
+# @phone_number_range.phone_number_rangeable,
+# @phone_number_range
+# )
+# )
+ end
+
+# test "should destroy phone_number_range" do
+# assert_difference('PhoneNumberRange.count', -1) do
+# delete :destroy,
+# :"#{@phone_number_range.phone_number_rangeable_type.underscore}_id" => @phone_number_range.phone_number_rangeable.try(:to_param),
+# :id => @phone_number_range.to_param
+# end
+# assert_redirected_to(
+# method( :"#{@phone_number_range.phone_number_rangeable_type.underscore}_phone_number_ranges_path" ).(
+# @phone_number_range.phone_number_rangeable
+# )
+# )
+# end
+
+end
diff --git a/test/functional/phone_numbers_controller_test.rb b/test/functional/phone_numbers_controller_test.rb
new file mode 100644
index 0000000..ab0a4b2
--- /dev/null
+++ b/test/functional/phone_numbers_controller_test.rb
@@ -0,0 +1,115 @@
+require 'test_helper'
+
+class PhoneNumbersControllerTest < ActionController::TestCase
+
+ setup do
+ @tenant = Factory.create(:tenant)
+ @user = Factory.create(:user)
+
+ @tenant.tenant_memberships.create(:user_id => @user.id)
+
+ @user.update_attributes!(:current_tenant_id => @tenant.id)
+
+ @private_phone_book = @user.phone_books.first
+
+ @private_phone_book_entry = Factory.create(
+ :phone_book_entry,
+ :phone_book => @private_phone_book
+ )
+ @phone_number = Factory.create(
+ :phone_number,
+ :phone_numberable => @private_phone_book_entry
+ )
+
+ @expected_status_if_not_authorized = :redirect
+ end
+
+
+ test "should get index" do
+ session[:user_id] = @user.id
+ get :index, phone_book_entry_id: @private_phone_book_entry.id
+ assert_response :success
+ assert_not_nil assigns(:phone_numbers)
+ end
+
+ test "should not get index (not logged in)" do
+ get :index, phone_book_entry_id: @private_phone_book_entry.id
+ assert_response @expected_status_if_not_authorized
+ end
+
+ test "should get new" do
+ session[:user_id] = @user.id
+ get :new, phone_book_entry_id: @private_phone_book_entry.id
+ assert_response :success
+ end
+
+ # test "should not get new (not logged in)" do
+ # get :new, phone_book_entry_id: @private_phone_book_entry.id
+ # assert_response @expected_status_if_not_authorized
+ # end
+
+ # test "should create phone_number" do
+ # session[:user_id] = @user.id
+ # assert_difference('PhoneNumber.count') do
+ # post :create, phone_book_entry_id: @private_phone_book_entry.id, phone_number: @phone_number.attributes
+ # end
+ # assert_redirected_to( phone_book_entry_phone_number_path( assigns(:phone_number)))
+ # end
+ #
+ # test "should not create phone_number (not logged in)" do
+ # assert_no_difference('PhoneNumber.count') do
+ # post :create, phone_book_entry_id: @private_phone_book_entry.id, phone_number: @phone_number.attributes
+ # end
+ # assert_response @expected_status_if_not_authorized
+ # end
+
+ test "should show phone_number" do
+ session[:user_id] = @user.id
+ get :show, phone_book_entry_id: @private_phone_book_entry.id, id: @phone_number.to_param
+ assert_response :success
+ end
+
+ test "should not show phone_number (not logged in)" do
+ get :show, phone_book_entry_id: @private_phone_book_entry.id, id: @phone_number.to_param
+ assert_response @expected_status_if_not_authorized
+ end
+
+
+ test "should get edit" do
+ session[:user_id] = @user.id
+ get :edit, phone_book_entry_id: @private_phone_book_entry.id, id: @phone_number.to_param
+ assert_response :success
+ end
+
+ test "should not get edit (not logged in)" do
+ get :edit, phone_book_entry_id: @private_phone_book_entry.id, id: @phone_number.to_param
+ assert_response @expected_status_if_not_authorized
+ end
+
+ test "should update phone_number" do
+ session[:user_id] = @user.id
+ put :update, phone_book_entry_id: @private_phone_book_entry.id, id: @phone_number.to_param, phone_number: @phone_number.attributes
+ assert_redirected_to( phone_book_entry_phone_number_path( assigns(:phone_number)))
+ end
+
+ test "should not update phone_number (not logged in)" do
+ put :update, phone_book_entry_id: @private_phone_book_entry.id, id: @phone_number.to_param, phone_number: @phone_number.attributes
+ assert_response @expected_status_if_not_authorized
+ end
+
+ test "should destroy phone_number" do
+ session[:user_id] = @user.id
+ assert_difference('PhoneNumber.count', -1) do
+ delete :destroy, phone_book_entry_id: @private_phone_book_entry.id, id: @phone_number.to_param
+ end
+ assert_redirected_to( phone_book_entry_phone_numbers_path() )
+ end
+
+ test "should not destroy phone_number (not logged in)" do
+ assert_no_difference('PhoneNumber.count') do
+ delete :destroy, phone_book_entry_id: @private_phone_book_entry.id, id: @phone_number.to_param
+ end
+ assert_response @expected_status_if_not_authorized
+ end
+
+end
diff --git a/test/functional/phone_sip_accounts_controller_test.rb b/test/functional/phone_sip_accounts_controller_test.rb
new file mode 100644
index 0000000..37a3219
--- /dev/null
+++ b/test/functional/phone_sip_accounts_controller_test.rb
@@ -0,0 +1,49 @@
+require 'test_helper'
+
+class PhoneSipAccountsControllerTest < ActionController::TestCase
+ setup do
+ @phone_sip_account = phone_sip_accounts(:one)
+ end
+
+ test "should get index" do
+ get :index
+ assert_response :success
+ assert_not_nil assigns(:phone_sip_accounts)
+ end
+
+ test "should get new" do
+ get :new
+ assert_response :success
+ end
+
+ test "should create phone_sip_account" do
+ assert_difference('PhoneSipAccount.count') do
+ post :create, phone_sip_account: @phone_sip_account.attributes
+ end
+
+ assert_redirected_to phone_sip_account_path(assigns(:phone_sip_account))
+ end
+
+ test "should show phone_sip_account" do
+ get :show, id: @phone_sip_account.to_param
+ assert_response :success
+ end
+
+ test "should get edit" do
+ get :edit, id: @phone_sip_account.to_param
+ assert_response :success
+ end
+
+ test "should update phone_sip_account" do
+ put :update, id: @phone_sip_account.to_param, phone_sip_account: @phone_sip_account.attributes
+ assert_redirected_to phone_sip_account_path(assigns(:phone_sip_account))
+ end
+
+ test "should destroy phone_sip_account" do
+ assert_difference('PhoneSipAccount.count', -1) do
+ delete :destroy, id: @phone_sip_account.to_param
+ end
+
+ assert_redirected_to phone_sip_accounts_path
+ end
+end
diff --git a/test/functional/phones_controller_test.rb b/test/functional/phones_controller_test.rb
new file mode 100644
index 0000000..1b0aa55
--- /dev/null
+++ b/test/functional/phones_controller_test.rb
@@ -0,0 +1,55 @@
+require 'test_helper'
+
+class PhonesControllerTest < ActionController::TestCase
+ # TODO nil und normaler User duerfen nichts.
+
+ #TODO Uncomment tests once the route has been implemented.
+
+# setup do
+# @phone = Factory.create(:phone)
+# end
+#
+# test "should get index" do
+# get :index
+# assert_response :success
+# assert_not_nil assigns(:phones)
+# end
+#
+# test "should get new" do
+# get :new
+# assert_response :success
+# end
+#
+# # Would have to be a nested route to work.
+# #
+# # test "should create phone" do
+# # assert_difference('Phone.count') do
+# # post :create, phone: Factory.build(:phone, :phone_model_id => @phone.phone_model_id).attributes
+# # end
+# #
+# # assert_redirected_to phone_path(assigns(:phone))
+# # end
+#
+# test "should show phone" do
+# get :show, id: @phone.to_param
+# assert_response :success
+# end
+#
+# test "should get edit" do
+# get :edit, id: @phone.to_param
+# assert_response :success
+# end
+#
+# test "should update phone" do
+# put :update, id: @phone.to_param, phone: @phone.attributes
+# assert_redirected_to phone_path(assigns(:phone))
+# end
+#
+# test "should destroy phone" do
+# assert_difference('Phone.count', -1) do
+# delete :destroy, id: @phone.to_param
+# end
+#
+# assert_redirected_to phones_path
+# end
+end
diff --git a/test/functional/phones_sip_accounts_controller_test.rb b/test/functional/phones_sip_accounts_controller_test.rb
new file mode 100644
index 0000000..967b8fe
--- /dev/null
+++ b/test/functional/phones_sip_accounts_controller_test.rb
@@ -0,0 +1,49 @@
+require 'test_helper'
+
+class PhonesSipAccountsControllerTest < ActionController::TestCase
+
+ setup do
+ @phones_sip_account = Factory.create(:phones_sip_account)
+ end
+
+# test "should get index" do
+# get :index
+# assert_response :success
+# assert_not_nil assigns(:phones_sip_accounts)
+# end
+#
+# test "should get new" do
+# get :new
+# assert_response :success
+# end
+#
+# test "should create phones_sip_account" do
+# assert_difference('PhonesSipAccount.count') do
+# post :create, phones_sip_account: @phones_sip_account.attributes
+# end
+# assert_redirected_to phones_sip_account_path(assigns(:phones_sip_account))
+# end
+#
+# test "should show phones_sip_account" do
+# get :show, id: @phones_sip_account.to_param
+# assert_response :success
+# end
+#
+# test "should get edit" do
+# get :edit, id: @phones_sip_account.to_param
+# assert_response :success
+# end
+#
+# test "should update phones_sip_account" do
+# put :update, id: @phones_sip_account.to_param, phones_sip_account: @phones_sip_account.attributes
+# assert_redirected_to phones_sip_account_path(assigns(:phones_sip_account))
+# end
+#
+# test "should destroy phones_sip_account" do
+# assert_difference('PhonesSipAccount.count', -1) do
+# delete :destroy, id: @phones_sip_account.to_param
+# end
+# assert_redirected_to phones_sip_accounts_path
+# end
+
+end
diff --git a/test/functional/ringtones_controller_test.rb b/test/functional/ringtones_controller_test.rb
new file mode 100644
index 0000000..f0f04f6
--- /dev/null
+++ b/test/functional/ringtones_controller_test.rb
@@ -0,0 +1,49 @@
+require 'test_helper'
+
+class RingtonesControllerTest < ActionController::TestCase
+ setup do
+ @ringtone = ringtones(:one)
+ end
+
+ test "should get index" do
+ get :index
+ assert_response :success
+ assert_not_nil assigns(:ringtones)
+ end
+
+ test "should get new" do
+ get :new
+ assert_response :success
+ end
+
+ test "should create ringtone" do
+ assert_difference('Ringtone.count') do
+ post :create, ringtone: @ringtone.attributes
+ end
+
+ assert_redirected_to ringtone_path(assigns(:ringtone))
+ end
+
+ test "should show ringtone" do
+ get :show, id: @ringtone.to_param
+ assert_response :success
+ end
+
+ test "should get edit" do
+ get :edit, id: @ringtone.to_param
+ assert_response :success
+ end
+
+ test "should update ringtone" do
+ put :update, id: @ringtone.to_param, ringtone: @ringtone.attributes
+ assert_redirected_to ringtone_path(assigns(:ringtone))
+ end
+
+ test "should destroy ringtone" do
+ assert_difference('Ringtone.count', -1) do
+ delete :destroy, id: @ringtone.to_param
+ end
+
+ assert_redirected_to ringtones_path
+ end
+end
diff --git a/test/functional/sessions_controller_test.rb b/test/functional/sessions_controller_test.rb
new file mode 100644
index 0000000..d30ebc3
--- /dev/null
+++ b/test/functional/sessions_controller_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class SessionsControllerTest < ActionController::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/test/functional/sip_accounts_controller_test.rb b/test/functional/sip_accounts_controller_test.rb
new file mode 100644
index 0000000..5c97dd2
--- /dev/null
+++ b/test/functional/sip_accounts_controller_test.rb
@@ -0,0 +1,76 @@
+require 'test_helper'
+
+class SipAccountsControllerTest < ActionController::TestCase
+
+ setup do
+ @tenant = Factory.create(:tenant)
+ @user = Factory.create(:user)
+ @tenant.tenant_memberships.create(:user_id => @user.id)
+ @sip_account = @user.sip_accounts.create( Factory.build(:sip_account).attributes )
+
+ @parent_param = @sip_account.sip_accountable_type.foreign_key.to_sym
+ @parent_id = @sip_account.sip_accountable.id
+ end
+
+ test "should get index" do
+ session[:user_id] = @user.id
+ get :index,
+ @parent_param => @parent_id
+ assert_response :success
+ assert_not_nil assigns(:sip_accounts)
+ end
+
+ test "should get new" do
+ session[:user_id] = @user.id
+ get :new,
+ @parent_param => @parent_id
+ assert_response :success
+ end
+
+ test "should create sip_account" do
+ session[:user_id] = @user.id
+ assert_difference('SipAccount.count') do
+ post :create,
+ @parent_param => @parent_id,
+ sip_account: Factory.attributes_for(:sip_account)
+ end
+ end
+
+ test "should show sip_account" do
+ session[:user_id] = @user.id
+ get :show,
+ @parent_param => @parent_id,
+ id: @sip_account.to_param
+ assert_response :success
+ end
+
+ test "should get edit" do
+ session[:user_id] = @user.id
+ get :edit,
+ @parent_param => @parent_id,
+ id: @sip_account.to_param
+ assert_response :success
+ end
+
+ test "should update sip_account" do
+ session[:user_id] = @user.id
+ put :update,
+ @parent_param => @parent_id,
+ id: @sip_account.to_param,
+ sip_account: @sip_account.attributes
+ # TODO Find the right redirect/answer.
+ #assert_redirected_to method( :"#{@sip_account.sip_accountable_type.underscore}_sip_account_path" ).( @sip_account.sip_accountable, @sip_account )
+ end
+
+ test "should destroy sip_account" do
+ session[:user_id] = @user.id
+ assert_difference('SipAccount.count', -1) do
+ delete :destroy,
+ @parent_param => @parent_id,
+ id: @sip_account.to_param
+ end
+ # TODO Find the right redirect/answer.
+ #assert_redirected_to method( :"#{@sip_account.sip_accountable_type.underscore}_sip_accounts_path" ).( @sip_account.sip_accountable )
+ end
+
+end
diff --git a/test/functional/sip_domains_controller_test.rb b/test/functional/sip_domains_controller_test.rb
new file mode 100644
index 0000000..f26ea02
--- /dev/null
+++ b/test/functional/sip_domains_controller_test.rb
@@ -0,0 +1,49 @@
+require 'test_helper'
+
+class SipDomainsControllerTest < ActionController::TestCase
+ setup do
+ @sip_domain = Factory.create(:sip_domain)
+ end
+
+ test "should get index" do
+ get :index
+ assert_response :success
+ assert_not_nil assigns(:sip_domains)
+ end
+
+ test "should get new" do
+ get :new
+ assert_response :success
+ end
+
+ test "should create sip_domain" do
+ assert_difference('SipDomain.count') do
+ post :create, sip_domain: Factory.build(:sip_domain).attributes
+ end
+
+ assert_redirected_to sip_domain_path(assigns(:sip_domain))
+ end
+
+ test "should show sip_domain" do
+ get :show, id: @sip_domain.to_param
+ assert_response :success
+ end
+
+ test "should get edit" do
+ get :edit, id: @sip_domain.to_param
+ assert_response :success
+ end
+
+ test "should update sip_domain" do
+ put :update, id: @sip_domain.to_param, sip_domain: @sip_domain.attributes
+ assert_redirected_to sip_domain_path(assigns(:sip_domain))
+ end
+
+ test "should destroy sip_domain" do
+ assert_difference('SipDomain.count', -1) do
+ delete :destroy, id: @sip_domain.to_param
+ end
+
+ assert_redirected_to sip_domains_path
+ end
+end
diff --git a/test/functional/softkeys_controller_test.rb b/test/functional/softkeys_controller_test.rb
new file mode 100644
index 0000000..6eed165
--- /dev/null
+++ b/test/functional/softkeys_controller_test.rb
@@ -0,0 +1,49 @@
+require 'test_helper'
+
+class SoftkeysControllerTest < ActionController::TestCase
+ setup do
+ @softkey = softkeys(:one)
+ end
+
+ test "should get index" do
+ get :index
+ assert_response :success
+ assert_not_nil assigns(:softkeys)
+ end
+
+ test "should get new" do
+ get :new
+ assert_response :success
+ end
+
+ test "should create softkey" do
+ assert_difference('Softkey.count') do
+ post :create, softkey: @softkey.attributes
+ end
+
+ assert_redirected_to softkey_path(assigns(:softkey))
+ end
+
+ test "should show softkey" do
+ get :show, id: @softkey.to_param
+ assert_response :success
+ end
+
+ test "should get edit" do
+ get :edit, id: @softkey.to_param
+ assert_response :success
+ end
+
+ test "should update softkey" do
+ put :update, id: @softkey.to_param, softkey: @softkey.attributes
+ assert_redirected_to softkey_path(assigns(:softkey))
+ end
+
+ test "should destroy softkey" do
+ assert_difference('Softkey.count', -1) do
+ delete :destroy, id: @softkey.to_param
+ end
+
+ assert_redirected_to softkeys_path
+ end
+end
diff --git a/test/functional/system_messages_controller_test.rb b/test/functional/system_messages_controller_test.rb
new file mode 100644
index 0000000..2894cd3
--- /dev/null
+++ b/test/functional/system_messages_controller_test.rb
@@ -0,0 +1,49 @@
+require 'test_helper'
+
+class SystemMessagesControllerTest < ActionController::TestCase
+ setup do
+ @system_message = system_messages(:one)
+ end
+
+ test "should get index" do
+ get :index
+ assert_response :success
+ assert_not_nil assigns(:system_messages)
+ end
+
+ test "should get new" do
+ get :new
+ assert_response :success
+ end
+
+ test "should create system_message" do
+ assert_difference('SystemMessage.count') do
+ post :create, system_message: @system_message.attributes
+ end
+
+ assert_redirected_to system_message_path(assigns(:system_message))
+ end
+
+ test "should show system_message" do
+ get :show, id: @system_message.to_param
+ assert_response :success
+ end
+
+ test "should get edit" do
+ get :edit, id: @system_message.to_param
+ assert_response :success
+ end
+
+ test "should update system_message" do
+ put :update, id: @system_message.to_param, system_message: @system_message.attributes
+ assert_redirected_to system_message_path(assigns(:system_message))
+ end
+
+ test "should destroy system_message" do
+ assert_difference('SystemMessage.count', -1) do
+ delete :destroy, id: @system_message.to_param
+ end
+
+ assert_redirected_to system_messages_path
+ end
+end
diff --git a/test/functional/tenants_controller_test.rb b/test/functional/tenants_controller_test.rb
new file mode 100644
index 0000000..b4e2df4
--- /dev/null
+++ b/test/functional/tenants_controller_test.rb
@@ -0,0 +1,51 @@
+require 'test_helper'
+
+class TenantsControllerTest < ActionController::TestCase
+ # TODO Create tests which test that a login user has specific rights.
+
+ # setup do
+ # @tenant = Factory.create(:tenant)
+ # end
+ #
+ # test "should get index" do
+ # get :index
+ # assert_response :success
+ # assert_not_nil assigns(:tenants)
+ # end
+ #
+ # test "should get new" do
+ # get :new
+ # assert_response :success
+ # end
+ #
+ # test "should create tenant" do
+ # assert_difference('Tenant.count') do
+ # post :create, tenant: Factory.build(:tenant).attributes
+ # end
+ #
+ # assert_redirected_to tenant_path(assigns(:tenant))
+ # end
+ #
+ # test "should show tenant" do
+ # get :show, id: @tenant.to_param
+ # assert_response :success
+ # end
+ #
+ # test "should get edit" do
+ # get :edit, id: @tenant.to_param
+ # assert_response :success
+ # end
+ #
+ # test "should update tenant" do
+ # put :update, id: @tenant.to_param, tenant: @tenant.attributes
+ # assert_redirected_to tenant_path(assigns(:tenant))
+ # end
+ #
+ # test "should destroy tenant" do
+ # assert_difference('Tenant.count', -1) do
+ # delete :destroy, id: @tenant.to_param
+ # end
+ #
+ # assert_redirected_to tenants_path
+ # end
+end
diff --git a/test/functional/user_groups_controller_test.rb b/test/functional/user_groups_controller_test.rb
new file mode 100644
index 0000000..0e39048
--- /dev/null
+++ b/test/functional/user_groups_controller_test.rb
@@ -0,0 +1,51 @@
+require 'test_helper'
+
+class UserGroupsControllerTest < ActionController::TestCase
+ # TODO Create tests which test that a login user has specific rights.
+
+ # setup do
+ # @user_group = Factory.create(:user_group)
+ # end
+ #
+ # test "should get index" do
+ # get :index
+ # assert_response :success
+ # assert_not_nil assigns(:user_groups)
+ # end
+ #
+ # test "should get new" do
+ # get :new
+ # assert_response :success
+ # end
+ #
+ # test "should create user_group" do
+ # assert_difference('UserGroup.count') do
+ # post :create, user_group: Factory.build(:user_group).attributes
+ # end
+ #
+ # assert_redirected_to user_group_path(assigns(:user_group))
+ # end
+ #
+ # test "should show user_group" do
+ # get :show, id: @user_group.to_param
+ # assert_response :success
+ # end
+ #
+ # test "should get edit" do
+ # get :edit, id: @user_group.to_param
+ # assert_response :success
+ # end
+ #
+ # test "should update user_group" do
+ # put :update, id: @user_group.to_param, user_group: @user_group.attributes
+ # assert_redirected_to user_group_path(assigns(:user_group))
+ # end
+ #
+ # test "should destroy user_group" do
+ # assert_difference('UserGroup.count', -1) do
+ # delete :destroy, id: @user_group.to_param
+ # end
+ #
+ # assert_redirected_to user_groups_path
+ # end
+end
diff --git a/test/functional/users_controller_test.rb b/test/functional/users_controller_test.rb
new file mode 100644
index 0000000..d1898f7
--- /dev/null
+++ b/test/functional/users_controller_test.rb
@@ -0,0 +1,65 @@
+require 'test_helper'
+
+class UsersControllerTest < ActionController::TestCase
+ setup do
+ @tenant = Factory.create(:tenant)
+ @user = Factory.create(:user)
+
+ @tenant.tenant_memberships.create(:user_id => @user.id)
+
+ @user.update_attributes!(:current_tenant_id => @tenant.id)
+
+ @expected_status_if_not_authorized = :redirect
+ end
+
+ test "should get index" do
+ session[:user_id] = @user.id
+ get :index
+ assert_response :success
+ assert_not_nil assigns(:users)
+ end
+
+ test "should get new" do
+ session[:user_id] = nil
+ get :new
+ assert_response :success
+ end
+
+ # TODO Fix Test
+ #
+ # test "should create user" do
+ # session[:user_id] = nil
+ # assert_difference('User.count') do
+ # post :create, user: Factory.build(:user).attributes
+ # end
+ #
+ # # assert_redirected_to user_path(assigns(:user))
+ # end
+
+ test "should show user" do
+ session[:user_id] = @user.id
+ get :show, id: @user.to_param
+ assert_response :success
+ end
+
+
+ test "should get edit" do
+ session[:user_id] = @user.id
+ get :edit, id: @user.to_param
+ assert_response :success
+ end
+
+ test "should update user" do
+ session[:user_id] = @user.id
+ put :update, id: @user.to_param, user: @user.attributes
+ assert_redirected_to user_path(assigns(:user))
+ end
+
+ test "should not destroy itself" do
+ assert_no_difference('User.count') do
+ delete :destroy, id: @user.to_param
+ end
+
+# assert_redirected_to users_path
+ end
+end
diff --git a/test/functional/whitelists_controller_test.rb b/test/functional/whitelists_controller_test.rb
new file mode 100644
index 0000000..842069f
--- /dev/null
+++ b/test/functional/whitelists_controller_test.rb
@@ -0,0 +1,49 @@
+require 'test_helper'
+
+class WhitelistsControllerTest < ActionController::TestCase
+ setup do
+ @whitelist = whitelists(:one)
+ end
+
+ test "should get index" do
+ get :index
+ assert_response :success
+ assert_not_nil assigns(:whitelists)
+ end
+
+ test "should get new" do
+ get :new
+ assert_response :success
+ end
+
+ test "should create whitelist" do
+ assert_difference('Whitelist.count') do
+ post :create, whitelist: @whitelist.attributes
+ end
+
+ assert_redirected_to whitelist_path(assigns(:whitelist))
+ end
+
+ test "should show whitelist" do
+ get :show, id: @whitelist.to_param
+ assert_response :success
+ end
+
+ test "should get edit" do
+ get :edit, id: @whitelist.to_param
+ assert_response :success
+ end
+
+ test "should update whitelist" do
+ put :update, id: @whitelist.to_param, whitelist: @whitelist.attributes
+ assert_redirected_to whitelist_path(assigns(:whitelist))
+ end
+
+ test "should destroy whitelist" do
+ assert_difference('Whitelist.count', -1) do
+ delete :destroy, id: @whitelist.to_param
+ end
+
+ assert_redirected_to whitelists_path
+ end
+end
diff --git a/test/integration/.gitkeep b/test/integration/.gitkeep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/integration/.gitkeep
diff --git a/test/performance/browsing_test.rb b/test/performance/browsing_test.rb
new file mode 100644
index 0000000..3fea27b
--- /dev/null
+++ b/test/performance/browsing_test.rb
@@ -0,0 +1,12 @@
+require 'test_helper'
+require 'rails/performance_test_help'
+
+class BrowsingTest < ActionDispatch::PerformanceTest
+ # Refer to the documentation for all available options
+ # self.profile_options = { :runs => 5, :metrics => [:wall_time, :memory]
+ # :output => 'tmp/performance', :formats => [:flat] }
+
+ def test_homepage
+ get '/'
+ end
+end
diff --git a/test/test_helper.rb b/test/test_helper.rb
new file mode 100644
index 0000000..b6836c0
--- /dev/null
+++ b/test/test_helper.rb
@@ -0,0 +1,13 @@
+ENV["RAILS_ENV"] = "test"
+require File.expand_path('../../config/environment', __FILE__)
+require 'rails/test_help'
+
+class ActiveSupport::TestCase
+ # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
+ #
+ # Note: You'll currently still have to declare fixtures explicitly in integration tests
+ # -- they do not yet inherit this setting
+ # fixtures :all
+
+ # Add more helper methods to be used by all tests here...
+end
diff --git a/test/unit/.gitkeep b/test/unit/.gitkeep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/unit/.gitkeep
diff --git a/test/unit/access_authorization_test.rb b/test/unit/access_authorization_test.rb
new file mode 100644
index 0000000..ebd9f0b
--- /dev/null
+++ b/test/unit/access_authorization_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class AccessAuthorizationTest < ActiveSupport::TestCase
+ # def test_should_be_valid
+ # assert AccessAuthorization.new.valid?
+ # end
+end
diff --git a/test/unit/acd_agent_test.rb b/test/unit/acd_agent_test.rb
new file mode 100644
index 0000000..9e1a116
--- /dev/null
+++ b/test/unit/acd_agent_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class AcdAgentTest < ActiveSupport::TestCase
+ def test_should_be_valid
+ assert AcdAgent.new.valid?
+ end
+end
diff --git a/test/unit/acd_caller_test.rb b/test/unit/acd_caller_test.rb
new file mode 100644
index 0000000..68d5801
--- /dev/null
+++ b/test/unit/acd_caller_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class AcdCallerTest < ActiveSupport::TestCase
+ def test_should_be_valid
+ assert AcdCaller.new.valid?
+ end
+end
diff --git a/test/unit/address_test.rb b/test/unit/address_test.rb
new file mode 100644
index 0000000..6d676ba
--- /dev/null
+++ b/test/unit/address_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class AddressTest < ActiveSupport::TestCase
+ def test_should_be_valid
+ assert Address.new.valid?
+ end
+end
diff --git a/test/unit/api/row_test.rb b/test/unit/api/row_test.rb
new file mode 100644
index 0000000..dc21050
--- /dev/null
+++ b/test/unit/api/row_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class Api::RowTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/test/unit/area_code_test.rb b/test/unit/area_code_test.rb
new file mode 100644
index 0000000..10c7c08
--- /dev/null
+++ b/test/unit/area_code_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class AreaCodeTest < ActiveSupport::TestCase
+ def test_should_have_a_valid_factory
+ assert Factory.build(:area_code).valid?
+ end
+end
diff --git a/test/unit/automatic_call_distributor_test.rb b/test/unit/automatic_call_distributor_test.rb
new file mode 100644
index 0000000..b025df8
--- /dev/null
+++ b/test/unit/automatic_call_distributor_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class AutomaticCallDistributorTest < ActiveSupport::TestCase
+ def test_should_be_valid
+ assert AutomaticCallDistributor.new.valid?
+ end
+end
diff --git a/test/unit/call_forward_case_test.rb b/test/unit/call_forward_case_test.rb
new file mode 100644
index 0000000..0d1d238
--- /dev/null
+++ b/test/unit/call_forward_case_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class CallForwardCaseTest < ActiveSupport::TestCase
+
+ # Cannot be factory'd. CallForwardCases are seeded.
+
+end
diff --git a/test/unit/call_forward_test.rb b/test/unit/call_forward_test.rb
new file mode 100644
index 0000000..95716c5
--- /dev/null
+++ b/test/unit/call_forward_test.rb
@@ -0,0 +1,9 @@
+require 'test_helper'
+
+class CallForwardTest < ActiveSupport::TestCase
+
+ test "should have a valid factory" do
+ assert Factory.build(:call_forward).valid?
+ end
+
+end
diff --git a/test/unit/callthrough_test.rb b/test/unit/callthrough_test.rb
new file mode 100644
index 0000000..c1c6ab3
--- /dev/null
+++ b/test/unit/callthrough_test.rb
@@ -0,0 +1,134 @@
+require 'test_helper'
+
+class CallthroughTest < ActiveSupport::TestCase
+ def setup
+ # Basic setup of a new system
+ #
+ germany = Country.create(:name => "Germany", :country_code => "49", :international_call_prefix => "00", :trunk_prefix => "0" )
+ Language.create(:name => 'Deutsch', :code => 'de')
+ AreaCode.create(:country => germany, :name => "Bendorf", :area_code => "2622")
+
+ @gemeinschaft_setup = GemeinschaftSetup.new
+ @gemeinschaft_setup.country = Country.first
+ @gemeinschaft_setup.language = Language.first
+
+ @current_user = @gemeinschaft_setup.build_user(
+ :user_name => I18n.t('gemeinschaft_setups.initial_setup.admin_name'),
+ :male => true,
+ :email => 'admin@localhost',
+ :first_name => 'Max',
+ :last_name => 'Mustermann',
+ :password => 'xxxxxxxxxx',
+ :password_confirmation => 'xxxxxxxxxx',
+ :language_id => Language.first.id,
+ )
+ @sip_domain = @gemeinschaft_setup.build_sip_domain(
+ :host => '10.0.0.1',
+ :realm => '10.0.0.1',
+ )
+
+ @gemeinschaft_setup.save
+
+ super_tenant = Tenant.create(
+ :name => SUPER_TENANT_NAME,
+ :country_id => @gemeinschaft_setup.country.id,
+ :language_id => @gemeinschaft_setup.language_id,
+ :description => I18n.t('gemeinschaft_setups.initial_setup.super_tenant_description'),
+ )
+
+ # Admin
+ super_tenant.tenant_memberships.create(:user_id => @gemeinschaft_setup.user.id)
+
+ # Create the Super-Tenant's group:
+ super_tenant_super_admin_group = super_tenant.user_groups.create(:name => I18n.t('gemeinschaft_setups.initial_setup.super_admin_group_name'))
+ super_tenant_super_admin_group.user_group_memberships.create(:user_id => @gemeinschaft_setup.user.id)
+
+ # Create the tenant.
+ #
+ @tenant = @sip_domain.tenants.build(:name => 'AMOOMA GmbH')
+ @tenant.country = Country.first
+ @tenant.language = Language.first
+ @tenant.internal_extension_ranges = '10-20'
+ @tenant.did_list = '02622-70648-x, 02622-706480'
+ @tenant.save
+
+ @tenant.tenant_memberships.create(:user_id => @current_user.id)
+ @current_user.update_attributes!(:current_tenant_id => @tenant.id)
+
+ # The first user becomes a member of the 'admin' UserGroup
+ #
+ admin_group = @tenant.user_groups.create(:name => I18n.t('gemeinschaft_setups.initial_setup.admin_group_name'))
+ admin_group.users << @current_user
+
+ # User group
+ #
+ user_group = @tenant.user_groups.create(:name => I18n.t('gemeinschaft_setups.initial_setup.user_group_name'))
+ user_group.users << @current_user
+
+ # Generate the internal_extensions
+ #
+ @tenant.generate_internal_extensions
+
+ # Generate the external numbers (DIDs)
+ #
+ @tenant.generate_dids
+ end
+
+ test 'the setup should create a valid system' do
+ # Basics
+ #
+ assert_equal 1, Country.count
+ assert_equal 1, Language.count
+
+ # Testing the installation
+ #
+ assert @gemeinschaft_setup.valid?
+ assert @sip_domain.valid?
+ assert @current_user.valid?
+
+ assert @tenant.valid?
+
+ assert_equal 0, SipAccount.count
+ assert_equal 2, Tenant.count
+ assert_equal 1, User.count
+
+ # Check the amount of phone_numbers
+ #
+ assert_equal 11, @tenant.phone_number_ranges.find_by_name(INTERNAL_EXTENSIONS).phone_numbers.count
+ assert_equal 12, @tenant.phone_number_ranges.find_by_name(DIRECT_INWARD_DIALING_NUMBERS).phone_numbers.count
+ end
+
+ test 'that a callthrough can only be created with at least one DID' do
+ assert_equal 0, Callthrough.count
+
+ did = @tenant.phone_number_ranges.find_by_name(DIRECT_INWARD_DIALING_NUMBERS).phone_numbers.first
+
+ callthrough = @tenant.callthroughs.build
+
+ assert !callthrough.valid?
+
+ callthrough.phone_numbers.build(:number => did.number)
+
+ assert callthrough.save
+ assert_equal 1, Callthrough.count
+ end
+
+ # TODO Activate this after fixing unique phone_number
+ #
+ # test 'that one DID can not be used by two different callthroughs' do
+ # assert_equal 0, Callthrough.count
+
+ # did = @tenant.phone_number_ranges.find_by_name(DIRECT_INWARD_DIALING_NUMBERS).phone_numbers.first
+
+ # callthroughs = Array.new
+ # (1..2).each do |i|
+ # callthroughs[i] = @tenant.callthroughs.build
+ # callthroughs[i].phone_numbers.build(:number => did.number)
+ # callthroughs[i].save
+ # end
+
+ # assert callthroughs[1].valid?, '1st Callthrough is not valid'
+ # assert !callthroughs[2].valid?, '2nd Callthrough is not valid'
+ # end
+
+end
diff --git a/test/unit/conference_invitee_test.rb b/test/unit/conference_invitee_test.rb
new file mode 100644
index 0000000..bcc4c9b
--- /dev/null
+++ b/test/unit/conference_invitee_test.rb
@@ -0,0 +1,17 @@
+require 'test_helper'
+
+class ConferenceInviteeTest < ActiveSupport::TestCase
+
+ def test_should_have_a_valid_factory
+ assert Factory.build(:conference_invitee).valid?
+ end
+
+ test "parent conference should not have a phone number twice" do
+ invitee = Factory.create(:conference_invitee)
+ conference = invitee.conference
+ phone_number = PhoneNumber.new(:number => invitee.phone_number.number)
+ invitee_bad = conference.conference_invitees.build(:phone_number => phone_number)
+ assert !invitee_bad.valid?
+ end
+
+end
diff --git a/test/unit/conference_test.rb b/test/unit/conference_test.rb
new file mode 100644
index 0000000..b7cce28
--- /dev/null
+++ b/test/unit/conference_test.rb
@@ -0,0 +1,48 @@
+require 'test_helper'
+
+class ConferenceTest < ActiveSupport::TestCase
+
+ def test_should_have_a_valid_factory
+ assert Factory.build(:conference).valid?
+ end
+
+ def test_dates_must_make_sense
+ # We can't create a conference in the past.
+ assert !Factory.build(:conference, :start => Time.now - 1.day, :end => Time.now + 1.day).valid?
+
+ # But we can create a conference which started 2 minutes ago.
+ assert Factory.build(:conference, :start => Time.now - 2.minutes, :end => Time.now + 1.hour).valid?
+
+ # The end must be before the start.
+ assert !Factory.build(:conference, :start => Time.now + 2.day, :end => Time.now + 1.day).valid?
+
+ # No date at all is fine.
+ assert Factory.build(:conference, :start => nil, :end => nil).valid?
+
+ # Just start or just end is not ok.
+ assert !Factory.build(:conference, :start => nil, :end => Time.now + 1.day).valid?
+ assert !Factory.build(:conference, :start => Time.now + 1.day, :end => nil).valid?
+ end
+
+ def test_pin_must_be_nil_or_more_than_6_digits
+ conference = Factory.build(:conference, :pin => nil)
+
+ assert conference.valid?
+
+ (MINIMUM_PIN_LENGTH - 1).times do |i|
+ pin = "#{10**i}"
+ conference.pin = pin
+ assert !conference.valid?
+ end
+
+ conference.pin = "#{10**(MINIMUM_PIN_LENGTH - 1)}"
+ assert conference.valid?
+
+ conference.pin = "-#{10**(MINIMUM_PIN_LENGTH - 1)}"
+ assert !conference.valid?
+
+ conference.pin = 'Teststring'
+ assert !conference.valid?
+ end
+
+end
diff --git a/test/unit/country_test.rb b/test/unit/country_test.rb
new file mode 100644
index 0000000..4933843
--- /dev/null
+++ b/test/unit/country_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class CountryTest < ActiveSupport::TestCase
+ def test_should_have_a_valid_factory
+ assert Factory.build(:country).valid?
+ end
+end
diff --git a/test/unit/dial_in_number_store_test.rb b/test/unit/dial_in_number_store_test.rb
new file mode 100644
index 0000000..d1341f9
--- /dev/null
+++ b/test/unit/dial_in_number_store_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class DialInNumberStoreTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/test/unit/fax_account_test.rb b/test/unit/fax_account_test.rb
new file mode 100644
index 0000000..f4048cb
--- /dev/null
+++ b/test/unit/fax_account_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class FaxAccountTest < ActiveSupport::TestCase
+ # def test_should_be_valid
+ # assert FaxAccount.new.valid?
+ # end
+end
diff --git a/test/unit/fax_document_test.rb b/test/unit/fax_document_test.rb
new file mode 100644
index 0000000..190a953
--- /dev/null
+++ b/test/unit/fax_document_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class FaxDocumentTest < ActiveSupport::TestCase
+ # def test_should_be_valid
+ # assert FaxDocument.new.valid?
+ # end
+end
diff --git a/test/unit/fax_page_test.rb b/test/unit/fax_page_test.rb
new file mode 100644
index 0000000..522ffd5
--- /dev/null
+++ b/test/unit/fax_page_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class FaxPageTest < ActiveSupport::TestCase
+ # def test_should_be_valid
+ # assert FaxPage.new.valid?
+ # end
+end
diff --git a/test/unit/fax_resolution_test.rb b/test/unit/fax_resolution_test.rb
new file mode 100644
index 0000000..93676af
--- /dev/null
+++ b/test/unit/fax_resolution_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class FaxResolutionTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/test/unit/fax_thumbnail_test.rb b/test/unit/fax_thumbnail_test.rb
new file mode 100644
index 0000000..4fc5bc8
--- /dev/null
+++ b/test/unit/fax_thumbnail_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class FaxThumbnailTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/test/unit/gemeinschaft_setup_test.rb b/test/unit/gemeinschaft_setup_test.rb
new file mode 100644
index 0000000..5ea6523
--- /dev/null
+++ b/test/unit/gemeinschaft_setup_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class GemeinschaftSetupTest < ActiveSupport::TestCase
+ def test_should_have_a_valid_factory
+ assert Factory.build(:gemeinschaft_setup).valid?
+ end
+end
diff --git a/test/unit/gs_cluster_sync_log_entry_test.rb b/test/unit/gs_cluster_sync_log_entry_test.rb
new file mode 100644
index 0000000..bff49e9
--- /dev/null
+++ b/test/unit/gs_cluster_sync_log_entry_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class GsClusterSyncLogEntryTest < ActiveSupport::TestCase
+ def test_should_be_valid
+ assert GsClusterSyncLogEntry.new.valid?
+ end
+end
diff --git a/test/unit/gs_node_test.rb b/test/unit/gs_node_test.rb
new file mode 100644
index 0000000..1155cab
--- /dev/null
+++ b/test/unit/gs_node_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class GsNodeTest < ActiveSupport::TestCase
+ def test_should_be_valid
+ assert GsNode.new.valid?
+ end
+end
diff --git a/test/unit/gui_function_membership_test.rb b/test/unit/gui_function_membership_test.rb
new file mode 100644
index 0000000..c85ec68
--- /dev/null
+++ b/test/unit/gui_function_membership_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class GuiFunctionMembershipTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/test/unit/gui_function_test.rb b/test/unit/gui_function_test.rb
new file mode 100644
index 0000000..60bce1d
--- /dev/null
+++ b/test/unit/gui_function_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class GuiFunctionTest < ActiveSupport::TestCase
+ def test_should_be_valid
+ assert GuiFunction.new.valid?
+ end
+end
diff --git a/test/unit/helpers/api/rows_helper_test.rb b/test/unit/helpers/api/rows_helper_test.rb
new file mode 100644
index 0000000..16c8fe7
--- /dev/null
+++ b/test/unit/helpers/api/rows_helper_test.rb
@@ -0,0 +1,4 @@
+require 'test_helper'
+
+class Api::RowsHelperTest < ActionView::TestCase
+end
diff --git a/test/unit/helpers/config_siemens_helper_test.rb b/test/unit/helpers/config_siemens_helper_test.rb
new file mode 100644
index 0000000..1afae0d
--- /dev/null
+++ b/test/unit/helpers/config_siemens_helper_test.rb
@@ -0,0 +1,4 @@
+require 'test_helper'
+
+class ConfigSiemensHelperTest < ActionView::TestCase
+end
diff --git a/test/unit/helpers/page_helper_test.rb b/test/unit/helpers/page_helper_test.rb
new file mode 100644
index 0000000..6009662
--- /dev/null
+++ b/test/unit/helpers/page_helper_test.rb
@@ -0,0 +1,4 @@
+require 'test_helper'
+
+class PageHelperTest < ActionView::TestCase
+end
diff --git a/test/unit/helpers/sessions_helper_test.rb b/test/unit/helpers/sessions_helper_test.rb
new file mode 100644
index 0000000..7d44e09
--- /dev/null
+++ b/test/unit/helpers/sessions_helper_test.rb
@@ -0,0 +1,4 @@
+require 'test_helper'
+
+class SessionsHelperTest < ActionView::TestCase
+end
diff --git a/test/unit/hunt_group_member_test.rb b/test/unit/hunt_group_member_test.rb
new file mode 100644
index 0000000..4472cc2
--- /dev/null
+++ b/test/unit/hunt_group_member_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class HuntGroupMemberTest < ActiveSupport::TestCase
+ # def test_should_be_valid
+ # assert HuntGroupMember.new.valid?
+ # end
+end
diff --git a/test/unit/hunt_group_test.rb b/test/unit/hunt_group_test.rb
new file mode 100644
index 0000000..5ef843b
--- /dev/null
+++ b/test/unit/hunt_group_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class HuntGroupTest < ActiveSupport::TestCase
+ # def test_should_be_valid
+ # assert HuntGroup.new.valid?
+ # end
+end
diff --git a/test/unit/language_test.rb b/test/unit/language_test.rb
new file mode 100644
index 0000000..3308735
--- /dev/null
+++ b/test/unit/language_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class LanguageTest < ActiveSupport::TestCase
+ test "has a valid factory" do
+ assert Factory.build(:language).valid?
+ end
+end
diff --git a/test/unit/manufacturer_test.rb b/test/unit/manufacturer_test.rb
new file mode 100644
index 0000000..635a977
--- /dev/null
+++ b/test/unit/manufacturer_test.rb
@@ -0,0 +1,27 @@
+require 'test_helper'
+
+class ManufacturerTest < ActiveSupport::TestCase
+ def test_should_have_a_valid_factory
+ assert Factory.build(:manufacturer).valid?
+ end
+
+ # StateMachine Tests:
+ def test_that_the_initial_state_should_be_active
+ @manufacturer = Factory.create(:manufacturer)
+ assert_equal 'active', @manufacturer.state
+ assert @manufacturer.active?
+ end
+
+ def test_not_active_state_will_not_be_displayed
+ @manufacturer = Factory.create(:manufacturer)
+ assert_equal 1, Manufacturer.count
+
+ @manufacturer.deactivate!
+ assert_equal 0, Manufacturer.count
+ assert_equal 1, Manufacturer.unscoped.count
+
+ @manufacturer.activate!
+ assert_equal 1, Manufacturer.count
+ assert_equal Manufacturer.count, Manufacturer.unscoped.count
+ end
+end
diff --git a/test/unit/oui_test.rb b/test/unit/oui_test.rb
new file mode 100644
index 0000000..de48a97
--- /dev/null
+++ b/test/unit/oui_test.rb
@@ -0,0 +1,14 @@
+require 'test_helper'
+
+class OuiTest < ActiveSupport::TestCase
+ def test_should_have_a_valid_factory
+ assert Factory.build(:oui).valid?
+ end
+
+ def test_that_the_initial_state_should_be_active
+ @oui = Factory.create(:oui)
+ assert_equal 'active', @oui.state
+ assert @oui.active?
+ end
+
+end
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
diff --git a/test/unit/phone_book_test.rb b/test/unit/phone_book_test.rb
new file mode 100644
index 0000000..7db48f8
--- /dev/null
+++ b/test/unit/phone_book_test.rb
@@ -0,0 +1,119 @@
+require 'test_helper'
+
+class PhoneBookTest < ActiveSupport::TestCase
+ def test_should_have_a_valid_factory
+ assert Factory.build(:phone_book).valid?
+ end
+
+ def test_should_have_unique_name_depending_on_type
+ user1 = Factory.create(:user)
+ user2 = Factory.create(:user)
+ tenant = Factory.create(:tenant)
+
+ phonebook = Factory.create(:phone_book, :phone_bookable => user1)
+ assert !user1.phone_books.build(:name => phonebook.name).valid?
+ assert user2.phone_books.build(:name => phonebook.name).valid?
+ assert tenant.phone_books.build(:name => phonebook.name).valid?
+ end
+
+ # TODO Create a real system for the phone_book tests and than test again.
+
+
+ # test "User gets a private phone book with rw rights" do
+ # user = Factory.create(:user)
+ # assert_equal 1, user.phone_books.count
+
+ # phone_book = user.phone_books.first
+
+ # user_ability = Ability.new( user )
+
+ # [ :show, :destroy, :edit ].each { |action|
+ # assert user_ability.can?( action, phone_book ), "should be able to #{action}"
+ # }
+
+ # # Lets test some stuff about the phone_book_entries
+ # assert_equal 0, phone_book.phone_book_entries.count
+
+ # entry1 = Factory.create(:phone_book_entry, :phone_book_id => phone_book.id)
+ # entry2 = Factory.create(:phone_book_entry, :phone_book_id => phone_book.id)
+ # entry3 = Factory.create(:phone_book_entry, :phone_book_id => phone_book.id)
+ # assert_equal 3, phone_book.phone_book_entries.count
+
+ # assert_equal 1, PhoneBookEntry.where(:id => entry1.id).count
+ # assert_equal 1, PhoneBookEntry.where(:id => entry2.id).count
+ # assert_equal 1, PhoneBookEntry.where(:id => entry3.id).count
+ # user.phone_books.first.destroy
+ # assert_equal 0, user.phone_books.count
+ # assert_equal 0, PhoneBookEntry.where(:id => entry1.id).count
+ # assert_equal 0, PhoneBookEntry.where(:id => entry2.id).count
+ # assert_equal 0, PhoneBookEntry.where(:id => entry3.id).count
+ # end
+
+ test "Tenant gets automatically one phone book and can destroy it" do
+ tenant = Factory.create(:tenant)
+ assert_equal 1, tenant.phone_books.count
+ tenant.phone_books.first.destroy
+ assert_equal 0, tenant.phone_books.count
+ end
+
+ # test "only tenant members can read a tenant phone book" do
+ # tenant = Factory.create(:tenant)
+ # user = Factory.create(:user)
+ # tenant.users << user
+ # tenant.save
+ # user.current_tenant = tenant
+ # user.save
+ # phone_book = Factory.create(:phone_book, :phone_bookable_type => 'Tenant', :phone_bookable_id => tenant.id)
+
+ # evil_user = Factory.create(:user)
+
+ # user_ability = Ability.new( user )
+ # evil_user_ability = Ability.new( evil_user )
+
+ # [ :show ].each { |action|
+ # assert user_ability.can?( action, phone_book ), "should be able to #{action}"
+ # assert evil_user_ability.cannot?( action, phone_book ), "should not be able to #{action}"
+ # }
+ # end
+
+
+
+ # test "tenant's phone book can not be edited by tenant members" do
+ # tenant = Factory.create(:tenant)
+ # user = Factory.create(:user)
+ # tenant.users << user
+ # phone_book = Factory.create(:phone_book, :phone_bookable_type => 'Tenant', :phone_bookable_id => tenant.id)
+
+ # evil_user = Factory.create(:user)
+
+ # user_ability = Ability.new( user )
+ # evil_user_ability = Ability.new( evil_user )
+
+ # [ :edit, :destroy ].each { |action|
+ # assert user_ability.cannot?( action, phone_book ), "should not be able to #{action}"
+ # assert evil_user_ability.cannot?( action, phone_book ), "should not be able to #{action}"
+ # }
+ # end
+
+ # test "only user can manage his private phone book after creating it" do
+ # user = Factory.create(:user)
+ # phone_book = Factory.create(:phone_book, :phone_bookable_type => 'User', :phone_bookable_id => user.id)
+
+ # evil_user = Factory.create(:user)
+
+ # user_ability = Ability.new( user )
+ # evil_user_ability = Ability.new( evil_user )
+
+ # [ :show, :destroy, :edit ].each { |action|
+ # assert user_ability.can?( action, phone_book ), "should be able to #{action}"
+ # assert evil_user_ability.cannot?( action, phone_book ), "should not be able to #{action}"
+ # }
+ # end
+
+ def test_that_the_initial_state_should_be_active
+ @phone_book = Factory.create(:phone_book)
+ assert_equal 'active', @phone_book.state
+ assert @phone_book.active?
+ end
+
+end
diff --git a/test/unit/phone_model_test.rb b/test/unit/phone_model_test.rb
new file mode 100644
index 0000000..e358cf9
--- /dev/null
+++ b/test/unit/phone_model_test.rb
@@ -0,0 +1,9 @@
+require 'test_helper'
+
+class PhoneModelTest < ActiveSupport::TestCase
+
+ def test_should_have_a_valid_factory
+ assert Factory.build(:phone_model).valid?
+ end
+
+end
diff --git a/test/unit/phone_number_range_test.rb b/test/unit/phone_number_range_test.rb
new file mode 100644
index 0000000..1770299
--- /dev/null
+++ b/test/unit/phone_number_range_test.rb
@@ -0,0 +1,9 @@
+require 'test_helper'
+
+class PhoneNumberRangeTest < ActiveSupport::TestCase
+
+ def test_should_have_a_valid_factory
+ assert Factory.build(:phone_number_range).valid?
+ end
+
+end
diff --git a/test/unit/phone_number_test.rb b/test/unit/phone_number_test.rb
new file mode 100644
index 0000000..e10b20c
--- /dev/null
+++ b/test/unit/phone_number_test.rb
@@ -0,0 +1,260 @@
+# ruby coding: utf-8
+
+require 'test_helper'
+
+class PhoneNumberTest < ActiveSupport::TestCase
+
+ test "should have valid factory" do
+ assert Factory.build(:phone_number).valid?
+ end
+
+ def test_that_the_initial_state_should_be_active
+ @phone_number = Factory.create(:phone_number)
+ assert_equal 'active', @phone_number.state
+ assert @phone_number.active?
+ end
+
+ test "that the value_of_to_s field is filled" do
+ phone_number = Factory.create(:phone_number)
+ assert_equal phone_number.value_of_to_s, phone_number.to_s
+ end
+
+ {
+ '+492612000' => {
+ :country_code => "49",
+ :area_code => "261",
+ :central_office_code => nil,
+ :subscriber_number => "2000",
+ :extension => nil,
+ },
+ '+49 261 2000' => {
+ :country_code => "49",
+ :area_code => "261",
+ :central_office_code => nil,
+ :subscriber_number => "2000",
+ :extension => nil,
+ },
+ '+49-261-2000' => {
+ :country_code => "49",
+ :area_code => "261",
+ :central_office_code => nil,
+ :subscriber_number => "2000",
+ :extension => nil,
+ },
+ '492612000' => {
+ :country_code => "49",
+ :area_code => "261",
+ :central_office_code => nil,
+ :subscriber_number => "2000",
+ :extension => nil,
+ },
+ '49888888882000' => nil, # unknown area code
+ '552612000' => nil, # unknown country code
+ '15551234567' => {
+ :country_code => "1",
+ :area_code => "555",
+ :central_office_code => "123",
+ :subscriber_number => "4567",
+ :extension => nil,
+ },
+ '2612000' => nil, # not an international number
+ '02612000' => nil, # not an international number
+ '00492612000' => nil, # invalid format
+ '2000' => nil,
+ '' => nil,
+ nil => nil,
+ '++++' => nil,
+ '###' => nil,
+ 'äöü' => nil,
+ false => nil,
+ true => nil, # true.to_s == "true" # invalid number
+ }.each_pair do |number, expected|
+ test "should parse number #{number.inspect} correctly" do
+ # load some country codes:
+ usa = Country.create(:name => "United States of America", :country_code => "1", :international_call_prefix => "011", :trunk_prefix => "1" )
+ germany = Country.create(:name => "Germany", :country_code => "49", :international_call_prefix => "00", :trunk_prefix => "0" )
+ cuba = Country.create(:name => "Cuba", :country_code => "53", :international_call_prefix => "119", :trunk_prefix => "" )
+ # load some area codes:
+ AreaCode.create(:country => germany, :name => "Koblenz am Rhein", :area_code => "261")
+ AreaCode.create(:country => germany, :name => "Neuwied", :area_code => "2631")
+ AreaCode.create(:country => germany, :name => "Berlin", :area_code => "30")
+ AreaCode.create(:country => germany, :name => "Hamburg", :area_code => "40")
+ AreaCode.create(:country => germany, :name => "Hohenmocker", :area_code => "39993")
+
+ assert_equal expected, PhoneNumber.parse_international_number( number )
+ end
+ end
+
+ {
+ '+492612000' => {
+ :country_code => "49",
+ :area_code => "261",
+ :central_office_code => nil,
+ :subscriber_number => "2000",
+ :extension => nil,
+ },
+ '+49 261 2000' => {
+ :country_code => "49",
+ :area_code => "261",
+ :central_office_code => nil,
+ :subscriber_number => "2000",
+ :extension => nil,
+ },
+ '+49-261-2000' => {
+ :country_code => "49",
+ :area_code => "261",
+ :central_office_code => nil,
+ :subscriber_number => "2000",
+ :extension => nil,
+ },
+ '110' => {
+ :country_code => nil,
+ :area_code => nil,
+ :central_office_code => nil,
+ :subscriber_number => "110",
+ :extension => nil,
+ },
+ '11833' => {
+ :country_code => nil,
+ :area_code => nil,
+ :central_office_code => nil,
+ :subscriber_number => "11833",
+ :extension => nil,
+ },
+ '15551234567' => {
+ :country_code => nil,
+ :area_code => nil,
+ :central_office_code => nil,
+ :subscriber_number => "15551234567",
+ :extension => nil,
+ },
+ '0015551234567' => {
+ :country_code => "1",
+ :area_code => "555",
+ :central_office_code => "123",
+ :subscriber_number => "4567",
+ :extension => nil,
+ },
+ '+15551234567' => {
+ :country_code => "1",
+ :area_code => "555",
+ :central_office_code => "123",
+ :subscriber_number => "4567",
+ :extension => nil,
+ },
+ '02612000' => {
+ :country_code => "49",
+ :area_code => "261",
+ :central_office_code => nil,
+ :subscriber_number => "2000",
+ :extension => nil,
+ },
+ '00492612000' => {
+ :country_code => "49",
+ :area_code => "261",
+ :central_office_code => nil,
+ :subscriber_number => "2000",
+ :extension => nil,
+ },
+ '2000' => {
+ :country_code => nil,
+ :area_code => nil,
+ :central_office_code => nil,
+ :subscriber_number => nil,
+ :extension => "2000",
+ },
+ '99' => {
+ :country_code => nil,
+ :area_code => nil,
+ :central_office_code => nil,
+ :subscriber_number => nil,
+ :extension => "99",
+ },
+ '5' => {
+ :country_code => nil,
+ :area_code => nil,
+ :central_office_code => nil,
+ :subscriber_number => nil,
+ :extension => "5",
+ },
+ '' => nil,
+ nil => nil,
+ '++++' => nil,
+ '###' => nil,
+ 'äöü' => nil,
+ false => nil,
+ true => nil, # true.to_s == "true" # invalid number
+ }.each_pair do |number, expected|
+ test "should parse number #{number.inspect} correctly for a specific tenant" do
+ # load some country codes:
+ usa = Country.create(:name => "United States of America", :country_code => "1", :international_call_prefix => "011", :trunk_prefix => "1" )
+ germany = Country.create(:name => "Germany", :country_code => "49", :international_call_prefix => "00", :trunk_prefix => "0" )
+ cuba = Country.create(:name => "Cuba", :country_code => "53", :international_call_prefix => "119", :trunk_prefix => "" )
+ # load some area codes:
+ AreaCode.create(:country => germany, :name => "Koblenz am Rhein", :area_code => "261")
+ AreaCode.create(:country => germany, :name => "Neuwied", :area_code => "2631")
+ AreaCode.create(:country => germany, :name => "Berlin", :area_code => "30")
+ AreaCode.create(:country => germany, :name => "Hamburg", :area_code => "40")
+ AreaCode.create(:country => germany, :name => "Hohenmocker", :area_code => "39993")
+
+ # create a tenant
+ tenant = Factory.create(:tenant, :country_id => germany.id)
+ # create some extensions
+ internal_extension_range = tenant.phone_number_ranges.create(:name => INTERNAL_EXTENSIONS)
+ ['2000', '2001', '2003', '2004', '2005', '2006', '2007', '2008', '2009', '2010', '5', '99'].each do |extension|
+ internal_extension_range.phone_numbers.create(:name => "Extension #{extension}", :number => extension)
+ end
+
+ assert_equal expected, PhoneNumber.parse( number, tenant )
+ end
+ end
+
+ # TODO: Test uniqueness of a phone_number when creating it.
+
+ # test "has to be unique per sip_account" do
+ # germany = Country.create(:name => "Germany", :country_code => "49", :international_call_prefix => "00", :trunk_prefix => "0" )
+ # Language.create(:name => 'Deutsch', :code => 'de')
+ # AreaCode.create(:country => germany, :name => "Bendorf", :area_code => "2622")
+
+ # @sip_domain = Factory.create(:sip_domain)
+
+ # @tenant = @sip_domain.tenants.build(:name => 'AMOOMA GmbH')
+ # @tenant.country = Country.first
+ # @tenant.language = Language.first
+ # @tenant.internal_extension_ranges = '10-20'
+ # @tenant.save
+
+ # @tenant.generate_internal_extensions
+
+ # sip_account = @tenant.sip_accounts.build(Factory.create(:sip_account).attributes)
+ # phone_number = sip_account.phone_numbers.create(Factory.build(:phone_number, :number => '10').attributes)
+ # phone_number_evil = sip_account.phone_numbers.build(phone_number.attributes)
+
+ # assert phone_number.valid?
+ # assert !phone_number_evil.valid?
+ # end
+
+ # test "has to be unique per SIP domain even for different tenants" do
+ # provider_sip_domain = Factory.create(:sip_domain)
+ # tenants = []
+ # sip_accounts = []
+ # 2.times { |i|
+ # tenants[i] = provider_sip_domain.tenants.create(Factory.build(:tenant, :internal_extension_ranges => '10-20').attributes)
+ # tenants[i].generate_internal_extensions
+
+ # sip_accounts[i] = tenants[i].sip_accounts.build(Factory.build(:sip_account, :tenant_id => tenants[i].id).attributes)
+ # sip_accounts[i].phone_numbers.build(:number => '10')
+ # }
+ # sip_accounts[0].save
+
+ # assert sip_accounts[0].valid?, 'Should be valid.'
+ # assert ! sip_accounts[1].valid?,
+ # "Shouldn't be possible to use the same phone number more than once per SIP domain."
+
+ # # Lets change the second phone_number for a positiv test:
+ # #
+ # sip_accounts[1].phone_numbers.first.number = '11'
+ # assert sip_accounts[1].valid?
+ # end
+
+end
diff --git a/test/unit/phone_sip_account_test.rb b/test/unit/phone_sip_account_test.rb
new file mode 100644
index 0000000..735799e
--- /dev/null
+++ b/test/unit/phone_sip_account_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class PhoneSipAccountTest < ActiveSupport::TestCase
+ # def test_should_be_valid
+ # assert PhoneSipAccount.new.valid?
+ # end
+end
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
diff --git a/test/unit/ringtone_test.rb b/test/unit/ringtone_test.rb
new file mode 100644
index 0000000..dee6002
--- /dev/null
+++ b/test/unit/ringtone_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class RingtoneTest < ActiveSupport::TestCase
+ # def test_should_be_valid
+ # assert Ringtone.new.valid?
+ # end
+end
diff --git a/test/unit/sip_account_test.rb b/test/unit/sip_account_test.rb
new file mode 100644
index 0000000..6595ccc
--- /dev/null
+++ b/test/unit/sip_account_test.rb
@@ -0,0 +1,34 @@
+require 'test_helper'
+
+class SipAccountTest < ActiveSupport::TestCase
+
+ def test_should_have_a_valid_factory
+ assert Factory.build(:sip_account).valid?
+ end
+
+ test "that the value_of_to_s field is filled" do
+ sip_account = Factory.create(:sip_account)
+ assert_equal sip_account.value_of_to_s, sip_account.to_s
+ end
+
+ test "should have a unique auth_name per sip_domain" do
+ provider_sip_domain = Factory.create(:sip_domain)
+ tenants = []
+ sip_accounts = []
+ 2.times { |i|
+ tenants[i] = provider_sip_domain.tenants.create(Factory.build(:tenant).attributes)
+ sip_accounts[i] = Factory.build(
+ :sip_account,
+ :sip_accountable => tenants[i],
+ :auth_name => "somerandomauthname",
+ :tenant_id => tenants[i].id
+ )
+ }
+ sip_accounts[0].save!
+
+ assert sip_accounts[0].valid?
+ assert ! sip_accounts[1].valid?,
+ "Shouldn't be possible to use the same phone number more than once per SIP realm."
+ end
+
+end
diff --git a/test/unit/sip_domain_test.rb b/test/unit/sip_domain_test.rb
new file mode 100644
index 0000000..5d31f69
--- /dev/null
+++ b/test/unit/sip_domain_test.rb
@@ -0,0 +1,9 @@
+require 'test_helper'
+
+class SipDomainTest < ActiveSupport::TestCase
+
+ def test_should_have_a_valid_factory
+ assert Factory.build(:sip_domain).valid?
+ end
+
+end
diff --git a/test/unit/softkey_function_test.rb b/test/unit/softkey_function_test.rb
new file mode 100644
index 0000000..ed63836
--- /dev/null
+++ b/test/unit/softkey_function_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class SoftkeyFunctionTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/test/unit/softkey_test.rb b/test/unit/softkey_test.rb
new file mode 100644
index 0000000..ca173f9
--- /dev/null
+++ b/test/unit/softkey_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class SoftkeyTest < ActiveSupport::TestCase
+ # def test_should_be_valid
+ # assert Softkey.new.valid?
+ # end
+end
diff --git a/test/unit/system_message_test.rb b/test/unit/system_message_test.rb
new file mode 100644
index 0000000..0476ac8
--- /dev/null
+++ b/test/unit/system_message_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class SystemMessageTest < ActiveSupport::TestCase
+ # def test_should_be_valid
+ # assert SystemMessage.new.valid?
+ # end
+end
diff --git a/test/unit/tenant_membership_test.rb b/test/unit/tenant_membership_test.rb
new file mode 100644
index 0000000..8e7a191
--- /dev/null
+++ b/test/unit/tenant_membership_test.rb
@@ -0,0 +1,14 @@
+require 'test_helper'
+
+class TenantMembershipTest < ActiveSupport::TestCase
+ def test_should_have_a_valid_factory
+ assert Factory.build(:tenant_membership).valid?
+ end
+
+ def test_that_the_initial_state_should_be_active
+ @tenant_membership = Factory.create(:tenant_membership)
+ assert_equal 'active', @tenant_membership.state
+ assert @tenant_membership.active?
+ end
+
+end
diff --git a/test/unit/tenant_test.rb b/test/unit/tenant_test.rb
new file mode 100644
index 0000000..4d4abce
--- /dev/null
+++ b/test/unit/tenant_test.rb
@@ -0,0 +1,33 @@
+require 'test_helper'
+
+class TenantTest < ActiveSupport::TestCase
+ def test_should_have_a_valid_factory
+ assert Factory.build(:tenant).valid?
+ end
+
+ def test_should_have_unique_name
+ tenant = Factory.create(:tenant)
+ assert !Factory.build(:tenant, :name => tenant.name).valid?
+ assert Factory.build(:tenant, :name => "different_#{tenant.name}").valid?
+ end
+
+ def test_that_the_initial_state_should_be_active
+ @tenant = Factory.create(:tenant)
+ assert_equal 'active', @tenant.state
+ assert @tenant.active?
+ end
+
+ def test_not_active_state_will_not_be_displayed
+ @tenant = Factory.create(:tenant)
+ assert_equal 1, Tenant.count
+
+ @tenant.deactivate!
+ assert_equal 0, Tenant.count
+ assert_equal 1, Tenant.unscoped.count
+
+ @tenant.activate!
+ assert_equal 1, Tenant.count
+ assert_equal Tenant.count, Tenant.unscoped.count
+ end
+
+end
diff --git a/test/unit/user_group_membership_test.rb b/test/unit/user_group_membership_test.rb
new file mode 100644
index 0000000..251229f
--- /dev/null
+++ b/test/unit/user_group_membership_test.rb
@@ -0,0 +1,39 @@
+require 'test_helper'
+
+class UserGroupMembershipTest < ActiveSupport::TestCase
+ def test_should_have_a_valid_factory
+ assert Factory.build(:user_group_membership).valid?
+ end
+ def test_should_have_unique_members_in_each_group
+ group1 = Factory.create(:user_group)
+ group2 = Factory.create(:user_group)
+ user1 = Factory.create(:user)
+ user2 = Factory.create(:user)
+ member = Factory.create(
+ :user_group_membership,
+ :user_id => user1.id,
+ :user_group_id => group1.id
+ )
+ assert !Factory.build(
+ :user_group_membership,
+ :user_id => user1.id,
+ :user_group_id => group1.id
+ ).valid?
+ assert Factory.build(
+ :user_group_membership,
+ :user_id => user1.id,
+ :user_group_id => group2.id
+ ).valid?
+ assert Factory.build(
+ :user_group_membership,
+ :user_id => user2.id,
+ :user_group_id => group1.id
+ ).valid?
+ end
+
+ def test_that_the_initial_state_should_be_active
+ @user_group_membership = Factory.create(:user_group_membership)
+ assert_equal 'active', @user_group_membership.state
+ assert @user_group_membership.active?
+ end
+end
diff --git a/test/unit/user_group_test.rb b/test/unit/user_group_test.rb
new file mode 100644
index 0000000..5e815a8
--- /dev/null
+++ b/test/unit/user_group_test.rb
@@ -0,0 +1,38 @@
+require 'test_helper'
+
+class UserGroupTest < ActiveSupport::TestCase
+ def test_should_have_a_valid_factory
+ assert Factory.build(:user_group).valid?
+ end
+
+ def test_should_have_unique_name_on_same_tenant
+ tenant1 = Factory.create(:tenant)
+ tenant2 = Factory.create(:tenant)
+ group = Factory.create(:user_group, :tenant_id => tenant1.id)
+ assert !Factory.build(:user_group, :name => group.name, :tenant_id => tenant1.id).valid?
+ assert Factory.build(:user_group, :name => group.name, :tenant_id => tenant2.id).valid?
+ assert Factory.build(:user_group, :name => "different_#{group.name}", :tenant_id => tenant1.id).valid?
+ end
+
+ test "user_group_membership only available for tenant_memberships" do
+ good_tenant = Factory.create(:tenant)
+ evil_tenant = Factory.create(:tenant)
+
+ user = Factory.create(:user)
+ good_tenant.tenant_memberships.create(:user_id => user.id)
+
+ good_user_group = good_tenant.user_groups.create(:name => 'Example')
+ evil_user_group = evil_tenant.user_groups.create(:name => 'Example')
+
+ # Check the basics
+ assert_equal 1, good_tenant.user_groups.count
+ assert_equal 1, evil_tenant.user_groups.count
+ assert_equal 1, good_tenant.users.count
+ assert_equal 0, evil_tenant.users.count
+
+ # Check if the user can become a member
+ assert good_user_group.user_group_memberships.build(:user_id => user.id).valid?
+ assert !evil_user_group.user_group_memberships.build(:user_id => user.id).valid?
+ end
+
+end
diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb
new file mode 100644
index 0000000..bb89e77
--- /dev/null
+++ b/test/unit/user_test.rb
@@ -0,0 +1,82 @@
+require 'test_helper'
+
+class UserTest < ActiveSupport::TestCase
+
+ def test_should_have_a_valid_factory
+ assert Factory.build(:user).valid?
+ end
+
+ def test_should_have_a_unique_email_address
+ user = Factory.create(:user)
+ assert !Factory.build(:user, :email => user.email).valid?
+ assert Factory.build(:user, :email => "different_#{user.email}").valid?
+ end
+
+ def test_can_not_move_to_a_current_tenant_without_a_membership_relation
+ super_tenant = Factory.create(:tenant)
+ good_tenant = Factory.create(:tenant)
+ evil_tenant = Factory.create(:tenant)
+
+ user = Factory.create(:user)
+ super_tenant.tenant_memberships.create(:user_id => user.id)
+ good_tenant.tenant_memberships.create(:user_id => user.id)
+
+ assert user.update_attributes(:current_tenant_id => super_tenant.id)
+ assert !user.update_attributes(:current_tenant_id => evil_tenant.id)
+ assert user.update_attributes(:current_tenant_id => good_tenant.id)
+ end
+
+ test "should be possible to modify the user without changing the PIN" do
+ user = Factory.create(:user)
+ pin_salt = user.pin_salt
+ pin_hash = user.pin_hash
+ user.middle_name = "#{user.middle_name} Foo"
+ assert user.save, "Should be possible to save the user."
+ user = User.where(:id => user.id).first
+ assert user
+ assert_equal pin_salt, user.pin_salt, "PIN salt should not change."
+ assert_equal pin_hash, user.pin_hash, "PIN hash should not change."
+ end
+
+ test "should be possible to change the PIN" do
+ user = Factory.create(:user)
+ pin_salt = user.pin_salt
+ pin_hash = user.pin_hash
+ new_pin = '453267'
+ user.new_pin = new_pin
+ user.new_pin_confirmation = new_pin
+ assert user.save, "Should be possible to save the user."
+ user = User.where(:id => user.id).first
+ assert_not_equal "#{pin_salt}#{pin_hash}", "#{user.pin_salt}#{user.pin_hash}",
+ "PIN salt/hash should have changed."
+ end
+
+ test "should not be possible to change the PIN if the confirmation does not match" do
+ user = Factory.create(:user)
+ pin_salt = user.pin_salt
+ pin_hash = user.pin_hash
+ user.new_pin = '123001'
+ user.new_pin_confirmation = '123002'
+ assert ! user.save, "Should not be possible to save the user."
+ assert ! user.valid?, "Should not be valid."
+ assert user.errors && user.errors.messages
+ assert (
+ (user.errors.messages[:new_pin] && user.errors.messages[:new_pin].length > 0) ||
+ (user.errors.messages[:new_pin_confirmation] && user.errors.messages[:new_pin_confirmation].length > 0)
+ ), "There should be an error message because new_pin != new_pin_confirmation."
+ end
+
+ test "PIN must be numeric" do
+ user = Factory.create(:user)
+ new_pin = 'xxxx'
+ user.new_pin = new_pin
+ user.new_pin_confirmation = new_pin
+ assert ! user.save, "Should not be possible to save the user."
+ assert ! user.valid?, "Should not be valid."
+ assert (
+ (user.errors.messages[:new_pin] && user.errors.messages[:new_pin].length > 0) ||
+ (user.errors.messages[:new_pin_confirmation] && user.errors.messages[:new_pin_confirmation].length > 0)
+ ), "There should be an error message because PIN isn't numeric."
+ end
+
+end
diff --git a/test/unit/whitelist_test.rb b/test/unit/whitelist_test.rb
new file mode 100644
index 0000000..5678bbb
--- /dev/null
+++ b/test/unit/whitelist_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class WhitelistTest < ActiveSupport::TestCase
+ def test_should_be_valid
+ assert Whitelist.new.valid?
+ end
+end