- ##
- # test the inbox action
- def test_inbox
- user = create(:user)
- other_user = create(:user)
- read_message = create(:message, :read, :recipient => user)
- # Check that the inbox page requires us to login
- get :inbox, :params => { :display_name => user.display_name }
- assert_redirected_to login_path(:referer => inbox_path(:display_name => user.display_name))
-
- # Login
- session[:user] = user.id
-
- # Check that we can view our inbox when logged in
- get :inbox, :params => { :display_name => user.display_name }
- assert_response :success
- assert_template "inbox"
- assert_select "table.messages", :count => 1 do
- assert_select "tr", :count => 2
- assert_select "tr#inbox-#{read_message.id}.inbox-row", :count => 1
- end
-
- # Check that we can't view somebody else's inbox when logged in
- get :inbox, :params => { :display_name => other_user.display_name }
- assert_redirected_to inbox_path(:display_name => user.display_name)
- end
-
- ##
- # test the outbox action
- def test_outbox
- user = create(:user)
- other_user = create(:user)
- create(:message, :sender => user)
-
- # Check that the outbox page requires us to login
- get :outbox, :params => { :display_name => user.display_name }
- assert_redirected_to login_path(:referer => outbox_path(:display_name => user.display_name))
-
- # Login
- session[:user] = user.id
-
- # Check that we can view our outbox when logged in
- get :outbox, :params => { :display_name => user.display_name }
- assert_response :success
- assert_template "outbox"
- assert_select "table.messages", :count => 1 do
- assert_select "tr", :count => 2
- assert_select "tr.inbox-row", :count => 1
- end
-
- # Check that we can't view somebody else's outbox when logged in
- get :outbox, :params => { :display_name => other_user.display_name }
- assert_redirected_to outbox_path(:display_name => user.display_name)
- end
-