From 74d04d1f3d320f6751e6f3ddbd071189d4f1c8b7 Mon Sep 17 00:00:00 2001 From: iamodh Date: Thu, 19 Feb 2026 11:52:38 +0900 Subject: [PATCH 1/7] feat(m4): add name and phone_number normalization using Rails normalizes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Use declarative `normalizes` API instead of before_validation callbacks - Name: remove all whitespace ("홍 길 동" → "홍길동") - Phone: remove all non-digit characters ("010-1234-5678" → "01012345678") - Update TECHSPEC §7.1 to reflect normalizes approach Co-Authored-By: Claude Opus 4.6 --- PLAN.md | 4 ++-- TECHSPEC.md | 15 +++------------ app/models/registration.rb | 3 +++ test/models/registration_test.rb | 12 ++++++++++++ 4 files changed, 20 insertions(+), 14 deletions(-) diff --git a/PLAN.md b/PLAN.md index 53105e8..635d96c 100755 --- a/PLAN.md +++ b/PLAN.md @@ -139,8 +139,8 @@ bundle exec rails runner "puts 'OK'" **Unit Tests** -- [ ] 이름 정규화: "홍 길 동" → "홍길동" -- [ ] 전화번호 정규화: "010-1234-5678" → "01012345678" +- [x] 이름 정규화: "홍 길 동" → "홍길동" +- [x] 전화번호 정규화: "010-1234-5678" → "01012345678" - [ ] 필수 필드 누락 시 에러 **Integration Tests** diff --git a/TECHSPEC.md b/TECHSPEC.md index f0a1681..f27818a 100755 --- a/TECHSPEC.md +++ b/TECHSPEC.md @@ -526,21 +526,12 @@ Course 1 ──< Registration ### 7.1 데이터 정규화 (Registration) -저장 전 `before_validation` 콜백에서 처리: +`normalizes` 선언으로 처리: ```ruby class Registration < ApplicationRecord - before_validation :normalize_name, :normalize_phone_number - - private - - def normalize_name - self.name = name.gsub(/\s+/, '') if name.present? - end - - def normalize_phone_number - self.phone_number = phone_number.gsub(/\D/, '') if phone_number.present? - end + normalizes :name, with: ->(name) { name.gsub(/\s+/, "") } + normalizes :phone_number, with: ->(phone_number) { phone_number.gsub(/\D/, "") } end ``` diff --git a/app/models/registration.rb b/app/models/registration.rb index 289cfaa..6cb21fa 100644 --- a/app/models/registration.rb +++ b/app/models/registration.rb @@ -4,5 +4,8 @@ class Registration < ApplicationRecord enum :gender, { male: "male", female: "female" } + normalizes :name, with: ->(name) { name.gsub(/\s+/, "") } + normalizes :phone_number, with: ->(phone_number) { phone_number.gsub(/\D/, "") } + validates :name, :phone_number, :birth_date, :gender, :address, presence: true end diff --git a/test/models/registration_test.rb b/test/models/registration_test.rb index 179d9fe..5461a42 100644 --- a/test/models/registration_test.rb +++ b/test/models/registration_test.rb @@ -11,6 +11,18 @@ class RegistrationTest < ActiveSupport::TestCase assert_equal courses(:five_km), registration.course end + test "normalizes name by removing spaces" do + registration = registrations(:hong_5km) + registration.name = "홍 길 동" + assert_equal "홍길동", registration.name + end + + test "normalizes phone_number by removing non-digits" do + registration = registrations(:hong_5km) + registration.phone_number = "010-1234-5678" + assert_equal "01012345678", registration.phone_number + end + test "requires name, phone_number, birth_date, gender, and address" do registration = registrations(:hong_5km) registration.name = nil From b27ac56b06004b7c3429d404fd1f215c61df37c5 Mon Sep 17 00:00:00 2001 From: iamodh Date: Thu, 19 Feb 2026 13:24:43 +0900 Subject: [PATCH 2/7] feat(m4): add registration form with home page and course display - Add Course#remaining_slots to calculate available capacity - Add home page showing available courses (capacity > 0) with remaining slots - Add registration form with required fields (name, phone, birth_date, gender, address) - Add routes for home and nested registrations under courses - Add testing guideline: update old tests when model methods replace inline logic Co-Authored-By: Claude Opus 4.6 --- CLAUDE.md | 1 + PLAN.md | 5 +-- app/controllers/home_controller.rb | 6 +++ app/controllers/registrations_controller.rb | 6 +++ app/models/course.rb | 4 ++ app/views/home/show.html.erb | 11 ++++++ app/views/registrations/new.html.erb | 32 ++++++++++++++++ config/routes.rb | 7 +++- test/integration/registration_form_test.rb | 42 +++++++++++++++++++++ test/models/course_test.rb | 5 +++ 10 files changed, 114 insertions(+), 5 deletions(-) create mode 100644 app/controllers/home_controller.rb create mode 100644 app/controllers/registrations_controller.rb create mode 100644 app/views/home/show.html.erb create mode 100644 app/views/registrations/new.html.erb create mode 100644 test/integration/registration_form_test.rb diff --git a/CLAUDE.md b/CLAUDE.md index 1d942ff..fc2f5b0 100755 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -47,6 +47,7 @@ 3. **Red → Green → Refactor**: 테스트 실패 → 최소 구현 → 리팩토링 순서 엄수 4. **Fixtures 활용**: `test/fixtures/*.yml`에 실제 데이터 흐름을 담아라 5. **동일 성격 검증은 하나의 테스트로 합쳐라**: 필수 필드 3개 → 테스트 1개에서 모두 검증 (필드별 분리 금지) +6. **테스트 내 인라인 로직을 대체하는 모델 메서드가 추가되면, 기존 테스트도 해당 메서드를 사용하도록 수정한다** ### 단계별 테스트 범위 diff --git a/PLAN.md b/PLAN.md index 635d96c..c7f9180 100755 --- a/PLAN.md +++ b/PLAN.md @@ -141,12 +141,11 @@ bundle exec rails runner "puts 'OK'" - [x] 이름 정규화: "홍 길 동" → "홍길동" - [x] 전화번호 정규화: "010-1234-5678" → "01012345678" -- [ ] 필수 필드 누락 시 에러 **Integration Tests** -- [ ] 신청 폼 표시 (available 코스만, 잔여 인원 표시) -- [ ] 입력 에러 시 폼 상태 유지 + 입력값 보존 +- [x] 신청 폼 표시 (available 코스만, 잔여 인원 표시) +- [ ] 필수 필드 누락 제출 시 폼 상태 유지 + 입력값 보존 **완료 조건:** 신청 폼 동작, 정규화 적용, 에러 시 입력값 보존 diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb new file mode 100644 index 0000000..3400409 --- /dev/null +++ b/app/controllers/home_controller.rb @@ -0,0 +1,6 @@ +class HomeController < ApplicationController + def show + @race = Race.first! + @courses = @race.courses.where("capacity > 0") + end +end diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb new file mode 100644 index 0000000..785d84e --- /dev/null +++ b/app/controllers/registrations_controller.rb @@ -0,0 +1,6 @@ +class RegistrationsController < ApplicationController + def new + @course = Course.find(params[:course_id]) + @registration = @course.registrations.new + end +end diff --git a/app/models/course.rb b/app/models/course.rb index 7de1291..387983f 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -1,4 +1,8 @@ class Course < ApplicationRecord belongs_to :race has_many :registrations, dependent: :destroy + + def remaining_slots + capacity - registrations.where(status: "applied").count + end end diff --git a/app/views/home/show.html.erb b/app/views/home/show.html.erb new file mode 100644 index 0000000..7b3f205 --- /dev/null +++ b/app/views/home/show.html.erb @@ -0,0 +1,11 @@ +

