summaryrefslogtreecommitdiff
path: root/test/functional/call_forwards_controller_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/call_forwards_controller_test.rb')
-rw-r--r--test/functional/call_forwards_controller_test.rb91
1 files changed, 91 insertions, 0 deletions
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