Commit Graph

4427 Commits

Author SHA1 Message Date
kennyj
5225c1a472 Fix build about TemplateDigestorTest. 2012-08-30 23:55:42 +09:00
Christos Zisopoulos
17f2499f04 Digestor can now parse old style hash syntax for render 2012-08-30 13:13:47 +02:00
Christos Zisopoulos
21bad7445b Digestor ignores most whitespace when parsing render invocations 2012-08-30 13:01:25 +02:00
David Heinemeier Hansson
ed5c938fa3 Added controller-level etag additions that will be part of the action etag computation *Jeremy Kemper/DHH* 2012-08-29 15:06:30 -05:00
David Heinemeier Hansson
502d5e24e2 Add automatic template digests to all CacheHelper#cache calls (originally spiked in the cache_digests plugin) *DHH* 2012-08-29 14:23:56 -05:00
schneems
0b6175ac2d Add Missing Keys from Journey on failed URL format
Many named routes have keys that are required to successfully resolve. If a key is left off like this:

    <%= link_to 'user', user_path %>

This will produce an error like this:

    No route matches {:action=>"show", :controller=>"users"}

Since we know that the :id is missing, we can add extra debugging information to the error message.

    No route matches {:action=>"show", :controller=>"users"} missing required keys: [:id]


This will help new and seasoned developers look closer at their parameters. I've also subclassed the routing error to be clear that this error is a result of attempting to generate a url and not because the user is trying to visit a bad url. 

While this may sound trivial this error message is misleading and confuses most developers. The important part isn't what's in the options its's what's missing. Adding this information to the error message will make debugging much more obvious. 

This is the sister pull request of https://github.com/rails/journey/pull/44 which will be required to get they missing keys into the correct error message. 

Example Development Error in Rails: http://cl.ly/image/3S0T0n1T3421
2012-08-28 08:53:45 -07:00
Rafael Mendonça França
e4b33b08d6 Add missing require 2012-08-28 10:12:49 -03:00
Rafael Mendonça França
7256cb53e0 Merge pull request #7452 from arunagw/memcached_dalli
Memcached to dalli for actionpack test.
2012-08-28 05:27:34 -07:00
Piotr Sarnacki
e1ffd82e76 Deprecate AV::RecordIdentifier in controllers
Methods provided by RecordIdentifier are not widely used in controllers
nowadays as they're view specific (this is probably a legacy left after
RJS rendering directly in controllers). However if people still need to
use it, it's trivial to include ActionView::RecordIdentifier by
themselves.
2012-08-28 11:19:37 +02:00
Piotr Sarnacki
f4d493ed7c Fix ActionView::RecordIdentifier to work as a singleton
We extend it with self, but the methods were not working properly were
used directly on module.
2012-08-28 11:19:37 +02:00
Piotr Sarnacki
582a7f4599 Deprecate Template#mime_type 2012-08-28 11:19:36 +02:00
Piotr Sarnacki
dc663dd52c Don't require action_dispatch in ActionView::UrlHelpers
ActionDispatch::Routing::UrlFor was always required in UrlHelpers. This
was changed by splitting previous implementation of UrlHelper into 2
modules: ActionView::Helpers::UrlHelper and
ActionView::Routing::UrlHelper. The former one keeps only basic
implementation of url_for. The latter adds features that allow to use
routes and is only required when url_helpers or mounted_helpers are
required.
2012-08-28 11:19:29 +02:00
Piotr Sarnacki
9b0ac0bc74 Use ActionView::Base.logger instead of AC::Base.logger 2012-08-28 10:51:05 +02:00
Piotr Sarnacki
45efb665f0 Add ActionView::Base.default_formats
default_formats array is used by LookupContext in order to allow
rendering templates when :formats option is not passed. Previously it
was always set to Mime::SET, which created dependency on Action Pack. In
order to remove this dependency, Mime::SET is used only if
ActionController is loaded.
2012-08-28 10:51:04 +02:00
Piotr Sarnacki
7abc0c73bd Deprecate mime types lookup in auto_discovery_link_tag
Automatically handling mime types for things other than :rss and :atom
is not functionality that justifies dependency on Mime::Type from
actionpack.
2012-08-28 10:51:04 +02:00
Piotr Sarnacki
731bb2fe68 Remove stubs from LogSubscriber tests
We can use another way to instantiate ActionView::Base, by passing
renderer as a first option. Thanks to that we can just pass prefixes to
LookupContext instead stubbing them on the controller. This is also good,
because that kind of API is used in Rails code.
2012-08-28 10:51:04 +02:00
Piotr Sarnacki
ba83aa7f03 Move action_controller/vendor/html-scanner to action_view
This is another step in moving Action View's dependencies in Action Pack
to Action View itself. Also, HtmlScanner seems to be better suited for
views rather than controllers.
2012-08-28 10:51:03 +02:00
Piotr Sarnacki
264624049e Move ActionController::RecordIdentifier to ActionView
Since it's more about DOM classes and ids it belongs to Action View
better. What's more, it's more convenient to make it part of Action View
to follow the rule that Action Pack can depend on Action View, but not
the other way round.
2012-08-28 10:51:03 +02:00
Arun Agrawal
834a5a9c7e Let's run action pack tests with Dalli
There is no memcache gem left in repo.
2012-08-27 09:46:35 +05:30
Carlos Antonio da Silva
af31cf0672 Create variable only in the test that uses it
Instead of building a Blog::Post instance for every test in form helper
tests, just build it in the test that uses it.
2012-08-25 21:52:24 -03:00
Vasiliy Ermolovich
130fe2b172 correct handling of date selects when using both disabled and discard options
we should take disabled option not only from `html_options` hash but from
`options` hash too like `build_select` method does it. So