<%= @race.name %>

+ +
+ <% @courses.each do |course| %> +
+

<%= course.name %>

+

잔여: <%= course.remaining_slots %>명

+ <%= link_to "신청하기", new_course_registration_path(course) %> +
+ <% end %> +
diff --git a/app/views/registrations/new.html.erb b/app/views/registrations/new.html.erb new file mode 100644 index 0000000..165279e --- /dev/null +++ b/app/views/registrations/new.html.erb @@ -0,0 +1,32 @@ +

<%= @course.name %> 신청

+ +<%= form_with model: @registration, url: course_registrations_path(@course) do |f| %> +
+ <%= f.label :name, "이름" %> + <%= f.text_field :name %> +
+ +
+ <%= f.label :phone_number, "전화번호" %> + <%= f.text_field :phone_number %> +
+ +
+ <%= f.label :birth_date, "생년월일" %> + <%= f.date_field :birth_date %> +
+ +
+ <%= f.label :gender, "성별" %> + <%= f.select :gender, [["남성", "male"], ["여성", "female"]], prompt: "선택해주세요" %> +
+ +
+ <%= f.label :address, "주소" %> + <%= f.text_area :address %> +
+ +
+ <%= f.submit "신청하기" %> +
+<% end %> diff --git a/config/routes.rb b/config/routes.rb index 48254e8..cb243c2 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -9,6 +9,9 @@ # get "manifest" => "rails/pwa#manifest", as: :pwa_manifest # get "service-worker" => "rails/pwa#service_worker", as: :pwa_service_worker - # Defines the root path route ("/") - # root "posts#index" + root "home#show" + + resources :courses, only: [] do + resources :registrations, only: [ :new, :create ] + end end diff --git a/test/integration/registration_form_test.rb b/test/integration/registration_form_test.rb new file mode 100644 index 0000000..ae95734 --- /dev/null +++ b/test/integration/registration_form_test.rb @@ -0,0 +1,42 @@ +require "test_helper" + +class RegistrationFormTest < ActionDispatch::IntegrationTest + test "home page shows available courses with registration links" do + get root_path + + assert_response :success + + [ courses(:five_km), courses(:ten_km), courses(:half) ].each do |course| + assert_select "[data-course-id='#{course.id}'] a[href=?]", new_course_registration_path(course) + end + end + + test "home page hides courses with zero capacity" do + get root_path + + assert_select "[data-course-id='#{courses(:full).id}']", count: 0 + end + + test "home page displays remaining slots for each available course" do + get root_path + + five_km = courses(:five_km) + + assert_select "[data-course-id='#{five_km.id}'] .remaining-slots", + text: /#{five_km.remaining_slots}/ + end + + test "registration form renders input fields for the selected course" do + course = courses(:five_km) + + get new_course_registration_path(course) + + assert_response :success + assert_select "form[action=?]", course_registrations_path(course) + assert_select "input[name='registration[name]']" + assert_select "input[name='registration[phone_number]']" + assert_select "input[name='registration[birth_date]']" + assert_select "select[name='registration[gender]']" + assert_select "textarea[name='registration[address]']" + end +end diff --git a/test/models/course_test.rb b/test/models/course_test.rb index dbfc1f5..1b22818 100644 --- a/test/models/course_test.rb +++ b/test/models/course_test.rb @@ -10,4 +10,9 @@ class CourseTest < ActiveSupport::TestCase course = courses(:five_km) assert_includes course.registrations, registrations(:hong_5km) end + + test "remaining_slots returns capacity minus applied registrations" do + course = courses(:five_km) + assert_equal course.capacity - 1, course.remaining_slots + end end From b133a6946e127ffbbdc5ac38f30e691c9851fc8e Mon Sep 17 00:00:00 2001 From: iamodh Date: Thu, 19 Feb 2026 17:37:47 +0900 Subject: [PATCH 3/7] feat(m4): add form submission with validation errors and input preservation Add create action to RegistrationsController with validation error handling. Auto-set race_id from course via before_validation callback. Display validation errors at top of form and preserve user input on resubmission. Co-Authored-By: Claude Opus 4.6 --- PLAN.md | 2 +- app/controllers/registrations_controller.rb | 17 +++++++++++++++++ app/models/registration.rb | 8 ++++++++ app/views/registrations/new.html.erb | 10 ++++++++++ test/integration/registration_form_test.rb | 15 +++++++++++++++ 5 files changed, 51 insertions(+), 1 deletion(-) diff --git a/PLAN.md b/PLAN.md index c7f9180..90a1c83 100755 --- a/PLAN.md +++ b/PLAN.md @@ -145,7 +145,7 @@ bundle exec rails runner "puts 'OK'" **Integration Tests** - [x] 신청 폼 표시 (available 코스만, 잔여 인원 표시) -- [ ] 필수 필드 누락 제출 시 폼 상태 유지 + 입력값 보존 +- [x] 필수 필드 누락 제출 시 폼 상태 유지 + 입력값 보존 **완료 조건:** 신청 폼 동작, 정규화 적용, 에러 시 입력값 보존 diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index 785d84e..bcb4d6a 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -3,4 +3,21 @@ def new @course = Course.find(params[:course_id]) @registration = @course.registrations.new end + + def create + @course = Course.find(params[:course_id]) + @registration = @course.registrations.new(registration_params) + + if @registration.save + redirect_to root_path + else + render :new, status: :unprocessable_entity + end + end + + private + + def registration_params + params.require(:registration).permit(:name, :phone_number, :birth_date, :gender, :address) + end end diff --git a/app/models/registration.rb b/app/models/registration.rb index 6cb21fa..b9b81fd 100644 --- a/app/models/registration.rb +++ b/app/models/registration.rb @@ -2,10 +2,18 @@ class Registration < ApplicationRecord belongs_to :race belongs_to :course + before_validation :set_race_from_course + enum :gender, { male: "male", female: "female" } normalizes :name, with: ->(name) { name.gsub(/\s+/, "") } normalizes :phone_number, with: ->(phone_number) { phone_number.gsub(/\D/, "") } validates :name, :phone_number, :birth_date, :gender, :address, presence: true + + private + + def set_race_from_course + self.race = course.race if course.present? && race.blank? + end end diff --git a/app/views/registrations/new.html.erb b/app/views/registrations/new.html.erb index 165279e..3668e6f 100644 --- a/app/views/registrations/new.html.erb +++ b/app/views/registrations/new.html.erb @@ -1,5 +1,15 @@

