4 class PdDeclarationsControllerTest < ActionDispatch::IntegrationTest
6 # test all routes which lead to this controller
9 { :path => "/account/pd_declaration", :method => :get },
10 { :controller => "accounts/pd_declarations", :action => "show" }
13 { :path => "/account/pd_declaration", :method => :post },
14 { :controller => "accounts/pd_declarations", :action => "create" }
18 def test_show_not_logged_in
19 get account_pd_declaration_path
21 assert_redirected_to login_path(:referer => account_pd_declaration_path)
28 get account_pd_declaration_path
30 assert_response :success
33 def test_create_not_logged_in
34 post account_pd_declaration_path
36 assert_response :forbidden
39 def test_create_unconfirmed
43 post account_pd_declaration_path
45 assert_redirected_to edit_account_path
46 assert_nil flash[:notice]
47 assert_equal "You didn't confirm that you consider your edits to be in the Public Domain.", flash[:warning]
50 assert_not_predicate user, :consider_pd
53 def test_create_confirmed
57 post account_pd_declaration_path, :params => { :consider_pd => true }
59 assert_equal "You have successfully declared that you consider your edits to be in the Public Domain.", flash[:notice]
60 assert_nil flash[:warning]
63 assert_predicate user, :consider_pd
66 def test_create_already_declared_unconfirmed
67 user = create(:user, :consider_pd => true)
70 post account_pd_declaration_path
72 assert_nil flash[:notice]
73 assert_equal "You have already declared that you consider your edits to be in the Public Domain.", flash[:warning]
76 assert_predicate user, :consider_pd
79 def test_create_already_declared_confirmed
80 user = create(:user, :consider_pd => true)
83 post account_pd_declaration_path, :params => { :consider_pd => true }
85 assert_nil flash[:notice]
86 assert_equal "You have already declared that you consider your edits to be in the Public Domain.", flash[:warning]
89 assert_predicate user, :consider_pd