Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: resource fails to show when title is numeric #3208

Merged
merged 3 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/avo/resources/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,10 @@ def model_class
end

def record_title
fetch_record_title.to_s
end

def fetch_record_title
return name if @record.nil?

# Get the title from the record if title is not set, try to get the name, title or label, or fallback to the to_param
Expand Down
11 changes: 11 additions & 0 deletions spec/features/avo/resource_title_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require "rails_helper"

RSpec.feature "Resource title option", type: :feature do
let!(:project) { create :project }

it "dont raise any error while visiting show viw with title as id" do
with_temporary_class_option(Avo::Resources::Project, :title, :id) do
expect { visit avo.resources_project_path(project) }.not_to raise_error
end
end
end
Loading