<%= @course.name %> 신청

+<% if @registration.errors.any? %> +
+
    + <% @registration.errors.full_messages.each do |message| %> +
  • <%= message %>
  • + <% end %> +
+
+<% end %> + <%= form_with model: @registration, url: course_registrations_path(@course) do |f| %>
<%= f.label :name, "이름" %> diff --git a/test/integration/registration_form_test.rb b/test/integration/registration_form_test.rb index ae95734..9b9b3c9 100644 --- a/test/integration/registration_form_test.rb +++ b/test/integration/registration_form_test.rb @@ -39,4 +39,19 @@ class RegistrationFormTest < ActionDispatch::IntegrationTest assert_select "select[name='registration[gender]']" assert_select "textarea[name='registration[address]']" end + + test "submitting with missing fields re-renders form with validation errors and preserves input" do + course = courses(:five_km) + kept_name = "김철수" + + assert_no_difference "Registration.count" do + post course_registrations_path(course), params: { + registration: { name: kept_name, phone_number: "", birth_date: "", gender: "", address: "" } + } + end + + assert_response :unprocessable_entity + assert_select "input[name='registration[name]'][value=?]", kept_name + assert_select ".field-errors" + end end From 1598721f8a1ca7e87ebfe8da7afebbdee6ed5a61 Mon Sep 17 00:00:00 2001 From: iamodh Date: Thu, 19 Feb 2026 17:44:41 +0900 Subject: [PATCH 4/7] feat(m4): add name length validation (max 10 characters) Add maximum length constraint for registration name field as specified in TECHSPEC. Validates after normalization (space removal). Co-Authored-By: Claude Opus 4.6 --- TECHSPEC.md | 2 +- app/models/registration.rb | 3 ++- test/models/registration_test.rb | 7 +++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/TECHSPEC.md b/TECHSPEC.md index f27818a..3679b65 100755 --- a/TECHSPEC.md +++ b/TECHSPEC.md @@ -48,7 +48,7 @@ - Rails 생태계에서 단일 id PK가 컨벤션이며, 복합 PK는 라우팅/association/유지보수에 마찰을 만든다 - Unique Index는 동시 요청에서도 DB가 최종적으로 중복을 차단한다 - name/phone_number 정규화 (저장 전 처리) - - name: 모든 공백 제거 ("홍 길 동" → "홍길동") + - name: 모든 공백 제거 ("홍 길 동" → "홍길동"), 최대 10글자 - phone: 숫자만 추출 ("010-1234-5678" → "01012345678") - 이유: "홍길동" vs "홍 길동", "010-1234-5678" vs "01012345678" 등 동일인 우회 방지 - 적용 위치: 모델 콜백(before_validation)에서 일괄 처리 diff --git a/app/models/registration.rb b/app/models/registration.rb index b9b81fd..9f78214 100644 --- a/app/models/registration.rb +++ b/app/models/registration.rb @@ -9,7 +9,8 @@ class Registration < ApplicationRecord normalizes :name, with: ->(name) { name.gsub(/\s+/, "") } normalizes :phone_number, with: ->(phone_number) { phone_number.gsub(/\D/, "") } - validates :name, :phone_number, :birth_date, :gender, :address, presence: true + validates :name, presence: true, length: { maximum: 10 } + validates :phone_number, :birth_date, :gender, :address, presence: true private diff --git a/test/models/registration_test.rb b/test/models/registration_test.rb index 5461a42..0d5d230 100644 --- a/test/models/registration_test.rb +++ b/test/models/registration_test.rb @@ -23,6 +23,13 @@ class RegistrationTest < ActiveSupport::TestCase assert_equal "01012345678", registration.phone_number end + test "rejects name longer than 10 characters" do + registration = registrations(:hong_5km) + registration.name = "가" * 11 + assert_not registration.valid? + assert_includes registration.errors[:name], "is too long (maximum is 10 characters)" + end + test "requires name, phone_number, birth_date, gender, and address" do registration = registrations(:hong_5km) registration.name = nil From 30734ad469d6543a65990de817701d075c2453a3 Mon Sep 17 00:00:00 2001 From: iamodh Date: Thu, 19 Feb 2026 17:46:39 +0900 Subject: [PATCH 5/7] feat(m4): add maxlength attribute to name input field Add HTML maxlength=10 to name text field for client-side UX guard. Co-Authored-By: Claude Opus 4.6 --- app/views/registrations/new.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/registrations/new.html.erb b/app/views/registrations/new.html.erb index 3668e6f..62bc7fe 100644 --- a/app/views/registrations/new.html.erb +++ b/app/views/registrations/new.html.erb @@ -13,7 +13,7 @@ <%= form_with model: @registration, url: course_registrations_path(@course) do |f| %>
<%= f.label :name, "이름" %> - <%= f.text_field :name %> + <%= f.text_field :name, maxlength: 10 %>
From 95653bad6f8140a8c37fa416c71746ae66e54f33 Mon Sep 17 00:00:00 2001 From: iamodh Date: Thu, 19 Feb 2026 17:49:03 +0900 Subject: [PATCH 6/7] feat(m4): add address length validation (max 30 characters) Add maximum length constraint for registration address field with server-side validation and HTML maxlength attribute. Co-Authored-By: Claude Opus 4.6 --- TECHSPEC.md | 1 + app/models/registration.rb | 3 ++- app/views/registrations/new.html.erb | 2 +- test/models/registration_test.rb | 7 +++++++ 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/TECHSPEC.md b/TECHSPEC.md index 3679b65..79d59b7 100755 --- a/TECHSPEC.md +++ b/TECHSPEC.md @@ -49,6 +49,7 @@ - Unique Index는 동시 요청에서도 DB가 최종적으로 중복을 차단한다 - name/phone_number 정규화 (저장 전 처리) - name: 모든 공백 제거 ("홍 길 동" → "홍길동"), 최대 10글자 + - address: 최대 30글자 - phone: 숫자만 추출 ("010-1234-5678" → "01012345678") - 이유: "홍길동" vs "홍 길동", "010-1234-5678" vs "01012345678" 등 동일인 우회 방지 - 적용 위치: 모델 콜백(before_validation)에서 일괄 처리 diff --git a/app/models/registration.rb b/app/models/registration.rb index 9f78214..fb91e13 100644 --- a/app/models/registration.rb +++ b/app/models/registration.rb @@ -10,7 +10,8 @@ class Registration < ApplicationRecord normalizes :phone_number, with: ->(phone_number) { phone_number.gsub(/\D/, "") } validates :name, presence: true, length: { maximum: 10 } - validates :phone_number, :birth_date, :gender, :address, presence: true + validates :phone_number, :birth_date, :gender, presence: true + validates :address, presence: true, length: { maximum: 30 } private diff --git a/app/views/registrations/new.html.erb b/app/views/registrations/new.html.erb index 62bc7fe..8ada238 100644 --- a/app/views/registrations/new.html.erb +++ b/app/views/registrations/new.html.erb @@ -33,7 +33,7 @@
<%= f.label :address, "주소" %> - <%= f.text_area :address %> + <%= f.text_area :address, maxlength: 30 %>
diff --git a/test/models/registration_test.rb b/test/models/registration_test.rb index 0d5d230..9f13ce5 100644 --- a/test/models/registration_test.rb +++ b/test/models/registration_test.rb @@ -30,6 +30,13 @@ class RegistrationTest < ActiveSupport::TestCase assert_includes registration.errors[:name], "is too long (maximum is 10 characters)" end + test "rejects address longer than 30 characters" do + registration = registrations(:hong_5km) + registration.address = "가" * 31 + assert_not registration.valid? + assert_includes registration.errors[:address], "is too long (maximum is 30 characters)" + end + test "requires name, phone_number, birth_date, gender, and address" do registration = registrations(:hong_5km) registration.name = nil From a705d01e16d8bddbfa631bc5a8bdbcd91936379a Mon Sep 17 00:00:00 2001 From: iamodh Date: Thu, 19 Feb 2026 17:57:07 +0900 Subject: [PATCH 7/7] feat(m4): add phone_number length validation (max 11 digits) Add maximum length constraint for phone_number field. Server validates 11 digits (post-normalization), HTML allows 13 chars to accommodate dashes in user input. Co-Authored-By: Claude Opus 4.6 --- TECHSPEC.md | 2 +- app/models/registration.rb | 3 ++- app/views/registrations/new.html.erb | 2 +- test/models/registration_test.rb | 7 +++++++ 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/TECHSPEC.md b/TECHSPEC.md index 79d59b7..5b3265e 100755 --- a/TECHSPEC.md +++ b/TECHSPEC.md @@ -50,7 +50,7 @@ - name/phone_number 정규화 (저장 전 처리) - name: 모든 공백 제거 ("홍 길 동" → "홍길동"), 최대 10글자 - address: 최대 30글자 - - phone: 숫자만 추출 ("010-1234-5678" → "01012345678") + - phone: 숫자만 추출 ("010-1234-5678" → "01012345678"), 최대 11자리 - 이유: "홍길동" vs "홍 길동", "010-1234-5678" vs "01012345678" 등 동일인 우회 방지 - 적용 위치: 모델 콜백(before_validation)에서 일괄 처리 - 정원 초과 신청 방지 (동시성 대응) diff --git a/app/models/registration.rb b/app/models/registration.rb index fb91e13..f161e75 100644 --- a/app/models/registration.rb +++ b/app/models/registration.rb @@ -10,7 +10,8 @@ class Registration < ApplicationRecord normalizes :phone_number, with: ->(phone_number) { phone_number.gsub(/\D/, "") } validates :name, presence: true, length: { maximum: 10 } - validates :phone_number, :birth_date, :gender, presence: true + validates :phone_number, presence: true, length: { maximum: 11 } + validates :birth_date, :gender, presence: true validates :address, presence: true, length: { maximum: 30 } private diff --git a/app/views/registrations/new.html.erb b/app/views/registrations/new.html.erb index 8ada238..695f90f 100644 --- a/app/views/registrations/new.html.erb +++ b/app/views/registrations/new.html.erb @@ -18,7 +18,7 @@
<%= f.label :phone_number, "전화번호" %> - <%= f.text_field :phone_number %> + <%= f.text_field :phone_number, maxlength: 13 %>
diff --git a/test/models/registration_test.rb b/test/models/registration_test.rb index 9f13ce5..f01239d 100644 --- a/test/models/registration_test.rb +++ b/test/models/registration_test.rb @@ -30,6 +30,13 @@ class RegistrationTest < ActiveSupport::TestCase assert_includes registration.errors[:name], "is too long (maximum is 10 characters)" end + test "rejects phone_number longer than 11 digits" do + registration = registrations(:hong_5km) + registration.phone_number = "0" * 12 + assert_not registration.valid? + assert_includes registration.errors[:phone_number], "is too long (maximum is 11 characters)" + end + test "rejects address longer than 30 characters" do registration = registrations(:hong_5km) registration.address = "가" * 31