]> git.openstreetmap.org Git - rails.git/blob - test/controllers/profiles/companies_controller_test.rb
Add frozen_string_literal comments to ruby files
[rails.git] / test / controllers / profiles / companies_controller_test.rb
1 # frozen_string_literal: true
2
3 require "test_helper"
4
5 module Profiles
6   class CompaniesControllerTest < ActionDispatch::IntegrationTest
7     ##
8     # test all routes which lead to this controller
9     def test_routes
10       assert_routing(
11         { :path => "/profile/company", :method => :get },
12         { :controller => "profiles/companies", :action => "show" }
13       )
14       assert_routing(
15         { :path => "/profile/company", :method => :put },
16         { :controller => "profiles/companies", :action => "update" }
17       )
18     end
19
20     def test_show
21       user = create(:user)
22       session_for(user)
23
24       get profile_company_path
25
26       assert_response :success
27       assert_template :show
28     end
29
30     def test_show_unauthorized
31       get profile_company_path
32
33       assert_redirected_to login_path(:referer => profile_company_path)
34     end
35
36     def test_update
37       user = create(:user)
38       session_for(user)
39
40       put profile_company_path, :params => { :user => { :company => "new company", :description => user.description } }
41
42       assert_redirected_to user_path(user)
43       follow_redirect!
44       assert_response :success
45       assert_template :show
46       assert_dom ".alert-success", :text => "Profile company updated."
47
48       user.reload
49       assert_equal "new company", user.company
50     end
51   end
52 end