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