]> git.openstreetmap.org Git - rails.git/blob - test/controllers/messages/inboxes_controller_test.rb
Add frozen_string_literal comments to ruby files
[rails.git] / test / controllers / messages / inboxes_controller_test.rb
1 # frozen_string_literal: true
2
3 require "test_helper"
4
5 module Messages
6   class InboxesControllerTest < ActionDispatch::IntegrationTest
7     ##
8     # test all routes which lead to this controller
9     def test_routes
10       assert_routing(
11         { :path => "/messages/inbox", :method => :get },
12         { :controller => "messages/inboxes", :action => "show" }
13       )
14     end
15
16     def test_show
17       user = create(:user)
18       read_message = create(:message, :read, :recipient => user)
19
20       session_for(user)
21
22       get messages_inbox_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#inbox-#{read_message.id}", :count => 1 do
27           assert_select "a[href='#{user_path read_message.sender}']", :text => read_message.sender.display_name
28           assert_select "a[href='#{message_path read_message}']", :text => read_message.title
29         end
30       end
31     end
32
33     def test_show_requires_login
34       get messages_inbox_path
35       assert_redirected_to login_path(:referer => messages_inbox_path)
36     end
37   end
38 end