Skip to content

Commit 1d0dbea

Browse files
Test: add specs for judge form validation errors
Signed-off-by: Audrea Cook <[email protected]>
1 parent 578e335 commit 1d0dbea

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

spec/system/judges/new_spec.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,21 @@
6262
end
6363
# rubocop:enable RSpec/ExampleLength
6464

65+
context "when validations fail" do
66+
it "shows validation error when name is blank" do
67+
submit_judge_form(name: "")
68+
expect(page).to have_text("Name can't be blank")
69+
end
70+
71+
it "does not allow duplicate judge names in the same organization", :aggregate_failures do
72+
duplicate_name = Faker::Name.unique.name
73+
create(:judge, name: duplicate_name, casa_org: organization)
74+
submit_judge_form(name: duplicate_name)
75+
expect(page).to have_text("Name has already been taken")
76+
expect(Judge.where(name: duplicate_name, casa_org: organization).count).to eq 1
77+
end
78+
end
79+
6580
private
6681

6782
def submit_judge_form(name:, active: true)

0 commit comments

Comments
 (0)