]> git.openstreetmap.org Git - rails.git/blob - test/controllers/accounts/pd_declarations_controller_test.rb
Add pd declaration create action
[rails.git] / test / controllers / accounts / pd_declarations_controller_test.rb
1 require "test_helper"
2
3 module Accounts
4   class PdDeclarationsControllerTest < ActionDispatch::IntegrationTest
5     ##
6     # test all routes which lead to this controller
7     def test_routes
8       assert_routing(
9         { :path => "/account/pd_declaration", :method => :get },
10         { :controller => "accounts/pd_declarations", :action => "show" }
11       )
12       assert_routing(
13         { :path => "/account/pd_declaration", :method => :post },
14         { :controller => "accounts/pd_declarations", :action => "create" }
15       )
16     end
17
18     def test_show_not_logged_in
19       get account_pd_declaration_path
20
21       assert_redirected_to login_path(:referer => account_pd_declaration_path)
22     end
23
24     def test_show_agreed
25       user = create(:user)
26       session_for(user)
27
28       get account_pd_declaration_path
29
30       assert_response :success
31     end
32
33     def test_create_not_logged_in
34       post account_pd_declaration_path
35
36       assert_response :forbidden
37     end
38
39     def test_create
40       user = create(:user)
41       session_for(user)
42
43       post account_pd_declaration_path
44
45       assert_redirected_to edit_account_path
46     end
47   end
48 end