Commit Graph

130 Commits

Author SHA1 Message Date
Andrew White ab2c0fd621 Respect Accept header when there is no :format
Previously when making a request to a URL without a format and a
non-HTML Accept header the content type would be returned as
`text/html` even if it was meant to be another type like JSON.

To fix this people had to manually set a route default to whatever
was their desired content type was but this workaround couldn't
handle routes with multiple content types.

This commit fixes it by determining the extension from the request
object if there is no `:format` parameter set in the params. For
backwards compatibility if the Accept header indicates a HTML
request then the fragment is saved without an extension - otherwise
upgrading to this version of the gem would invalidate all existing
cached actions and cause possible cache storms/thundering herds
when deployed to production.

Some consideration was given to expiring both extension-less paths
and paths with `.html` when `expire_action` is called with a `"html"`
format parameter but it's probably best left to the application
developer as it could expire items from caches unexpectedly.

Fixes #18.
2016-11-12 17:06:58 +00:00
Andrew White 900e4add3a Correct syntax of examples and show new `to_proc` option 2016-11-12 12:12:53 +00:00
Andrew White 309b42925c Merge pull request #33 from eileencodes/upgrade-to-rails-5
Upgrade to Rails 5
2016-11-12 11:06:20 +00:00
Andrew White 8b679b1a2e Add rubocop and fix offenses 2016-11-12 11:05:36 +00:00
Andrew White 54bd795609 Handle positional vs. kwargs for get
In Rails 5.0 positional args for HTTP request methods were deprecated
so conditionally override get to do the transition from kwargs to
the older positional format.
2016-11-12 11:05:36 +00:00
Andrew White fe96863f29 Send params as strings
In Rails 5.0 we changed to converting true/false to strings whereas
previously they were passed to the controller action unchanged so
send them as strings for consistency.
2016-11-12 11:05:36 +00:00
Andrew White 5438d91095 Add random test ordering where available 2016-11-12 11:05:35 +00:00
Andrew White 3012c25773 No need to check if fragment responds to :each 2016-11-12 11:05:35 +00:00
Andrew White ba11500f96 Handle render :plain in test case controller 2016-11-12 11:05:35 +00:00
Andrew White 83243ce9e4 Tidy up and standardise test temporary directory 2016-11-12 11:05:35 +00:00
Andrew White e788c0847d Move view paths setting to controller 2016-11-12 11:05:35 +00:00
Andrew White b6b6b70eee Handle the deprecation of render :text
In 4.1 render :text was deprecated and replaced with :plain and :html so
we need to conditional define a method to handle the difference.
2016-11-12 11:05:35 +00:00
Andrew White 54e3632f12 Move routing inline to test cases
As `/:controller/:action` routes are deprecated use explicit routes
declared inline inside individual test cases.
2016-11-12 11:05:35 +00:00
Andrew White b572b4f40e Test the gem with 4.0, 4.1, 4.2, 5.0 and master 2016-11-12 11:05:35 +00:00
Andrew White 589a67f675 Tidy up ignores - not need for most of these 2016-11-12 11:05:35 +00:00
eileencodes f9736a3a59 Upgrade travis to run on new infrastructure
More info here:
https://docs.travis-ci.com/user/migrating-from-legacy/
2016-11-12 11:05:35 +00:00
eileencodes fca0f0795f Set Ruby version to 2.2.2
Rack and Rails require Ruby 2.2.2 so we need to upgrade travis to use
only Ruby 2.2.2 and set the minimum version in the gemspec.

This means we'll have to split this peripheral gem into 2 releases. One
for the 4 apps and one for the 5 apps because the changes required by
Rails 5 won't work on older version.
2016-11-12 11:05:35 +00:00
eileencodes e26b768299 Replace use of assigns in test
`assigns` was removed from Rails and using `instance_variable_get` is
the new correct way to assign an instance variable in tests.
2016-11-12 11:05:34 +00:00
eileencodes 37e5427c5d Check for false in proc
In rails/rails@394b7be parameters set were changed to query strings to
behave more like a real browser. In a browser the parameters `false`
will never get sent as `false` and will always be `"false"`. Because
of this change the test for passing `false` into this `Proc` was
failing. We need to change it to check if the layout is not false rather
than relying on the value in the parameters.
2016-11-12 11:05:34 +00:00
eileencodes 882b02aa40 Fix render nothing deprecation warning
`render nothing:` is deprecated. If you want nothing rendered you should
use `head :ok`.
2016-11-12 11:05:34 +00:00
eileencodes d148b817b7 Fix keyword args dep notice
Rails now requires kwargs in test requests. This sets `params`,
`format`, and `headers` accordingly to fix the deprecation warning.
2016-11-12 11:05:34 +00:00
eileencodes 9dd3a7139d Fix render text deprecation warning
`render text:` is no longer a valid way to render just text content. The
correct way is to use `render plain:`. `render text:` is deprecated.
2016-11-12 11:05:34 +00:00
eileencodes 8d5bab7bf1 Change `*_filter` to `*_action`
`before_filter` is now `before_action`. I've changed this to remove the
deprecation warning.
2016-11-12 11:05:34 +00:00
eileencodes 6ae36ce76b Upgrade gem to Rails 5
This sets the dependency to allow Rails 5.

