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