Commit Graph

4276 Commits

Author SHA1 Message Date
Piotr Sarnacki
e4aaac1301 Fix sorting of helpers from different paths
When more than one directory for helpers is provided to a controller, it
should preserver the order of directories. Given 2 paths:

    MyController.helpers_paths = ["dir1/helpers", "dir2/helpers"]

helpers from dir1 should be loaded first. Before this commit, all
helpers were mixed and then sorted alphabetically, which essentially
would require to rename helpers to get desired order.

This is a problem especially for engines, where you would like to be
able to predict accurately which engine helpers will load first.

(closes #6496)
2012-05-28 06:58:48 +02:00
Rafael Mendonça França
2c2b0beaf4 Add :escape option for truncate
This options can be used to not escape the result by default.
2012-05-26 14:27:07 -03:00
Rafael Mendonça França
4ce3b5d6fe Test that the block used in truncate is escaped if it is not HTML safe
Refactoring the truncate method to not do a sort-circuit return
2012-05-26 13:57:15 -03:00
Li Ellis Gallardo
38813da6dc Truncate now has the ability to receive a html option that allows it to call rails helpers.
This way if my text is long I don't have to do something like this:

.text
= truncate(@text, :length => 27)

 if @text.size >= 27
    = link_to "continue", notes_path, ....."")
2012-05-26 10:24:17 -05:00
José Valim
73db73fee9 Remove implicit dependency on pathname 2012-05-25 09:27:39 +02:00
José Valim
cb92efbf04 Merge pull request #6453 from parndt/session_keys
Added session.keys and session.values back to ActionDispatch::Request::Session
2012-05-22 22:49:14 -07:00
Philip Arndt
6ac458d341 Added ActionDispatch::Request::Session#keys and ActionDispatch::Request::Session#values 2012-05-23 14:47:30 +12:00
Carlos Galdino
30847b499b Add tests for time_field and date_field helpers
These tests check the values of 'min' and 'max' input attrs
2012-05-22 23:33:07 -03:00
Jeremy Kemper
65d2a60a8c Merge pull request #6359 from carlosgaldino/add-html5-inputs
Add HTML5 color and date/time inputs
2012-05-22 16:17:40 -07:00
Philip Arndt
40c0b3a25d Fixed typo new_defautls -> new_defaults.
* Added tests for 'else' case in ActionView::Helpers::TranslationHelper#wrap_translate_defaults
* Also updated the testing syntax of translation.html_safe? asserts to provide better output upon failure.
2012-05-23 11:04:15 +12:00
Carlos Galdino
b02d14aad5 Add several HTML5 input helpers
The input types added are:

- input[type="month"]

- input[type="week"]

- input[type="datetime"]

- input[type="datetime-local"]
2012-05-21 17:23:56 -03:00
Carlos Galdino
1ce4b5b33d Add HTML5 input[type="color"] helper 2012-05-21 17:23:48 -03:00
Marc-Andre Lafortune
89ebd28d4e Fix bug when Rails.application is defined but is nil. See #881 2012-05-21 15:24:18 -04:00
José Valim
776ea1090f Revert "Merge pull request #6425 from pinetops/resolver_concurrency_fix"
This reverts commit 254c04286c5916ae7f91eb6e173b312e7a74e364, reversing
changes made to 513a0525c24c2944630acfa465b22cd2f4601adf.
2012-05-21 21:01:02 +02:00
Aaron Patterson
254c04286c Merge pull request #6425 from pinetops/resolver_concurrency_fix
Resolver concurrency fix
2012-05-21 11:29:25 -07:00
Tom Clarke
685192bbcb Make the Resolver template cache threadsafe - closes #6404
The Template cache in the Resolver can be accessed by multiple threads
similtaneously in multi-threaded environments. The cache is implemented
using a Hash, which isn't threadsafe in all VMs (notably JRuby).

