Commit Graph

10811 Commits

Author SHA1 Message Date
David Heinemeier Hansson
c0a2d474c5 Get ready to release 4.1.0.beta1 2013-12-17 16:05:28 -08:00
Jeremy Kemper
4f4fdd643f Clearly limit new CSRF protection to GET requests 2013-12-17 16:02:04 -07:00
Jeremy Kemper
39ca25f5c4 Merge pull request #13345 from jeremy/get-csrf
CSRF protection from cross-origin <script> tags
2013-12-17 12:29:57 -08:00
Jeremy Kemper
1650bb3d56 CSRF protection from cross-origin <script> tags
Thanks to @homakov for sounding the alarm about JSONP-style data leaking
2013-12-17 13:14:17 -07:00
Yves Senn
bb0bc7a26f Merge pull request #13346 from chancancode/release_notes_etc
Release notes fixes [ci skip]
2013-12-17 08:56:27 -08:00
Godfrey Chan
2003d0409e Some assorted fixes for the 4.1 release notes:
* Added release notes for secrets.yml and mentioned it in the highlights
* Added release notes for Mailer previews and mentioned it in the highlights
* Added release notes for Module#concerning
* Removed mention for AV extraction from the highlights
* Rearranged the major features to put highlighted features first
* Various improvements and typo fixes

[ci skip]
2013-12-17 08:39:07 -08:00
Carlos Antonio da Silva
6802196a6b Disable available locales checks to avoid warnings running the tests 2013-12-17 09:05:41 -02:00
Andrew White
d6dec7fcb6 Add mailer previews feature based on mail_view gem 2013-12-17 03:58:35 +00:00
Rafael Mendonça França
108171a44e Merge pull request #13307 from akshay-vishnoi/typo
Spelling and Grammar check [ci skip]
2013-12-15 11:19:44 -08:00
Akshay Vishnoi
c758093eca Spelling and Grammar check [ci skip] 2013-12-16 00:44:37 +05:30
robertomiranda
35d0d6fec5 Update secret_key_base Docs 2013-12-15 10:32:41 -05:00
Philipe Fatio
fd76b9d546 Fix syntax error in redirect_to example
Without parenthesis, ruby assumes that curly braces denote the beginning
of a block.
2013-12-14 15:35:50 +01:00
Carlos Antonio da Silva
07fd25c759 Merge pull request #13293 from akshay-vishnoi/typo
Spelling and Grammar checks [ci skip]
2013-12-12 08:12:13 -08:00
Rafael Mendonça França
1454f2c20a Merge pull request #13290 from strzalek/inline-syntax-docs
Variants inline syntax documentation
2013-12-12 07:59:17 -08:00
Akshay Vishnoi
5fccd77b6c Spelling and Grammar checks 2013-12-12 18:28:34 +05:30
Łukasz Strzałkowski
3ce9563d42 Variants inline syntax documentation [ci skip]
* Extend method documentation
  * Mention it in actionpack/CHANGELOG
  * Update release notes
2013-12-12 13:20:45 +01:00
Carlos Antonio da Silva
fe24f3560a Changelog improvements [ci skip] 2013-12-12 08:33:46 -02:00
Damien Mathieu
6645a2099a Merge pull request #13288 from dvsuresh/fix_typo
Fix typo in action_controller responder.rb [ci skip]
2013-12-12 00:13:52 -08:00
dvsuresh
25a5c5f236 Fix typo in action_controller responder.rb 2013-12-12 02:03:58 -06:00
Godfrey Chan
ebfd97124d Merge pull request #13284 from aayushkhandelwal11/typos_corrected
s/everytime/every time/
2013-12-11 22:13:04 -08:00
Aayush khandelwal
4a9e54ef35 typos rectified [ci skip] 2013-12-12 11:29:23 +05:30
Trent Ogren
96a6703ed9 Update CHANGELOG entry for Session#fetch
This reverts the changes to CHANGELOG.md in commit
38f8872aa5fd8f0a1d0895e9eb41f73261acd040.
2013-12-11 19:26:45 -06:00
Trent Ogren
d0fc760d09 Make ActionDispatch::Request::Session#fetch behave like Hash#fetch
Session#fetch was mutating the session when given a default argument
and/or a block. Since Session duck-types as a Hash, it should behave
like one in these cases.
2013-12-11 15:29:33 -06:00
Piotr Sarnacki
e6c602da90 Fix mounting engines inside a resources block
When a route is mounted inside a resources block, it's automatically
prefixed, so a following code:

    resources :users do
      mount Blog::Engine => '/blog'
    end

