feat: Add comprehensive test coverage for Event model

- Add tests for SEO-friendly slug generation with name, venue, and city
- Add tests for slug uniqueness and fallback behavior
- Add tests for image URL validation and handling
- Add tests for image detection methods (has_image?, display_image)
- Fix duplicate has_image? method in Event model
- Remove duplicate test method to resolve test failures
- All 50 tests now passing

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
kbe
2025-10-01 08:48:03 +02:00
parent 78b675b41d
commit 4ca8d73c8e
2 changed files with 158 additions and 8 deletions

View File

@@ -167,25 +167,22 @@ class Event < ApplicationRecord
end
end
# Check if event has any image (uploaded or URL)
# Check if event has any image (old field, attached, or URL)
def has_image?
image.attached? || image_url.present?
self[:image].present? || image.attached? || image_url.present?
end
# Get display image source (uploaded or URL)
def display_image
if image.attached?
image
else
elsif image_url.present?
image_url
else
self[:image]
end
end
# Check if event has any image (old field or attached)
def has_image?
self[:image].present? || image.attached?
end
# Check if coordinates were successfully geocoded or are fallback coordinates
def geocoding_successful?
coordinates_look_valid?