This commit extracts the cache to a new Cache class and adds mutexes to
prevent concurrent access.
2012-05-21 14:24:30 -04:00
Aaron Patterson
513a0525c2 Merge pull request #2549 from trek/RoutingErrorForMissingControllers
When a route references a missing controller, raise ActionController::RoutingError with clearer message
2012-05-21 11:00:43 -07:00
Andrew White
79b38c386a Escape the extension when normalizing the action cache path.
Although no recognized formats use non-ASCII characters, sometimes they
can be included in the :format parameter because of invalid URLS. To
prevent encoding incompatibility errors we need to escape them before
passing the path to URI.unescape.

Closes #4379
2012-05-20 19:07:05 +01:00
Andrew White
3fc561a1f7 Return 400 Bad Request for URL paths with invalid encoding.
Passing path parameters with invalid encoding is likely to trigger errors
further on like `ArgumentError (invalid byte sequence in UTF-8)`. This will
result in a 500 error whereas the better error to return is a 400 error which
allows exception notification libraries to filter it out if they wish.

Closes #4450
2012-05-20 19:07:04 +01:00
Andrew White
66eb3f02cc Raise ActionController::BadRequest for malformed parameter hashes.
Currently Rack raises a TypeError when it encounters a malformed or
ambiguous hash like `foo[]=bar&foo[4]=bar`. Rather than pass this
through to the application this commit captures the exception and
re-raises it using a new ActionController::BadRequest exception.

The new ActionController::BadRequest exception returns a 400 error
instead of the 500 error that would've been returned by the original
TypeError. This allows exception notification libraries to ignore
these errors if so desired.

Closes #3051
2012-05-20 19:07:04 +01:00
David Chelimsky
dcce01132d Raise Assertion instead of RoutingError for routing assertion failures.
Before this change, assert_recognizes, assert_generates, and
assert_routing raised ActionController::RoutingError when they failed to
recognize the route.

This commit changes them to raise Assertion instead. This aligns with
convention for logical failures, and supports reporting tools that care
about the difference between logical failures and errors e.g. the
summary at the end of a test run.

- Fixes #5899
2012-05-20 06:21:32 -05:00
Dmitry Vorotilin
32a433e1c0 Show in log correct wrapped keys 2012-05-20 09:33:56 +04:00
kennyj
e5e2ba14c3 Don't use assert_block method. It will be deprecated. 2012-05-20 00:14:40 +09:00
Carlos Antonio da Silva
0e207a499f Clarify grouped_options_for_select method API, add changelog entry
Make the method API more clear by explicitly showing the expected
arguments. This means that the options cannot be passed as second
argument because we are not relying on extract_options! anymore,
you are expected to give a selected key or `nil` if you want to pass
options, as it is the last argument.

