1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/actionview/test
claudiob dee00df11c Fix how file_ and password_field_tag edit options
This commit fixes the behavior of `file_field_tag` and `password_field_tag`
when invoked with a hash of options.

These two helpers are different from all the other ones in that they modify the
options hash passed as a parameter, whereas all the other helpers duplicate it
before updating it.

The result is that *bad things* can happen if the user re-uses the same hash.
For instance, users who write the following code to display a file field
followed by a text field (both with the same class):

```rhtml
<% options = {class: 'important'} %>
<%= file_field_tag 'Upload', options %>
<%= text_field_tag 'Name', options %>
```

would instead see **two file fields!**

```html
<input class="important" id="Upload" name="Upload" type="file">
<input class="important" id="Name" name="Name" type="file" value="value">
```

This PR replaces `update` with `merge` in the code of the two helpers,
fixing the issue above.

The included test verifies the change, since it passes after this PR, but
fails before with the following error:

```
Expected: <input type="text" name="title" id="title" value="Hello!" class="important" />
Actual: <input type="password" name="title" id="title" value="Hello!" class="important" />
```
2014-10-15 10:15:45 -07:00
..
actionpack Revert "Revert "Merge pull request #16888 from jejacks0n/render_template"" 2014-09-26 01:42:18 +09:00
activerecord Remove internal options from query string of paths 2014-09-25 17:50:16 +02:00
fixtures handle <%== nil %> cases 2014-09-14 17:11:13 -07:00
lib/controller Moved viewpathstest into actionview/test/actionpack/controller 2013-10-09 20:09:33 +02:00
template Fix how file_ and password_field_tag edit options 2014-10-15 10:15:45 -07:00
tmp Add tmp dir in actionview/test/ 2013-08-05 01:24:14 +05:30
abstract_unit.rb Don’t require already required modules 2014-09-26 13:05:00 -07:00
active_record_unit.rb Change back occurrences of SQLite(3) to sqlite3 when referring to the 2014-07-06 11:47:16 -07:00