File tree Expand file tree Collapse file tree 5 files changed +22
-22
lines changed
Expand file tree Collapse file tree 5 files changed +22
-22
lines changed Original file line number Diff line number Diff line change @@ -75,4 +75,4 @@ def submission_params
7575 { }
7676 end
7777 end
78- end
78+ end
Original file line number Diff line number Diff line change @@ -55,4 +55,4 @@ def create_form_without_code(attrs = {})
5555 form3 . reload
5656 expect ( form3 . code ) . to eq ( original_code )
5757 end
58- end
58+ end
Original file line number Diff line number Diff line change 5353 button_text : "Submit" ,
5454 code : "ABCDEFGHIJKL"
5555 )
56-
56+
5757 form . name = "Updated Form"
5858 form . save!
59-
59+
6060 expect ( form . reload . code ) . to eq ( "ABCDEFGHIJKL" )
6161 end
6262
6363 it "ensures uniqueness of codes" do
64- existing_form = Form . create! (
64+ Form . create! (
6565 name : "Existing Form" ,
6666 button_text : "Submit" ,
6767 code : "ABCDEFGHIJKL"
6868 )
69-
69+
7070 new_form = Form . new (
7171 name : "New Form" ,
7272 button_text : "Submit" ,
7373 code : "ABCDEFGHIJKL"
7474 )
75-
75+
7676 expect ( new_form ) . not_to be_valid
7777 expect ( new_form . errors [ :code ] ) . to include ( "has already been taken" )
7878 end
7979 end
8080
8181 describe ".find_by_code_or_id" do
8282 let! ( :form ) { Form . create! ( name : "Test Form" , button_text : "Submit" ) }
83-
83+
8484 it "finds a form by its code" do
8585 found_form = Form . find_by_code_or_id ( form . code )
8686 expect ( found_form ) . to eq ( form )
8787 end
88-
88+
8989 it "finds a form by its ID" do
9090 found_form = Form . find_by_code_or_id ( form . id )
9191 expect ( found_form ) . to eq ( form )
9292 end
93-
93+
9494 it "returns nil when neither code nor ID matches" do
9595 found_form = Form . find_by_code_or_id ( "NONEXISTENT" )
9696 expect ( found_form ) . to be_nil
9797 end
9898 end
99- end
99+ end
Original file line number Diff line number Diff line change 22
33RSpec . describe "Empty form submissions" , type : :request do
44 let! ( :device ) { Device . create! ( name : "Test Device" , location : "Test Location" ) }
5-
5+
66 describe "form with no enabled fields" do
77 let! ( :form ) do
88 Form . create! (
1515 enable_postcode : false
1616 )
1717 end
18-
18+
1919 it "allows submitting a form with no fields" do
2020 expect {
2121 post public_form_path ( form . code , device . id )
2222 } . to change ( Submission , :count ) . by ( 1 )
23-
23+
2424 expect ( response ) . to redirect_to ( form_thanks_path ( form . code , device ) )
2525 follow_redirect!
2626 expect ( response ) . to have_http_status ( :success )
2727 end
2828 end
29-
29+
3030 describe "code with no enabled fields" do
3131 let! ( :form ) do
3232 Form . create! (
3939 enable_postcode : false
4040 )
4141 end
42-
42+
4343 let! ( :code ) { Code . create! ( device : device , form : form ) }
44-
44+
4545 it "allows submitting a code form with no fields" do
4646 expect {
4747 post public_code_path ( code )
4848 } . to change ( Submission , :count ) . by ( 1 )
49-
49+
5050 expect ( response ) . to redirect_to ( code_thanks_path ( code ) )
5151 follow_redirect!
5252 expect ( response ) . to have_http_status ( :success )
53-
53+
5454 # Verify the code was claimed
5555 code . reload
5656 expect ( code . claimed? ) . to be true
5757 end
5858 end
59- end
59+ end
Original file line number Diff line number Diff line change 6363
6464 it "renders correctly in the forms edit view" do
6565 # Log in as admin to access the forms
66- admin = login_as_admin
66+ login_as_admin
6767
6868 # Link the form to the device
6969 form . devices << device
7575 expect ( response . body ) . to include ( public_form_path ( form . code , device . id ) )
7676 end
7777 end
78- end
78+ end
You can’t perform that action at this time.
0 commit comments