diff --git a/app/views/fields/url/_index.html.erb b/app/views/fields/url/_index.html.erb index 32f3641382..e3dc951889 100644 --- a/app/views/fields/url/_index.html.erb +++ b/app/views/fields/url/_index.html.erb @@ -16,5 +16,5 @@ By default, the value is rendered as an `a` element. %> <%= content_tag :a, href: field.data, **field.html_options do %> - <%= field.data %> + <%= field.truncate %> <% end %> diff --git a/spec/administrate/views/fields/url/_index_spec.rb b/spec/administrate/views/fields/url/_index_spec.rb index d6fb1e809b..42d7ea6e18 100644 --- a/spec/administrate/views/fields/url/_index_spec.rb +++ b/spec/administrate/views/fields/url/_index_spec.rb @@ -2,13 +2,14 @@ describe "fields/url/_index", type: :view do let(:product) do - build(:product, image_url: "https://thoughtbot.com/image.jpg") + build(:product, image_url: "https://thoughtbot.com/image-but-extremely-long-and-should-be-truncated.jpg") end it "renders url" do url = instance_double( "Administrate::Field::Url", data: product.image_url, + truncate: product.image_url[0..50], html_options: {} ) @@ -19,7 +20,7 @@ expect(rendered).to have_css( %(a[href="#{product.image_url}"]), - text: product.image_url + text: product.image_url[0..50] ) end @@ -27,6 +28,7 @@ url = instance_double( "Administrate::Field::Url", data: product.image_url, + truncate: product.image_url, html_options: {referrerpolicy: "no-referrer"} )