summaryrefslogtreecommitdiff
path: root/test/functional/call_forwards_controller_test.rb
blob: da8e6c957291a4a02a2faf8d59f56aec3bab635a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
require 'test_helper'

class CallForwardsControllerTest < ActionController::TestCase
  
  setup do
    @user = FactoryGirl.create(:user)
    
    #@tenant = FactoryGirl.create(:tenant)
    #@tenant.tenant_memberships.create(:user_id => @user.id)
    #@user.update_attributes!(:current_tenant_id => @tenant.id)
    
    @sip_account = FactoryGirl.create(
      :sip_account,
      :sip_accountable => @user,
    )
    @user.sip_accounts << @sip_account
    @sip_account = @user.sip_accounts.last
    
    @phone_number = FactoryGirl.create(
      :phone_number,
      :phone_numberable => @sip_account,
    )
    @sip_account.phone_numbers << @phone_number
    @phone_number = @sip_account.phone_numbers.last
    
    @call_forward = FactoryGirl.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 => FactoryGirl.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