aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
Commit message (Collapse)AuthorAgeFilesLines
...
* | | | stop applying default headers in ActionDispatch::ResponseAaron Patterson2015-09-231-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I'm making this change so that I can construct response objects that *don't* have the default headers applied. For example, I would like to construct a response object from the return value of a controller. If you need to construct a response object with the default headers, then please use the alternate constructor: `ActionDispatch::Response.create`
* | | | don't access the response object before a request was madeAaron Patterson2015-09-231-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | It doesn't make sense to access the response object before a request is made (how was a response object created without making a request?) This commit splits testing default headers and default header mutation tests and removes access to the pre-request response object.
* | | | split cookie testsAaron Patterson2015-09-231-1/+6
| | | | | | | | | | | | | | | | these should really be multiple tests.
* | | | don't mutate a response object after to_aAaron Patterson2015-09-231-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | When the response object is `to_a`'d, that means it's been written to the socket. It doesn't make sense to mutate the response object after it's been written (and this may raise an exception in the future).
* | | | Merge pull request #21703 from ronakjangir47/redirect_error_messagesJeremy Daer2015-09-211-2/+4
|\ \ \ \ | | | | | | | | | | Added assertion for error messages for redirection to nil and params
| * | | | Added assertion for error messages for redirection to nil and params Ronak Jangir2015-09-211-2/+4
| | | | | | | | | | | | | | | As both `redirect_to_nil` and `redirect_to_params` are raising same `ActionController::ActionControllerError` so it’s good to assert error messages as well
* | | | | remove html_types setAaron Patterson2015-09-211-1/+1
| | | | | | | | | | | | | | | | | | | | Now that `all` has it's own object, we don't need the html_types Set.
* | | | | introduce an `All` mime typeAaron Patterson2015-09-211-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | This class gives us the `all?` predicate method that returns true without hitting method missing
* | | | | change inheritance to compositionAaron Patterson2015-09-211-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Changes `Mimes` to compose a set rather than inherit from array. With this change we don't need to define as many methods, so ISEQ memory is saved. Also it is clear which methods break the set cache.
* | | | | stop calling deprecated methodsAaron Patterson2015-09-2111-66/+66
| | | | | | | | | | | | | | | | | | | | | | | | | We should be asking the mime type method for the mime objects rather than via const lookup
* | | | | deprecate accessing mime types via constantsAaron Patterson2015-09-211-35/+37
|/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We don't want to manage a list of constants on `Mime::`. Managing constants is strange because it will break method caches, not to mention looking up by a constant could cause troubles. For example suppose there is a top level constant `HTML`, but nobody registers the HTML mime type and someone accesses `Mime::HTML`. Instead of getting an error about how the mime type doesn't exist, instead you'll get the top level constant. So, instead of directly accessing the constants, change this: Mime::HTML To this: Mime::Type[:HTML]
* | | | Added test for `send_file_headers` called with nil content typeRonak Jangir2015-09-191-1/+12
| | | |
* | | | mostly remove the ParamsParser middlewareAaron Patterson2015-09-181-1/+0
| | | | | | | | | | | | | | | | | | | | This can still be added to the middleware stack, but is really not necessary. I'll follow up with a commit that deprecates the constant
* | | | do not instantiate a param parser middlewareAaron Patterson2015-09-181-8/+12
| | | | | | | | | | | | | | | | | | | | | | | | we don't actually need a param parser middleware instance since the request object will take care of parsing parameters for us. For now, we'll just configure the parameter parsers on the request in this class.
* | | | File encoding is defaulted to utf-8 in Ruby >= 2.1Akira Matsuda2015-09-181-1/+0
| | | |
* | | | create a new renderer instance on calls to `for`Aaron Patterson2015-09-141-16/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This changes the renderer class to store the controller and defaults as an instance variable rather than allocating a new class. You can create a new renderer with an new env by calling `Renderer#new` or use new defaults by calling `Renderer#with_defaults` and saving the return value somewhere. Also I want to keep the `env` private since I would like to change the keys in the future. This commit only translates particular keys that the user requested.
* | | | eagerly allocate the renderer objectAaron Patterson2015-09-141-0/+4
| | | | | | | | | | | | | | | | | | | | this means the reader doesn't need to lock, but does have the added cost of a new object created for every controller
* | | | Handle Content-Types that are not :json, :xml, or :url_encoded_formeileencodes2015-09-091-0/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In c546a2b this was changed to mimic how the browser behaves in a real situation but left out types that were registered. When this was changed it didn't take `text/plain` or `text/html` content types into account. This is a problem if you're manipulating the `Content-Type` headers in your controller tests, and expect a certain result. The reason I changed this to use `to_sym` is because if the `Content-Type` is not registered then the symbol will not exist. If it's one of the special types we handle that specifically (:json, :xml, or :url_encoded_form). If it's any registered type we handle it by setting the `path_parameters` and then the `request_parameters`. If the `to_sym` returns nil an error will be thrown. If the controller test sets a `Content-Type` on the request that `Content-Type` should remain in the header and pass along the filename. For example: If a test sets a content type on a post ``` @request.headers['CONTENT_TYPE'] = 'text/plain' post :create, params: { name: 'foo.txt' } ``` Then `foo.txt` should be in the `request_parameters` and params related to the path should be in the `path_parameters` and the `Content-Type` header should match the one set in the `@request`. When c546a2b was committed `text/plain` and `text/html` types were throwing a "Unknown Content-Type" error which is misleading and incorrect. Note: this does not affect how this is handled in the browser, just how the controller tests handle setting `Content-Type`.
* | | | ensure that mutating headers will impact the content_type methodAaron Patterson2015-09-081-0/+5
| | | |
* | | | ensure that content type defaults to text / html when setting charsetAaron Patterson2015-09-081-0/+7
| | | |
* | | | Merge pull request #21502 from ↵Rafael Mendonça França2015-09-081-0/+20
|\ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | bernerdschaefer/bs-polymorphic-url_for-dups-arguments `url_for` does not modify polymorphic options
| * | | | `url_for` does not modify polymorphic optionsBernerd Schaefer2015-09-041-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The `url_for` methods in `actionpack` and `actionview` now make a copy of the provided options before generating polymorphic paths or URLs. The bug in the previous behavior is most noticeable in a case like: url_options = [:new, :post, param: 'value'] if current_page?(url_options) css_class = "active" end link_to "New Post", url_options, class: css_class
* | | | | Make `config.force_ssl` less dangerous to try and easier to disableJeremy Daer2015-09-071-164/+133
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | SSL redirect: * Move `:host` and `:port` options within `redirect: { … }`. Deprecate. * Introduce `:status` and `:body` to customize the redirect response. The 301 permanent default makes it difficult to test the redirect and back out of it since browsers remember the 301. Test with a 302 or 307 instead, then switch to 301 once you're confident that all is well. HTTP Strict Transport Security (HSTS): * Shorter max-age. Shorten the default max-age from 1 year to 180 days, the low end for https://www.ssllabs.com/ssltest/ grading and greater than the 18-week minimum to qualify for browser preload lists. * Disabling HSTS. Setting `hsts: false` now sets `hsts: { expires: 0 }` instead of omitting the header. Omitting does nothing to disable HSTS since browsers hang on to your previous settings until they expire. Sending `{ hsts: { expires: 0 }}` flushes out old browser settings and actually disables HSTS: http://tools.ietf.org/html/rfc6797#section-6.1.1 * HSTS Preload. Introduce `preload: true` to set the `preload` flag, indicating that your site may be included in browser preload lists, including Chrome, Firefox, Safari, IE11, and Edge. Submit your site: https://hstspreload.appspot.com
* | | | | Remove mocha from ActionPack testsMarcin Olichwirowicz2015-09-058-90/+132
| | | | |
* | | | | implement abstract store methodsAaron Patterson2015-09-042-3/+3
|/ / / / | | | | | | | | | | | | converts old ID methods to the new abstract store methods in Rack
* | | | Fix route creation when format is a blank stringeileencodes2015-09-021-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit bff61ba, while reducing allocations, caused a regression when an empty format is passed to a route. This can happen in cases where you're using an anchor tag, for example: `https://example.com/parent/575256966.#child_1032289285`. Because of this change `format` was getting sent in `parameterized_parts` when previously it was not included. This resulted in blank `format`'s being returned as `.` when if there was an extension included it would be `.extension`. Since there was no extension this caused incorrect URL's. The test shows this would result in `/posts/show/1.` instead of `/posts/show/1` which causes bad urls since the format is not present.
* | | | Fix bug where cookies mutated by request were not persistedeileencodes2015-09-011-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With changes made in 8363b8 and ae29142 cookies that are mutated on the request like `cookies.signed = x` were not retained in subsequent tests, breaking cookie authentiation in controller tests. The test added demonstrates the issue. The reason we need to select from non-deleted cookies is because without checking the `@delete_cookies` the `cookie_jar` `@cookies` will send the wrong cookies to be updated. The code must check for `@deleted_cookies` before sending an `#update` with the requests cookie_jar cookies. This follows how the cookie_jar cookies from the request were updated before these changes.
* | | | Merge pull request #19788 from cmdrclueless/actionpack_http_url_ipv6Rafael Mendonça França2015-09-011-0/+45
|\ \ \ \ | | | | | | | | | | Fix broken IPv6 addresses handling
| * | | | Fix broken IPv6 addresses handlingBrian Weaver2015-04-161-0/+45
| | | | |
* | | | | Set the content-type to `text/html` if the options[:html] is trueakihiro172015-08-291-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In this commit, we set the content-type to `text/html` in AbstractController if the `options[:html]` is true so that we don't include ActionView::Rendering into ActionController::Metal to set it properly. I removed the if `options[:plain]` statement because `AbstractController#rendered_format` returns `Mime::TEXT` by default.
* | | | | revises 877e42eXavier Noria2015-08-281-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * A string in the example lacked quotes. * The tests asserted stuff about :last_name, whereas test params do not have that key. * But, the first one passed, why? After hitting my head against the wall and doing some obscure rituals realized the new #require had an important typo, wanted to iterate over the array argument (key), but it ran over its own hash keys (method #keys). * Modified the test to prevent the same typo to happen again. * The second test assigned to an unused variable safe_params that has been therefore removed. * Grammar of the second test description. * Since I was on it, reworded both test descriptions.
* | | | | [Feature] params.require requires array of paramsGaurish Sharma2015-08-281-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This PR adds ability to accept arrays which allows you to require multiple values in one method. so instead of this: ```ruby params.require(:person).require(:first_name) params.require(:person).require(:last_name) ``` Here it will be one line for each params, so say if I require 10params, it will be 10lines of repeated code which is not dry. So I have added new method which does this in one line: ```ruby params.require(:person).require([:first_name, :last_name]) ``` Comments welcome
* | | | | Merge pull request #21384 from ↵Yves Senn2015-08-271-0/+10
|\ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | jeremyf/updating-ActionController-TestSession-to-behave-as-a-hash-with-indifferent Updating TestSession to access with indifference
| * | | | | Updating TestSession to access with indifferenceJeremy Friesen2015-08-261-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The following Rails code failed (with a `KeyError` exception) under test: ```ruby class ApplicationController < ActionController::Base def user_strategy # At this point: # ```ruby # session == { # "user_strategy"=>"email", # "user_identifying_value"=>"hello@world.com" # } # ``` if session.key?(:user_strategy) session.fetch(:user_strategy) end end end ``` When I checked the session's keys (`session.keys`), I got an array of strings. If I accessed `session[:user_strategy]` I got the expected `'email'` value. However if I used `session.fetch(:user_strategy)` I got a `KeyError` exception. This appears to be a Rails 4.2.4 regression (as the code works under Rails 4.2.3). Closes #21383
* | | | | | remove RackDelegation moduleAaron Patterson2015-08-262-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since all controller instances are required to have a request and response object, RackDelegation is no longer needed (we always have to delegate to the response)
* | | | | | include ActionView::Rendering in the minimal controllerAaron Patterson2015-08-261-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | without this module, the content type is not set correctly
* | | | | | Removed duplicate requiring minitest/mock as it is already required in ↵Ronak Jangir2015-08-261-1/+0
|/ / / / / | | | | | | | | | | | | | | | method_call_assertions
* | | | | provide a request and response to all controllersAaron Patterson2015-08-255-4/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Controllers should always have a request and response when responding. Since we make this The Rule(tm), then controllers don't need to be somewhere in limbo between "asking a response object for a rack response" or "I, myself contain a rack response". This duality leads to conditionals spread through the codebase that we can delete: * https://github.com/rails/rails/blob/85a78d9358aa728298cd020cdc842b55c16f9549/actionpack/lib/action_controller/metal.rb#L221-L223
* | | | | Fix another rack SPEC violationAaron Patterson2015-08-251-1/+1
| | | | |
* | | | | rack SPEC doesn't allow `first` on the bodyAaron Patterson2015-08-251-8/+12
| | | | | | | | | | | | | | | | | | | | collect the body and make assert against the collected body
* | | | | adding a direct dispatch method to controller classesAaron Patterson2015-08-251-8/+2
| | | | | | | | | | | | | | | | | | | | This saves a lambda and request allocation on each request.
* | | | | Merge pull request #21368 from rodzyn/remove_mochaKasper Timm Hansen2015-08-255-163/+209
|\ \ \ \ \ | | | | | | | | | | | | Get rid of mocha tests in actionpack - part 2
| * | | | | Get rid of mocha tests - part 2Marcin Olichwirowicz2015-08-255-163/+209
| | | | | |
* | | | | | Merge pull request #21366 from amitsuroliya/remove_unused_variableRafael Mendonça França2015-08-252-13/+13
|\ \ \ \ \ \ | | | | | | | | | | | | | | Remove more unused block arguments
| * | | | | | Remove more unused block arguments amitkumarsuroliya2015-08-252-13/+13
| | | | | | |
* | | | | | | Merge pull request #21345 from aditya-kapoor/trim-apRafael Mendonça França2015-08-252-6/+4
|\ \ \ \ \ \ \ | |/ / / / / / |/| | | | | | Trim out least needed controllers from AP test suite
| * | | | | | Trim out unneeded controllers from AP test suiteAditya Kapoor2015-08-242-6/+4
| | | | | | |
* | | | | | | Merge pull request #21094 from aditya-kapoor/add-missing-ap-testsRafael Mendonça França2015-08-251-0/+10
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | add missing test for action regexp for routing
| * | | | | | | add missing tests for action regexpAditya Kapoor2015-08-021-0/+10
| | | | | | | |
* | | | | | | | Remove unused block argumentsAnshul Sharma2015-08-251-1/+1
| | | | | | | |