Commit Graph

104 Commits

Author SHA1 Message Date
Rafael Mendonça França
fe1f4b2ad5
Add more rubocop rules about whitespaces 2016-10-29 01:17:49 -02:00
Rafael Mendonça França
d7be30e8ba
Remove deprecated methods related to controller filters
`skip_action_callback`, `skip_filter`, `before_filter`,
`prepend_before_filter`, `skip_before_filter`,
`append_before_filter`, `around_filter`
`prepend_around_filter`, `skip_around_filter`,
`append_around_filter`, `after_filter`,
`prepend_after_filter`, `skip_after_filter` and
`append_after_filter`.
2016-10-09 23:56:14 -03:00
Ryuta Kamizono
f006de5dc5 Fix broken alignments caused by auto-correct commit 411ccbd
Hash syntax auto-correcting breaks alignments. 411ccbdab2608c62aabdb320d52cb02d446bb39c
2016-08-10 06:36:39 +09:00
Xavier Noria
b326e82dc0 applies remaining conventions across the project 2016-08-06 20:20:22 +02:00
Xavier Noria
80e66cc4d9 normalizes indentation and whitespace across the project 2016-08-06 20:16:27 +02:00
Xavier Noria
411ccbdab2 remove redundant curlies from hash arguments 2016-08-06 19:44:11 +02:00
Xavier Noria
5b6eb1d58b modernizes hash syntax in actionpack 2016-08-06 19:35:13 +02:00
Xavier Noria
35b3de8021 applies new string literal convention in actionpack/test
The current code base is not uniform. After some discussion,
we have chosen to go with double quotes by default.
2016-08-06 18:54:50 +02:00
Aaron Patterson
8941831733 Revert "ActionController::Base#process() now only takes an action name"
This reverts commit 9f93a5efbba3e1cbf0bfa700a17ec8d1ef60d7c6.
2015-10-29 16:18:27 -07:00
Aaron Patterson
9f93a5efbb ActionController::Base#process() now only takes an action name
rather than an action name and *args.  The *args were not being used in regular
applications outside tests.  This causes a backwards compatibility
issue, but reduces array allocations for most users.
2015-10-29 15:40:18 -07:00
Jeremy Daer
565094a8b5 Use Mime[:foo] instead of Mime::Type[:FOO] for back compat
Rails 4.x and earlier didn't support `Mime::Type[:FOO]`, so libraries
that support multiple Rails versions would've had to feature-detect
whether to use `Mime::Type[:FOO]` or `Mime::FOO`.

`Mime[:foo]` has been around for ages to look up registered MIME types
by symbol / extension, though, so libraries and plugins can safely
switch to that without breaking backward- or forward-compatibility.

Note: `Mime::ALL` isn't a real MIME type and isn't registered for lookup
by type or extension, so it's not available as `Mime[:all]`. We use it
internally as a wildcard for `respond_to` negotiation. If you use this
internal constant, continue to reference it with `Mime::ALL`.

Ref. efc6dd550ee49e7e443f9d72785caa0f240def53
2015-10-06 11:29:30 -07:00
Aaron Patterson
e4ba720c17 stop calling deprecated methods
We should be asking the mime type method for the mime objects rather
than via const lookup
2015-09-21 12:04:12 -07:00
Marcin Olichwirowicz
3a161e65e7 Get rid of mocha tests - part 1 2015-08-24 12:24:07 +02:00
Rafael Mendonça França
76f6524538 Merge pull request #11790 from printercu/patch-3
ActionController#translate supports symbols
2015-02-12 15:39:17 -02:00
Abdelkader Boudih
7644a99d90 Deprecate all *_filter callbacks in favor of *_action callbacks 2015-01-08 20:52:36 +00:00
Rafael Mendonça França
489a8f2a44 Partially revert deprecation of *_filter
We are going to deprecate only on Rails 5 to make easier plugin
maintainers support different Rails versions. Right now we are only
discouraging their usage.

This reverts commit 6c5f43bab8206747a8591435b2aa0ff7051ad3de.

Conflicts:
	actionpack/CHANGELOG.md
2014-06-03 19:53:28 -03:00
Rafael Mendonça França
6c5f43bab8 Deprecate all *_filter callbacks in favor of *_action callbacks
This is the continuation of the work started at
9d62e04838f01f5589fa50b0baa480d60c815e2c
2014-05-27 19:10:14 -03:00
Zuhao Wan
45c396bd82 Ensure :js is defined regardless of the outcome of the test. 2014-05-17 19:09:09 +08:00
Łukasz Strzałkowski
2d3a6a0cb8 Action Pack Variants
By default, variants in the templates will be picked up if a variant is set
and there's a match. The format will be:

  app/views/projects/show.html.erb
  app/views/projects/show.html+tablet.erb
  app/views/projects/show.html+phone.erb

If request.variant = :tablet is set, we'll automatically be rendering the
html+tablet template.

In the controller, we can also tailer to the variants with this syntax:

  class ProjectsController < ActionController::Base
    def show
      respond_to do |format|
        format.html do |html|
          @stars = @project.stars

          html.tablet { @notifications = @project.notifications }
          html.phone  { @chat_heads    = @project.chat_heads }
        end

        format.js
        format.atom
      end
    end
  end