In upgrading to Rails 5 we require Ruby 2 and changes that are made here
will not work on older versions of Rails. Because of that I'm bumping
the version to 2.0.0.
2016-11-12 11:05:34 +00:00
Andrew White e571c6a324 Merge pull request #22 from estum/cache-path-symbol
Support symbols in :cache_path option
2016-11-06 19:36:00 +00:00
Andrew White fc821458a1 Merge pull request #24 from SoftSwiss/cache_key
Add test for non url cache_key
2016-11-06 19:29:26 +00:00
Roman Shatsov 30c550a120 add test for non url cache_key 2015-05-27 10:38:57 +03:00
Anton e955b32b88 Support symbols in :cache_path option
This tiny commit allows to use symbols in the `:cache_path` option via
the standard behavior of `Symbol#to_proc`. The controller's instance
method pointed by the symbol should be in a `protected` scope.
2015-04-09 02:24:54 +03:00
Rafael Mendonça França 30ae10cba0 Merge pull request #21 from claudiob/fix-tests
Fix tests
2015-01-06 19:40:24 -03:00
claudiob b604120c78 Fix failing tests by requiring mocha
Now that the rails gem points to 4.2, we need to require mocha in order
to use the `expects` syntax, otherwise tests will fail. See:
https://travis-ci.org/rails/actionpack-action_caching/jobs/46021642
2015-01-06 08:47:14 -08:00
Rafael Mendonça França 1ac6fb2184 Merge pull request #20 from claudiob/patch-1
Update README: still maintained after Rails 4.2.
2015-01-05 22:30:12 -03:00
Claudio B. 93f99972e2 Update README: still maintained after Rails 4.2.
According to @rafaelfranca, this repo almost doesn't have issues and
it's hard to break, so we can keep on maintaining it even now that
Rails 4.2 is out.

Once we want to remove support, we will probably announce it with an
official statement in a blog post.

[ci skip]
2015-01-05 17:28:53 -08:00
Rafael Mendonça França a9f3f09477 Merge pull request #16 from christianv/patch-1
Update README - use svg instead of png
2014-05-01 19:24:58 -03:00
Christian Vuerings 46c6668879 Update README - use svg instead of png
Changed the png build badges to svg.
2014-04-24 09:03:32 -07:00
Rafael Mendonça França 57f8d1950f Merge pull request #14 from amatsuda/use_railtie
Use defined Railtie rather than directly load the monkey-patch
2014-02-12 14:43:14 -02:00
Akira Matsuda 43dfcf04c3 Use defined Railtie rather than directly load the monkey-patch 2014-02-12 16:57:29 +09:00
Andrew White 782bf073e0 Call to_s on the extension as it may be a symbol. Fixes #10 2014-01-04 12:19:18 +00:00
Francesco Rodriguez a45e97298f Add license information to gemspec. 2013-11-19 01:59:23 -05:00
Andrew White c510fe75c4 Include the features when ActionController::Base is loaded
This will make this gem not load order dependent.

See https://github.com/rails/actionpack-page_caching/issues/6#issuecomment-27660871
2013-11-15 16:18:46 +00:00
Rafael Mendonça França c701ad9a2e Release 1.1.0 2013-11-01 11:39:24 -02:00
Rafael Mendonça França 3e183e08c2 Allow failures on edge 2013-11-01 09:56:06 -02:00
Rafael Mendonça França 25632cece1 Test with the released gem 2013-10-31 18:49:29 -02:00
Rafael Mendonça França daf0527149 Merge pull request #8 from johanneswuerbach/patch-1
Reference stable rails 4.0 release to avoid bundler issues
2013-10-31 13:42:08 -07:00
Johannes Würbach ffcb0c925c Reference stable rails 4.0 release to avoid bundler issues 2013-10-31 13:18:10 -07:00
Rafael Mendonça França a09d15f64f Fix typo
Closes #6
2013-07-01 10:46:44 -03:00
Francesco Rodriguez d70fc3b92b update maintenance note [ci skip] 2013-05-01 18:27:53 -05:00
Francesco Rodriguez 3adb7fe15c less strict Rails version 2013-05-01 18:23:07 -05:00
Francesco Rodriguez bb146208fd fix .travis.yml 2013-05-01 18:19:11 -05:00
Francesco Rodriguez 1dd550675c add support for Rails edge (4.1) 2013-05-01 18:18:14 -05:00
Francesco Rodriguez 94394eb398 use Rails 4-0-stable branch by default 2013-05-01 18:17:16 -05:00