Notice that this does not change the current method arguments contract
available in 3.2, it just brings back the same functionality with the
divider addition.
2012-05-19 09:58:14 -03:00
Jeremy Kemper
49b72fa864 Merge pull request #6384 from ihid/tidy_text_helpers
Tidied and standardised text_helper implementations.
2012-05-18 17:15:32 -07:00
Jeremy Walker
7e82ebd25e Tidied and standardised text_helper implementations. 2012-05-19 00:39:31 +01:00
kennyj
130b0d215d Fix build: can't convert Regexp to String 2012-05-19 05:13:28 +09:00
Andrew Mutz
2c423b3f3f reverting decoupling of NumberHelper from safe_join and adding tests for escaping of delimiters and separators 2012-05-18 11:56:18 -07:00
José Valim
a6a8957132 Merge pull request #6372 from richo/bugs/middleware_stack_as_array
Add some common Array methods to the middleware stack
2012-05-17 23:45:43 -07:00
José Valim
6bb86e1f3f Merge pull request #5020 from KL-7/fix-blank-image_tag-source
Render img tag with empty src if empty string is passed to image_tag.
2012-05-17 23:42:37 -07:00
Rich Healey
793205cccf Add the #unshift method to the middleware stack
The docs suggest that the middleware stack is an Array, so I've added
the unshift method to it. Originally I added some more Array methods,
but it was agreed that they lacked usecases.
2012-05-18 16:41:52 +10:00
Alex Soulim
446940c366 Add HTML5 input[type="time"] helper 2012-05-18 08:38:19 +04:00
Kirill Lashuk
3e9ec2411a Render img tag with empty src if empty string is passed to image_tag. 2012-05-18 01:39:39 +03:00
Jeremy Walker
90ec863b1d Removed old text_helper apis for highlight, excerpt and word_wrap 2012-05-17 21:52:49 +01:00
Rafael Mendonça França
319903bde5 Merge pull request #2036 from Bodacious/tag_helper_data_fix
TagHelper creates invalid data attributes when value is a BigDecimal
2012-05-17 11:01:21 -07:00
José Valim
f5ebc9a232 Merge pull request #6309 from steveklabnik/fix-2394
Created a Raw handler for templates.
2012-05-17 10:19:27 -07:00
Bodacious
56aabfd559 Fixed tag_helper data-attribute bug with BigDecimals 2012-05-17 18:15:43 +01:00
Steve Klabnik
8bea607265 Created a Raw handler for templates.
Fixes #2394
2012-05-17 12:14:20 -05:00
Rafael Mendonça França
982ed06b3a Make :prompt work as documented 2012-05-16 20:53:28 -03:00
Rafael Mendonça França
6f04975272 Test deprecation and fix the documentation of grouped_options_for_select 2012-05-16 20:53:28 -03:00
Aaron Patterson
66cbde016c Merge pull request #5369 from Greenie0506/add_separator_to_grouped_options_for_select
Add separator option to grouped_options_for_select
2012-05-16 16:15:50 -07:00
Rafael Mendonça França
7994496ab4 Merge pull request #6273 from KensoDev/feature/simple_format_refactoring
Feature/simple format refactoring
2012-05-15 15:58:11 -07:00
Greenie0506
a1ae17e327 Add separator argument to grouped_options_for_select
Change prompt to options hash in grouped_options_for_select
2012-05-15 13:45:12 -04:00
José Valim
dd42e89058 Revert "Revert "Remove :disable_with in favor of 'data-disable-with' option from submit_tag, button_tag and button_to helpers.""
Finally remove `:disable_with` but use `:data => { :disable_with => ... }`
in examples to show off a better API (which looks nicer in Ruby 1.9)

This reverts commit a5c38a9c087e33d36397afc496be7c8e01b37ef0.
2012-05-15 10:08:51 +02:00
José Valim
a5c38a9c08 Revert "Remove :disable_with in favor of 'data-disable-with' option from submit_tag, button_tag and button_to helpers."
`disable_with:` is much easier to type than `"data-disable-with" =>`,
and the fact it uses "data-disable-with" => is an implementation concern,
it should not affect the public API.

This reverts commit 683fc4db00f496e5225928afb4d4e932e0fcdc48.
2012-05-15 09:55:30 +02:00
Kornelius Kalnbach
0d3172c4e4 add tests and external file backtrace for Routing::Mapper#draw 2012-05-15 04:28:10 +02:00
Carlos Galdino + Rafael Mendonça França
683fc4db00 Remove :disable_with in favor of 'data-disable-with' option from submit_tag, button_tag and button_to helpers. 2012-05-14 16:42:19 -03:00
Avi Tzurel
4bb14b0daa Added the wrapper tag option to simple_format 2012-05-14 16:55:41 +03:00
Rafael Mendonça França
71931e2ef1 Remove :mouseover option from image_tag helper. 2012-05-13 19:55:44 -03:00
Rafael Mendonça França
2ef29ef9af Merge pull request #3237 from sakuro/data-url-scheme
Support data: url scheme

Conflicts:
	actionpack/lib/action_view/asset_paths.rb
2012-05-13 19:28:56 -03:00