The variant itself is nil by default, but can be set in before filters, like
so:

  class ApplicationController < ActionController::Base
    before_action do
      if request.user_agent =~ /iPad/
        request.variant = :tablet
      end
    end
  end

This is modeled loosely on custom mime types, but it's specifically not
intended to be used together. If you're going to make a custom mime type,
you don't need a variant. Variants are for variations on a single mime
types.
2013-12-04 00:13:16 +01:00
Max Melentiev
fde7344542 ActionController#translate also lookups shortcut without action name 2013-10-22 18:17:05 +04:00
printercu
40a8130bc5 ActionController#translate supports symbols
Made it similar to views helper.
2013-09-25 16:23:28 +04:00
Łukasz Strzałkowski
e10a25310f Move abstract's controller tests to AV
The ones that were actually testing AV functionality and should belong in there
2013-08-25 11:40:11 +02:00
Łukasz Strzałkowski
8e3413d410 Create AbstractController::Rendering interface
This interface should be use when implementing renderers.
2013-08-25 11:39:09 +02:00
Łukasz Strzałkowski
8c2c95e5d2 Fix AP test suite after moving stuff to AV 2013-08-25 11:39:08 +02:00
Yves Senn
3af7b16c11 add test-case to verify error.path when a helper was not found.
This verifies the code added with:
99c9d18601
2013-07-12 15:40:47 +02:00
Yves Senn
5bee14f3a4 move MissingHelperError out of the ClassMethods module. 2013-07-12 15:34:29 +02:00
Marc Schütz
90e420e406 Remove accidentally committed vi .swp file. 2013-07-10 16:06:40 +02:00
Piotr Niełacny
e0438b1c07 Show real LoadError on helpers require
When helper try to require missing file rails will throw exception about
missing helper.

  # app/helpers/my_helper.rb

  require 'missing'

  module MyHelper
  end

And when we try do load helper

  class ApplicationController
    helper :my
  end

Rails will throw exception. This is wrong because there is a helper
file.

  Missing helper file helpers/my_helper.rb

Now when helper try to require non-existed file rails will throw proper
exception.

  No such file to load -- missing
2013-07-10 11:26:43 +02:00
printercu
14c196e5a3 Avoid leak into controller's action_methods 2013-04-18 20:03:31 +04:00
Anupam Choudhury
d18e8b1a38 Refactored to remove unused variable 2013-03-28 15:58:03 +05:30
Rafael Mendonça França
e7438501d6 Merge pull request #8458 from lucisferre/improve-layout-override-fallback-behavior
Provides standard layout lookup behavior for method and proc cases

Conflicts:
	actionpack/CHANGELOG.md
2013-03-27 16:09:12 -03:00
Chris Nicola
ef27bba63d Provides standard layout lookup behavior for method and proc cases
When setting the layout either by referencing a method or supplying a
Proc there is no way to fall back to the default lookup behavior if
desired. This patch allows fallback to the layout lookup behavior when
returning nil from the proc or method.
2013-03-27 10:59:50 -07:00
Prathamesh Sonpatki
ba7c9d76af Changed 'args' to 'arguments' in test description 2013-03-24 02:27:43 +05:30
Carlos Antonio da Silva
57b65ef416 Fix setting expected value in translation tests
It was being set to nil instead due to the wrong assignment.
2013-01-21 09:29:03 -02:00
Jens Bissinger
4685d75736 Removed ActionController::Base dependency from abstract controller translation tests. 2013-01-20 15:53:43 +01:00
Jens Bissinger
1de60c54d3 Test abstract controller's localize method. 2013-01-20 15:44:03 +01:00
Akira Matsuda
70ae89c321 Remove unnecessary begin..rescue..end, use only rescue 2013-01-06 15:41:14 +09:00
Francesco Rodriguez
1b97d41e52 add tests to aliased _filter callbacks 2012-12-07 15:29:51 -05:00
Francesco Rodriguez
5fb94ec044 use _action instead of _filter callbacks 2012-12-07 15:24:56 -05:00
David Heinemeier Hansson
9d62e04838 Rename all action callbacks from *_filter to *_action 2012-12-07 18:54:44 +01:00
Sergey Pchelincev
1b5298e805 add lazy look up in abstract controller's translate method 2012-07-18 10:33:14 +03:00
Aaron Patterson
cd4a0a3332 we raise a subclass of LoadError, so rescue that 2012-06-14 10:40:23 -07:00
José Valim
dd0275e463 Add a test case for layout nil. 2012-03-28 23:06:52 +04:00
Luke Gruber
08c4d8eac3 use consistent explicit module inclusion
aid ease of understanding and readability for tests
2012-03-16 21:54:25 -04:00
Luke Gruber
aca6937760 allow zero-arity proc for AbstrController::layout
proc without parameters can now be given to
AbstractController::layout
2012-03-15 16:40:23 -04:00
Santiago Pastorino
687db9f86d Add missing require 2012-03-10 19:15:29 -02:00
Santiago Pastorino
4751a699c9 AbstractController.action_methods should return a Set 2012-03-10 18:37:30 -02:00
Alexey Vakhov
b27c29ef4a Fix layout lookup for anonymous controller 2012-02-28 14:42:57 +04:00
Aaron Patterson
fd918fe5ed AP tests should inherit from AS::TestCase 2012-01-05 17:05:44 -08:00
José Valim
cae1768c6a Remove deprecated layout lookup. 2011-12-20 14:44:48 +01:00