Commit 90ceace5f85567cbf7fae859ce4d61d052a157b7
1 parent
9fb3ad5a
Exists in
send_email_to_admins
and in
5 other branches
html_safe: Consider to_json safe
This also fixes shopping_cart tests
Showing
3 changed files
with
32 additions
and
1 deletions
Show diff stats
| ... | ... | @@ -0,0 +1,26 @@ |
| 1 | +## | |
| 2 | +# Object based copy of http://apidock.com/rails/ActionView/Helpers/OutputSafetyHelper/safe_join | |
| 3 | +# array.safe_join instead of safe_join(array) | |
| 4 | +# | |
| 5 | +class Array | |
| 6 | + def safe_join sep=nil | |
| 7 | + sep = ERB::Util.unwrapped_html_escape sep | |
| 8 | + | |
| 9 | + self.flatten.map!{ |i| ERB::Util.unwrapped_html_escape i }.join(sep).html_safe | |
| 10 | + end | |
| 11 | +end | |
| 12 | + | |
| 13 | +## | |
| 14 | +# Just use .to_json instead of .to_json.html_safe | |
| 15 | +# as escape_html_entities_in_json is default on rails. | |
| 16 | +# http://stackoverflow.com/a/31774454/670229 | |
| 17 | +# | |
| 18 | +ActiveSupport::JSON::Encoding.escape_html_entities_in_json = true | |
| 19 | +ActiveSupport::JSON.class_eval do | |
| 20 | + module EncodeWithHtmlSafe | |
| 21 | + def encode *args | |
| 22 | + super.html_safe | |
| 23 | + end | |
| 24 | + end | |
| 25 | + singleton_class.prepend EncodeWithHtmlSafe | |
| 26 | +end | ... | ... |
plugins/delivery/lib/delivery_plugin/display_helper.rb
| ... | ... | @@ -15,7 +15,7 @@ module DeliveryPlugin::DisplayHelper |
| 15 | 15 | content_tag :option, text, value: method.id, |
| 16 | 16 | data: {label: method.name, type: method.delivery_type, instructions: CGI::escapeHTML(method.description.to_s)}, |
| 17 | 17 | selected: if method.id == selected then 'selected' else nil end |
| 18 | - end.join | |
| 18 | + end.safe_join | |
| 19 | 19 | end |
| 20 | 20 | |
| 21 | 21 | def consumer_delivery_field_value order, field | ... | ... |
plugins/shopping_cart/features/delivery_client.feature
| ... | ... | @@ -64,10 +64,15 @@ Feature: delivery client |
| 64 | 64 | Scenario: gets free delivery due to free over price |
| 65 | 65 | Given I follow "Add to basket" |
| 66 | 66 | And I follow "Add to basket" |
| 67 | + And I wait 0.2 seconds to finish the request | |
| 67 | 68 | And I follow "Add to basket" |
| 69 | + And I wait 0.2 seconds to finish the request | |
| 68 | 70 | And I follow "Add to basket" |
| 71 | + And I wait 0.2 seconds to finish the request | |
| 69 | 72 | And I follow "Add to basket" |
| 73 | + And I wait 0.2 seconds to finish the request | |
| 70 | 74 | And I follow "Add to basket" |
| 75 | + And I wait 0.2 seconds to finish the request | |
| 71 | 76 | And I should see "Show basket" |
| 72 | 77 | And I follow "Show basket" |
| 73 | 78 | And I wait 1 second for animations | ... | ... |