datetime_select("post", "updated_at", { :discard_minute => true }, { :disabled => true })
datetime_select("post", "updated_at", :discard_minute => true , :disabled => true)

both these variants work now

closes #7431
2012-08-25 19:02:41 +03:00
Prem Sichanugrist
0ffe19056c Extract ActiveRecord::SessionStore from Rails
This functionality will be available from gem
`active_record-session_store` instead.
2012-08-24 15:24:19 -04:00
Sandeep
99322266b8 option_tags coerced to "" instead of nil 2012-08-21 21:59:05 +05:30
Pratik Naik
6a5d1c765f Make sure :via works with mount 2012-08-20 10:25:23 -05:00
tomykaira
503c1c04ad Access @rs only through attr_accessor 2012-08-20 21:47:00 +09:00
Jim Jones
4848bf321b Added X-Content-Type-Options to the header defaults.
With a value of "nosniff", this prevents Internet Explorer from MIME-sniffing a response away from the declared content-type.
2012-08-18 15:29:58 -07:00
Carlos Antonio da Silva
ebb4a3d5be Merge pull request #7244 from lucasuyezu/master
Fix indentation on template errors to consider line number character count.

For instance, when an error is shown, if the related source code snippet has line numbers from, lets say, 8-12, the lines are left aligned, which means the code indent is wrong:

    8: foo
    9: bar
    10: raise
    11: baz
    12: ...

This changes it to right align the source code snippet, so that the indentation is correct:

     8: foo
     9: bar
    10: raise
    11: baz
    12: ...
2012-08-15 09:15:31 -07:00
Rafael Mendonça França
546497d027 Extract common controllers to abstract_unit 2012-08-13 21:43:18 -03:00
Rafael Mendonça França
0dd24728a0 Implementing Routing Concerns
This pattern was introduced as a plugin by @dhh.

The original implementation can be found in
https://github.com/rails/routing_concerns
2012-08-13 21:41:53 -03:00
Lucas Uyezu
6446e84c1a Indentation should consider line number character count. 2012-08-13 18:49:47 -03:00
Aaron Patterson
38a3fed404 push header merge down to a private method so that live responses can have their own header object 2012-08-13 14:20:04 -04:00
Aaron Patterson
8f0541b702 live response headers can be merged with a hash 2012-08-13 13:57:26 -04:00
Evan Tann
1edc7cd78b Add support for start_hour and end_hour options in select_hour helper
Updated documentation to demonstrate start_hour and end_hour options
2012-08-13 12:26:23 -04:00
Carlos Antonio da Silva
a513cc1862 Ensure option_html_attributes does not modify the given option hashes
We can avoid creating extra hashes with #merge, and use #merge! instead.
2012-08-11 14:17:01 -03:00
Carlos Antonio da Silva
e8e8617c39 Simplify html attributes generation for options_for_select
Further simplify the option_html_attributes method after the changes
introduced in dacbcbe55745aa9e5484b10b11f65ccca7db1c54 to not escape the
html options here (since they're going to be escaped down the chain in
content tag).
2012-08-11 14:04:22 -03:00
Rafael Mendonça França
a6e0d8cfcf Merge pull request #7314 from schneems/schneems/form_for_error
Check for Blank Record in form_for
2012-08-10 20:09:21 -07:00
schneems
60b650b18c check for nil or empty record in form_for
if nil or an empty array is passed into form_for you get a horrible error message, this one is much more indicative of what the programmer needs to know to fix the problem.
2012-08-10 22:02:48 -05:00
Piotr Sarnacki
5b3bb61f3f Fix handling SCRIPT_NAME from within mounted engine's
When you mount your application at a path, for example /myapp, server
should set SCRIPT_NAME to /myapp. With such information, rails
application knows that it's mounted at /myapp path and it should generate
routes relative to that path.

