Remove html_safe and add spec

This commit is contained in:
Enrico Stano
2017-07-18 18:16:35 +02:00
committed by Rob Harrington
parent 85fefcd946
commit 2f3f20e433
2 changed files with 16 additions and 2 deletions

View File

@@ -31,8 +31,7 @@ module Spree
html_options = {class: "remove_fields #{options[:class]}", data: {action: 'remove'}, title: t(:remove)}
html_options.merge!(options[:html]) if options.key? :html
link_to_with_icon('icon-trash', name, '#', html_options).gsub('href="#" ', '').html_safe +
f.hidden_field(:_destroy)
link_to_with_icon('icon-trash', name, '#', html_options).gsub('href="#" ', '') + f.hidden_field(:_destroy)
end
end
end

View File

@@ -0,0 +1,15 @@
require 'spec_helper'
describe Spree::BaseHelper, type: :helper do
describe "#link_to_remove_fields_without_url" do
let(:name) { 'Hola' }
let(:form) { double('form_for', hidden_field: '<input type="hidden" name="_method" value="destroy">') }
let(:options) { {} }
subject { helper.link_to_remove_fields_without_url(name, form, options) }
it 'returns an `a` tag followed by a hidden `input` tag' do
expect(subject).to eq("<a class=\"remove_fields icon_link with-tip icon-trash\" data-action=\"remove\" title=\"Remove\"><span class='text'>Hola</span></a><input type=\"hidden\" name=\"_method\" value=\"destroy\">")
end
end
end