will generate a user_blog path helper.

In order to access engine helpers, we also use "mounted_helpers", a list
of helpers associated with each mounted engine, so a path to blog's post
can be generated using user_blog.post_path(user, post).

The problem I'm fixing here is that mount used a raw :as option, without
taking nestings into account. As a result, blog was added to a route set
as a `user_blog`, but helper was generated for just `blog`.

This commit applies the proper logic for defining a helper for a mounted
engine nested in resources or resource block.

(closes #8533)
2013-12-10 21:38:41 +01:00
Łukasz Strzałkowski
edacdbfaf9 Inline variants syntax
In most cases, when setting variant specific code, you're not sharing any code
within format.

Inline syntax can vastly simplify defining variants in those situations:

  respond_to do |format|
    format.js { render "trash" }
    format.html do |variant|
      variant.phone { redirect_to progress_path }
      variant.none  { render "trash" }
    end
  end

Becomes:

  respond_to do |format|
    format.js         { render "trash" }
    format.html.phone { redirect_to progress_path }
    format.html.none  { render "trash" }
  end
2013-12-10 11:55:43 +01:00
Łukasz Strzałkowski
fbb6be50a5 Simplify @responses hash initialization
@responses hash needs to be initialized with mime types that we get from
Collector#collect_mimes_from_class_level. Mime::Type class as key and nil as
value. This need to happen before content negotiation. Before that, it was
looping though mime types and executing mime-type-generated method inside
collector (see
AbstractController::Collector#generate_method_for_mime). That approach resulted
in 2 unnecessary method calls for each mime type
collected by Collector#collect_mimes_from_class_level.

Now hash is initialized in place, without usage of Collector#custom method.
2013-12-10 11:47:50 +01:00
David Heinemeier Hansson
4aae538d9f Revert "Merge pull request #13235 from strzalek/variants-inline" -- needs a little more work!
This reverts commit 186161148a189839a1e0924043f068a8d155ce69, reversing
changes made to cad9eb178ea5eec0e27d74e93518f4ed34e2f997.
2013-12-08 14:04:04 -08:00
David Heinemeier Hansson
186161148a Merge pull request #13235 from strzalek/variants-inline
Inline syntax for variants
2013-12-08 13:38:01 -08:00
Łukasz Strzałkowski
2647d2f656 Inline variants syntax
In most cases, when setting variant specific code, you're not sharing any code
within format.

Inline syntax can vastly simplify defining variants in those sitiations:

  respond_to do |format|
    format.js { render "trash" }
    format.html do |variant|
      variant.phone { redirect_to progress_path }
      variant.none  { render "trash" }
    end
  end
`
Becomes:

  respond_to do |format|
    format.js         { render "trash" }
    format.html.phone { redirect_to progress_path }
    format.html.none  { render "trash" }
  end
2013-12-08 22:29:07 +01:00
Łukasz Strzałkowski
9b8c0ff391 Simplify @responses hash initialization
@responses hash needs to be initialized with mime types that we get from
Collector#collect_mimes_from_class_level. Mime::Type class as key and nil as
value. This need to happen before content negotiation. Before that, it was
looping though mime types and executing mime-type-generated method inside
collector (see
AbstractController::Collector#generate_method_for_mime). That approach resulted
in 2 unnecessary method calls for each mime type
collected by Collector#collect_mimes_from_class_level.

Now hash is initialized in place, without usage of Collector#custom method.
2013-12-08 22:11:46 +01:00
Łukasz Strzałkowski
d99dd0af03 Require action_view explicitly in AC::Base 2013-12-08 13:03:41 +01:00
David Heinemeier Hansson
99975e742e Variants can be declared without a block to signify their presence in the controller 2013-12-07 16:32:38 -08:00
David Heinemeier Hansson
a16fa9abfd Allow code execution in case no variant has been set with variant.none 2013-12-07 15:00:35 -08:00
Arun Agrawal
7f10232b9e Fixed test for Mime::VCF
Added here 13dd38cee79be39f7b399e142fd78295dddd2abb
2013-12-06 08:15:43 +01:00
David Heinemeier Hansson
13dd38cee7 Add Mime::Type.register "text/vcard", :vcf to the default list of mime types 2013-12-05 15:49:06 -08:00
Jeremy Kemper
5086c8c211 Merge pull request #13189 from strzalek/retain-ap-av-dep
Retain ActionPack dependency on ActionView. Fixes #12979.
2013-12-05 07:25:17 -08:00
Bernard Potocki
e8572cf2f9 Add configuration option to optionally disable deep_munge 2013-12-05 12:08:34 +01:00
Yves Senn
d71c1fc6a7 add missing CHANGELOG entry for d8c6f52. [ci skip]
Discoverd by #13175.
2013-12-05 11:41:12 +01:00
Carlos Antonio da Silva
d6eda3ef3c Remove missing integration points of AV extraction 2013-12-05 11:39:56 +01:00
Shota Fukumori (sora_h)
c1d5477b63 Escalate missing error when :raise is true
Before ec16ba75a5493b9da972eea08bae630eba35b62f,
ActionView::Helpers::TranslationHelper#translate has raised errors with
specifying options[:raise] to true.

This should work by this fix:

     begin
       t(:"translations.missing", raise: true)
     rescue I18n::MissingTranslationData
       p :hello!
     end
2013-12-05 09:20:58 +09:00
Łukasz Strzałkowski
d8888b94b3 Retain ActionPack dependency on ActionView 2013-12-05 01:02:46 +01:00
Rafael Mendonça França
2d061c2c4f Update changelog [ci skip] 2013-12-04 17:48:32 -02:00
Angelo capilleri
2f3fe92f1b remove nil in NullType#ref.
Return Nil is implicit in a method and this syntax is used in the others
classes
2013-12-04 17:55:05 +01:00
Carlos Antonio da Silva
3b40a5d83d Improve a couple exception messages related to variants and mime types
Avoid one-liner conditionals when they are too big. Avoid concatenating
strings to build error messages. Improve messages a bit.
2013-12-03 22:23:12 -02:00
Carlos Antonio da Silva
bc26f442d2 Add nodoc to added VariantFilter class 2013-12-03 22:08:18 -02: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
Carlos Antonio da Silva
ce148025f2 Change deep_munge call to avoid deprecation warning 2013-12-03 20:25:03 -02:00
Aaron Patterson
dba82120fe Merge branch 'master-sec'
* master-sec:
  Deep Munge the parameters for GET and POST
  Stop using i18n's built in HTML error handling.
  Ensure simple_format escapes its html attributes
  Escape the unit value provided to number_to_currency
  Only use valid mime type symbols as cache keys
2013-12-03 11:01:56 -08:00
Carlos Antonio da Silva
7c20a8b558 Changelog improvements [ci skip] 2013-12-03 14:38:12 -02:00
Lauro Caetano
b1b9a0aeca Typos. return -> returns. [ci skip] 2013-12-03 13:31:36 -02:00
Guillermo Iguaran
abc1e5831c Convert Mime::NullType in a singleton 2013-12-03 02:41:26 -05:00
Guillermo Iguaran
66b1c2d3b5 Cleanups in comment about conditional 2013-12-03 02:34:57 -05:00
Guillermo Iguaran
9ed3aab692 Merge branch 'format_localized_template' of https://github.com/acapilleri/rails
Conflicts:
	actionpack/CHANGELOG.md
2013-12-03 02:34:11 -05:00
Angelo capilleri
43962d6ec5 Fix header Content-Type: #<Mime::NullType:...> in localized template
This PR fixes #13064 regression bug introduced by the #8085

Now in _process_format when the format is a Mime::NullType nothing is written in self.content_type.
In this way the method Response#assign_default_content_type_and_charset can
write the the default mime_type.
2013-12-03 07:46:39 +01:00
Michael Koziarski
4e9dd5378b Deep Munge the parameters for GET and POST
The previous implementation of this functionality could be accidentally
subverted by instantiating a raw Rack::Request before the first Rails::Request
was constructed.

Fixes CVE-2013-6417
2013-12-02 16:44:27 -08:00
Carlos Antonio da Silva
45f70dca7b Merge pull request #12123 from aredondo/master
Add regression test for IpSpoofAttackError issue

Closes #10780
2013-12-02 16:23:45 -08:00
Genadi Samokovarov
6329d9fa8b Remove deprecated cattr_* requires 2013-12-03 00:28:15 +02:00
Andrew White
d2e1caaab9 Try to escape each part of a path redirect route correctly
A path redirect may contain any and all parts of a url which have different
escaping rules for each part. This commit tries to escape each part correctly
by splitting the string into three chunks - path (which may also include a host),
query and fragment; then it applies the correct escape pattern to each part.

Whilst using `URI.parse` would be better, unfortunately the possible presence
of %{name} parameters in the path redirect string prevents us from using it so
we have to use a regular expression instead.

Fixes #13110.
2013-12-02 05:16:05 +00:00
Tejas Dinkar
223ff7949e [ci skip] Removing some gender sensitive object pronouns 2013-12-02 09:24:47 +05:30
Guillermo Iguaran
49ff20d9b1 Use genderless pronouns in API docs 2013-12-01 03:20:39 -05:00
Lauro Caetano
71d19f1517 Fix stream closing when sending file with ActionController::Live included.
Fixes #12381
2013-11-30 16:06:52 -02:00
Akshay Vishnoi
e0326f56b4 Typo fixes [ci skip] 2013-11-30 20:27:01 +05:30
Yves Senn
7c6d99e81e first pass through CHANGELOGS to extract 4_1_release_notes. [ci skip]
Extract **notable changes**, **deprecations** and **removals** from
each CHANGELOG.

I tried to reference the commits and pull requests for new features
and deprecations.

In the process I also made some minor changes to the CHANGELOGS.

The 4_1_release_notes guide is declared WIP.
2013-11-28 17:24:15 +01:00
Kuldeep Aggarwal
bbad99bdff fixed-case when invalid action name has passed 2013-11-28 03:14:19 +05:30
Kuldeep Aggarwal
4c450a514a fixed typo destory => destroy [ci skip] 2013-11-28 02:12:47 +05:30
Victor Costan
c759a93454 Better error message for typos in assert_response argument.
This commit makes it really easy to debug errors due to typos like
"assert_response :succezz".
2013-11-25 03:09:02 -05:00
Carlos Antonio da Silva
587c2d67ce Merge pull request #13020 from razielgn/raise-inspectable-messages
Raise RuntimeErrors with inspectable and MRI-independent messages.
2013-11-24 13:57:19 -08:00
Xavier Noria
17c29a0df0 Merge remote-tracking branch 'docrails/master'
Conflicts:
	activesupport/lib/active_support/core_ext/hash/deep_merge.rb
	activesupport/lib/active_support/core_ext/hash/keys.rb
2013-11-24 20:00:24 +01:00
Federico Ravasio
0bc95ed95a Raise RuntimeErrors with inspectable and MRI-independent messages.
Previous behaviour was MRI-dependent, now we're making sure the message
is correctly shown: something that can be relyied upon across every
Ruby implementation.
2013-11-24 14:18:00 +01:00
Carlos Antonio da Silva
18964368f3 Improve changelogs
Also make Action Mailer changelog format more consistent with the
others [ci skip]
2013-11-22 08:30:04 -02:00
Arun Agrawal
7917a5a5ff Build fix for Routing Inspector
Broken by

6701b4cf41f6f3d9cfc6a93715acbf852d1e468e
2013-11-22 00:45:51 +01:00
Rafael Mendonça França
b39b3652e1 Revert "Merge pull request #12990 from vipulnsward/remove_visualizer_param"
This reverts commit 5a19346d2855ecb1c791cdef3af92589566d00db, reversing
changes made to d82588ee4756b03025813b3997f4db171ee0fcdc.

This argument is being used in the view
5a19346d28/actionpack/lib/action_dispatch/journey/visualizer/index.html.erb (L4)

It is being set using the binding
5a19346d28/actionpack/lib/action_dispatch/journey/gtg/transition_table.rb (L108)
2013-11-21 17:49:00 -02:00
Vipul A M
1a2eb04566 Remove unused param titleto TransitionTable#visualizer 2013-11-22 00:44:10 +05:30
Yves Senn
f71cbb81ff unify punctuation in Action Pack changelog. [ci skip] 2013-11-21 18:10:38 +01:00
Sıtkı Bağdat
6701b4cf41 Fix for routes task
This commit fixes formatting issue for `rake routes` task, when a section is shorter than a header.
2013-11-21 18:35:58 +02:00
Kuldeep Aggarwal
fc32b7f99b skiping => skipping 2013-11-19 03:08:08 +05:30
Carlos Antonio da Silva
81475534ed Merge pull request #12898 from chocoby/fix/changelog_comment
Fix CHANGELOG typo [ci skip]
2013-11-15 05:33:38 -08:00
Carlos Antonio da Silva
00adce4ff0 Avoid hash lookups for building an array of required defaults
Only set the value once after it's calculated.
2013-11-15 11:29:32 -02:00
Carlos Antonio da Silva
3f2bf0dbe9 Get rid of useless temp variable 2013-11-15 11:29:31 -02:00
Carlos Antonio da Silva
5f00f13724 Set values instead of building hashes with single values for merging 2013-11-15 11:29:31 -02:00
chocoby
04907b64ac Fix CHANGELOG typo [ci skip] 2013-11-15 22:22:49 +09:00
Andrey Ognevsky
d04c4fac3b Take Hash with options inside Array in #url_for 2013-11-15 15:50:42 +04:00
David Heinemeier Hansson
07996ebc50 Revert "Used Yield instead of block.call" -- this causes all of atom_feed_helper_test.rb to fail with "SystemStackError: stack level too deep".
This reverts commit d3a1ce1cdc60d593de1682c5f4e3230c8db9a0fd.
2013-11-14 15:31:27 -08:00
Rafael Mendonça França
d4587bab24 Merge pull request #12892 from akshay-vishnoi/refactor
avoiding next statements
2013-11-14 12:32:23 -08:00
Akshay Vishnoi
dbcd085013 avoiding next statements 2013-11-15 01:37:33 +05:30
Rafael Mendonça França
84961dc5df Merge pull request #12889 from kuldeepaggarwal/speed_ups
Used Yield instead of block.call
2013-11-14 11:29:28 -08:00
Kuldeep Aggarwal
d3a1ce1cdc Used Yield instead of block.call 2013-11-15 00:53:57 +05:30
Akshay Vishnoi
fdf36d8110 class methods moved to already defined class<<self block 2013-11-15 00:23:35 +05:30
Akshay Vishnoi
1529e61036 #presence used 2013-11-14 16:08:43 +05:30
Prem Sichanugrist
efff6c1fd4 Change syntax format for example returned values
According to our guideline, we leave 1 space between `#` and `=>`, so we
want `# =>` instead of `#=>`.

Thanks to @fxn for the suggestion.

[ci skip]
2013-11-11 13:53:54 -05:00
Guillermo Iguaran
b72304f41e Merge pull request #12838 from strzalek/remove_mime_type_order_var
Remove @order attribute from collector
2013-11-10 21:31:37 -08:00
Lukasz Strzalkowski
83f75a97e2 Remove order attribute from collector
Ruby 1.8 legacy. Since 1.9 hash preserves insertion order. No need for additional array to achieve this
2013-11-10 21:30:43 -08:00
Rafael Mendonça França
4a344c50a1 Merge pull request #12740 from gaurish/patch-1
Improve Errors when Controller Name or Action isn't specfied
2013-11-10 17:32:56 -08:00
Gaurish Sharma
5122bbb3c2 Skip test which is broken on jruby
This test is broken from quite a while & is expected to remain broken as
encoding issues are hardest to fix in JRuby. so lets skip this test for
now
2013-11-09 02:36:24 +05:30
Aaron Patterson
267e5c84f9 calculate the ivars to remove in advance as a set and cache them in a
constant.

`view_assigns` can use the precalculated sets and remove instance
variables without allocating any extra arrays
2013-11-06 14:21:40 -08:00
Aaron Patterson
c8b566d54d use a set and reject to avoid array allocations 2013-11-06 14:11:37 -08:00
Aaron Patterson
779cd6ec61 each_with_object on the view_assigns hash 2013-11-06 13:54:15 -08:00
Aaron Patterson
9a4adb4b05 use slice to avoid range allocation 2013-11-06 13:53:52 -08:00
Aaron Patterson
697acc4025 these variables are also private 2013-11-06 13:37:24 -08:00
Aaron Patterson
32e94a488f instance_variables returns symbols, so we should use symbols in our list 2013-11-06 13:24:00 -08:00