]> git.openstreetmap.org Git - rails.git/blob - test/controllers/messages/outboxes_controller_test.rb
Merge pull request #6394 from openstreetmap/dependabot/github_actions/ruby/setup...
[rails.git] / test / controllers / messages / outboxes_controller_test.rb
1 # frozen_string_literal: true
2
3 require "test_helper"
4
5 module Messages
6   class OutboxesControllerTest < ActionDispatch::IntegrationTest
7     ##
8     # test all routes which lead to this controller
9     def test_routes
10       assert_routing(
11         { :path => "/messages/outbox", :method => :get },
12         { :controller => "messages/outboxes", :action => "show" }
13       )
14     end
15
16     def test_show
17       user = create(:user)
18       message = create(:message, :sender => user)
19
20       session_for(user)
21
22       get messages_outbox_path
23       assert_response :success
24       assert_select ".content-inner > table.messages-table > tbody", :count => 1 do
25         assert_select "tr", :count => 1
26         assert_select "tr#outbox-#{message.id}", :count => 1 do
27           assert_select "a[href='#{user_path message.recipient}']", :text => message.recipient.display_name
28           assert_select "a[href='#{message_path message}']", :text => message.title
29         end
30       end
31     end
32
33     def test_show_requires_login
34       get messages_outbox_path
35       assert_redirected_to login_path(:referer => messages_outbox_path)
36     end
37   end
38 end