Before this patch, rails handled SCRIPT_NAME correctly only for regular
apps, but it failed to do it for mounted engines. The solution was to
hardcode default_url_options[:script_name], which is not the best answer
- it will work only when application is mounted at a fixed path.

This patch fixes the situation by respecting original value of
SCRIPT_NAME when generating application's routes from engine and the
other way round - when you generate engine's routes from application.

This is done by using one of 2 pieces of information in env - current
SCRIPT_NAME or SCRIPT_NAME for a corresponding router. This is because
we have 2 cases to handle:

- generating engine's route from application: in this situation
  SCRIPT_NAME is basically SCRIPT_NAME set by the server and it
  indicates the place where application is mounted, so we can just pass
  it as :original_script_name in url_options. :original_script_name is
  used because if we use :script_name, router will ignore generating
  prefix for engine

- generating application's route from engine: in this situation we
  already lost information about the SCRIPT_NAME that server used. For
  example if application is mounted at /myapp and engine is mounted at
  /blog, at this point SCRIPT_NAME is equal /myapp/blog. Because of that
  we need to keep reference to /myapp SCRIPT_NAME by binding it to the
  current router. Later on we can extract it and use when generating url

Please note that starting from now you *should not* use
default_url_options[:script_name] explicitly if your server already
passes correct SCRIPT_NAME to rack env.

(closes #6933)
2012-08-11 00:21:46 +02:00
brainopia
e157903310 Test actual content of permanent cookie 2012-08-10 09:48:26 +04:00
Aaron Patterson
581a927710 set the controller under test so we no longer need the reset! method 2012-08-09 18:06:13 -07:00
Santiago Pastorino
d8cf713afa Do not mark strip_tags result as html_safe
Thanks to Marek Labos & Nethemba

CVE-2012-3465
2012-08-09 18:51:05 -03:00
Aaron Patterson
c63d17c2be push drawing once to it's own module 2012-08-09 14:50:27 -07:00
Aaron Patterson
1e8c0a29d0 refactor the before_setup hooks to a module 2012-08-09 14:50:26 -07:00
Aaron Patterson
0b29c7bb7b switch callbacks to minitest hooks 2012-08-09 14:50:26 -07:00
Egor Homakov
98c18d0058 some tests 2012-08-09 17:12:11 +03:00
David Heinemeier Hansson
b540f4c1b8 Allow data attributes to be set as a first-level option for form_for, so you can write form_for @record, data: { behavior: 'autosave' } instead of form_for @record, html: { data: { behavior: 'autosave' } } *DHH* 2012-08-08 16:36:46 -05:00
Rafael Mendonça França
5d1528740a Deprecate button_to_function and link_to_function helpers.
We recommend the use of Unobtrusive JavaScript instead. For example:

  link_to "Greeting", "#", :class => "nav_link"

  $(function() {
    $('.nav_link').click(function() {
      // Some complex code

      return false;
    });
  });

or

  link_to "Greeting", '#', onclick: "alert('Hello world!'); return false", class: "nav_link"

for simple cases.

This reverts commit 3acdd652e9fe99481c879c84c5807a84eb9ad724.
2012-08-07 20:57:42 -03:00
David Heinemeier Hansson
666d3fd0c1 Revert "Merge pull request #7033 from kron4eg/master". Not a a fan at all of what this makes ERB files look like.
This reverts commit 46b8bceedd3e47169c50a04c93161424909c75fb, reversing
changes made to 2f58795e783150f2e1b1f6c64e305703f0061129.
2012-08-07 11:44:24 -05:00
Artiom Di
e82ffeaa0a Restoring the '%' trim mode for ERb templates, allowing for a leading percent sign on a line to indicate non-inserted Ruby code. 2012-08-07 12:37:56 +03:00
Prem Sichanugrist
02c9654b9b Do not include application.js if it doesn't exists
Rails were including 'application.js' to the pack when using
`javascript_include_tag :all` even there's no application.js in the
public directory.
2012-08-06 16:45:10 -04:00