File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,8 +3,8 @@ module Validatable
33
44 included do
55 rescue_from ActionController ::InvalidAuthenticityToken do
6- if action_name == ' validate'
7- render json : { valid : false }
6+ if action_name == " validate"
7+ render json : { valid : false }
88 else
99 session_expired
1010 end
Original file line number Diff line number Diff line change 816816
817817 include_examples "restricts access to organization users/admins"
818818 end
819+
820+ describe 'POST #validate' do
821+ it 'should handle missing CSRF gracefully' do
822+ ActionController ::Base . allow_forgery_protection = true
823+ post validate_partners_individuals_requests_path
824+ ActionController ::Base . allow_forgery_protection = false
825+
826+ expect ( JSON . parse ( response . body ) ) . to eq ( { 'valid' => false } )
827+ expect ( response . status ) . to eq ( 200 )
828+ end
829+ end
819830 end
820831
821832 context "While not signed in" do
Original file line number Diff line number Diff line change 1111
1212 before { sign_in ( partner_user ) }
1313
14- describe ' GET #new' do
14+ describe " GET #new" do
1515 subject { get new_partners_family_request_path }
1616
1717 it "does not allow deactivated partners" do
2727 end
2828 end
2929
30- describe ' POST #create' do
30+ describe " POST #create" do
3131 before do
3232 # Set one child as deactivated and the other as active but
3333 # without a item_needed_diaperid
6666 expect ( Partners ::ChildItemRequest . find_by ( child_id : children [ 2 ] . id ) ) . to be_present
6767 end
6868 end
69+
70+ describe "POST #validate" do
71+ it "should handle missing CSRF gracefully" do
72+ ActionController ::Base . allow_forgery_protection = true
73+ post validate_partners_family_requests_path
74+ ActionController ::Base . allow_forgery_protection = false
75+
76+ expect ( JSON . parse ( response . body ) ) . to eq ( { "valid" => false } )
77+ expect ( response . status ) . to eq ( 200 )
78+ end
79+ end
6980end
Original file line number Diff line number Diff line change 156156 end
157157 end
158158 end
159+
160+ describe "POST #validate" do
161+ it "should handle missing CSRF gracefully" do
162+ ActionController ::Base . allow_forgery_protection = true
163+ post validate_partners_individuals_requests_path
164+ ActionController ::Base . allow_forgery_protection = false
165+
166+ expect ( JSON . parse ( response . body ) ) . to eq ( { "valid" => false } )
167+ expect ( response . status ) . to eq ( 200 )
168+ end
169+ end
159170end
Original file line number Diff line number Diff line change 407407 end
408408 end
409409 end
410+
411+ describe 'POST #validate' do
412+ it 'should handle missing CSRF gracefully' do
413+ sign_in ( partner_user )
414+
415+ ActionController ::Base . allow_forgery_protection = true
416+ post validate_partners_requests_path
417+ ActionController ::Base . allow_forgery_protection = false
418+
419+ expect ( JSON . parse ( response . body ) ) . to eq ( { 'valid' => false } )
420+ expect ( response . status ) . to eq ( 200 )
421+ end
422+ end
410423end
You can’t perform that action at this time.
0 commit comments