Commit Graph

5342 Commits

Author SHA1 Message Date
Zoltan Kiss
2156df13e0 Minor grammer, code conventions fix [ci skip]
Conflicts:
	activesupport/lib/active_support/core_ext/hash/conversions.rb
2014-03-15 12:11:41 -04:00
Jeremy Kemper
7a5601c432 Remove deprecation on active_support/core_ext/class/attribute_accessors requires. Appropriate to keep this, users don't care that the implementation got unified. 2014-03-15 06:26:15 -07:00
Sammy Larbi
d75eeadf74 Fix #to_json for BasicObject Enumerables 2014-03-14 16:55:34 -05:00
Aaron Patterson
e88da370f1 make tests pass on Ruby 2.2
Apparently we've been using a buggy feature for the past 6 years:

  https://bugs.ruby-lang.org/issues/9593
2014-03-13 10:55:52 -07:00
Aaron Patterson
28d05f0a80 use method_defined? to check whether or not a method is defined 2014-03-12 13:34:07 -07:00
Santiago Pastorino
18c651659e Merge pull request #14244 from arthurnn/orderd_hash_select_fix
Fix OrderedHash.select to return self instance.
2014-03-08 16:12:10 -02:00
Arthur Neves
a94966ea09
Fix OrderedHash.select to return self instance.
On ruby 2.1.1 the behavior of .select and .reject has changed.
They will return a Hash new instance, so we need to override them to
keep the instance object class.
2014-03-07 12:30:20 -05:00
Prem Sichanugrist
2dd2fcf896
Introduce Rails.gem_version
This method return `Gem::Version.new(Rails.version)`, suggesting a more
reliable way to perform version comparison.

Example:

    Rails.version #=> "4.1.2"
    Rails.gem_version #=> #<Gem::Version "4.1.2">

    Rails.version > "4.1.10" #=> false
    Rails.gem_version > Gem::Version.new("4.1.10") #=> true
    Gem::Requirement.new("~> 4.1.2") =~ Rails.gem_version #=> true

This was originally introduced as `.version` by @charliesome in #8501
but got reverted in #10002 since it was not backward compatible.

Also, updating template for `rake update_versions`.
2014-03-05 12:37:38 -05:00
Godfrey Chan
ccf8f27ddd Revert "Merge pull request #14269 from arthurnn/expanded_key_array"
This reverts commit 475c96589ca65282e1a61350271c2f83f0d4044f, reversing
changes made to 705915ab5cf24430892107764b0050c07e1df583.

We decided that this is not worth busting everyone's cache as this
seems like a very unlikely problem. The problem only occurs when the
user is 1) not using a namespace, or 2) using the same namesapce for
different *kinds* of cache items. The recommended "fix" is to put
those cache items into their own namspace:

    id = 1
    Rails.cache.fetch(id, namespace: "user"){ User.find(id) }

    ids = [1]
    Rails.cache.fetch(ids, namespace: "users"){ User.find(ids) }

See the discussion on #14269 for details.
2014-03-04 17:58:58 -08:00
Arthur Neves
7d98247446
Cache key should be different when is Array.
`cache.fetch(['foo'])` and `cache.fetch('foo')` should generate
different cache keys as they are not equivalents.

[related #8615]
[related #8614]
2014-03-03 21:00:15 -05:00
Robin Dupret
686e820c48 Add a comment to ensure that a test won't be removed [ci skip]
The 'cow' => 'kine' inflection has gone with c300dca9 but it should
not be removed from the tested irregularities since it ensures that
inflections work with words that do not begin with the same letters.
2014-03-03 14:15:59 +01:00
Parker Selbert
c046e60965 Return a hash rather than array from fetch_multi
The current implementation of `fetch_multi` returns an array and has no
means to easily backtrack which names yielded which results. By changing
the return value to a Hash we retain the name information. Hash#values
can be used on the response if only the values are needed.
2014-02-26 20:31:46 -06:00
Carlos Antonio da Silva
34c74f8e91 Fix concerning module reference [ci skip] 2014-02-26 21:45:54 -03:00
Aaron Patterson
707dfcdbc3 speed up underscore in cases that don't need to do anything
Benchmark:

Benchmark.ips do |x|
  x.report("home")       { "home".underscore }
  x.report("Home")       { "Home".underscore }
  x.report("homeBase")   { "homeBase".underscore }
  x.report("home::base") { "home::base".underscore }
end

Before:

Calculating -------------------------------------
                home      2598 i/100ms
                Home      2463 i/100ms
            homeBase      2300 i/100ms
          home::base      2086 i/100ms
-------------------------------------------------
                home    28522.3 (±14.7%) i/s -     140292 in   5.065102s
                Home    29165.8 (±14.9%) i/s -     140391 in   5.000475s
            homeBase    26218.5 (±7.1%) i/s -     131100 in   5.030485s
          home::base    27712.3 (±5.9%) i/s -     139762 in   5.064077s

After:

Calculating -------------------------------------
                home     23163 i/100ms
                Home      2432 i/100ms
            homeBase      2160 i/100ms
          home::base      2265 i/100ms
-------------------------------------------------
                home  1501614.8 (±10.2%) i/s -    7412160 in   5.009540s
                Home    28754.0 (±8.5%) i/s -     143488 in   5.033886s
            homeBase    25331.1 (±5.6%) i/s -     127440 in   5.047940s
          home::base    27089.9 (±5.5%) i/s -     135900 in   5.033516s
2014-02-26 15:09:18 -08:00
Carlos Antonio da Silva
71b3910a7d Point master changelogs to 4-1-stable branch
Remove 4-1 related entries from master [ci skip]
2014-02-25 09:14:36 -03:00
David Heinemeier Hansson
d61baee52a Go with #presence_in instead of #present_in -- it doesnt sound quite as good, but the closer relationship to #presence over #present is ultimately worth it 2014-02-24 14:17:47 +01:00
Guillermo Iguaran
4d24c150ab Merge pull request #14171 from arthurnn/extract_middleware_cache
Extract local cache middleware
2014-02-23 22:19:54 -05:00
Arthur Neves
cb172db3ff
Extract local cache middleware
Extract LocalCache Middleware, so it can requires rack dependencies,
without adding rack dependencies to `AS::Cache::Strategy::LocalCache`.
2014-02-23 14:18:53 -05:00
Jeremy Kemper
b16c36e688 Introduce Concern#class_methods and Kernel#concern 2014-02-23 12:06:23 -07:00
Yves Senn
c554d170e6 update version to 4.2.0.alpha 2014-02-23 13:14:43 +01:00
Xavier Noria
a26394d748 Merge pull request #14102 from arthurnn/quietly_doc
Add note to silence_stream and quietly. [skip ci]
2014-02-19 17:53:13 +01:00
Arthur Neves
7a025b173f
Methods silence_stream/quietly are not thread-safe [skip ci]
State that on the doc.

[fixes #11954]
2014-02-19 11:49:18 -05:00
Rafael Mendonça França
1879c259b8 Merge branch '4-1-0-beta2'
Conflicts:
	actionview/CHANGELOG.md
	activerecord/CHANGELOG.md
2014-02-18 16:00:47 -03:00
Rafael Mendonça França
8b20c72dd8 Preparing for 4.1.0.beta2 release 2014-02-18 15:45:20 -03:00
Carlos Antonio da Silva
68345d4a1a Move changelog entry to the top, fix examples indent [ci skip] 2014-02-18 12:53:01 -03:00
David Heinemeier Hansson
36bf5acd23 Use assert_nil instead as its clearer about what the return is expected to be 2014-02-18 16:40:26 +01:00
David Heinemeier Hansson
4edca106da Added Object#present_in to simplify value whitelisting 2014-02-18 16:35:07 +01:00
Xavier Noria
5d037819ca travel_to travels back and re-raises if the block raises 2014-02-18 10:25:11 +01:00
Xavier Noria
24fa399c99 adds a missing travel back 2014-02-18 09:52:42 +01:00
Xavier Noria
65a7c57105 time helpers honor the application time zone when passed a date
Rails applications are expected to be always aware of the application
time zone.

To be consistent with that contract, we have to assume that a bare
date passed to time helpers is a date in the application time zone,
not in the system time zone. The system time zone is irrelevant, we
should totally ignore it.

For example,

    travel_to user.birth_date + 40.years

should make that user be 40th years old regardless of the system
time zone. Without this patch that may not be true.
2014-02-18 09:42:06 +01:00
Yves Senn
92f567ab30 docs, hide inflector comment targeting only contributors. [ci skip]
This is a follow up to: 07c70245a1

As suggested by @fxn this comment should not be visible in the API:
07c70245a1 (commitcomment-5331658)
2014-02-11 09:08:16 +01:00
Justin Coyne
ae28e4beb3 Fix tidy_bytes for JRuby
The previous implementation was broken because JRuby (1.7.10) doesn't
have a code converter for UTF-8 to UTF8-MAC.
2014-02-10 08:10:44 -06:00
Yves Senn
07c70245a1 docs, mention that the current inflection rules are frozen. [ci skip]
Closes #13993.
2014-02-10 08:51:35 +01:00
Vijay Dev
92fdd65162 Merge branch 'master' of github.com:rails/docrails
Conflicts:
	guides/source/active_record_validations.md
	guides/source/api_documentation_guidelines.md
	guides/source/configuring.md
2014-02-09 23:33:55 +05:30
Zachary Scott
17b0edde57 Specify what #starts_with? we're talking about. Also added a note what
kind of exception we should expect for this internal comment.
2014-02-09 12:27:43 +01:00
Zachary Scott
dbe3345c4f Fix grammar of internal comment and modify it's location 2014-02-09 12:27:36 +01:00
Aaron Patterson
76af5c1d30 use feature detection to decide which implementation to use
Decouple the code from the particular Ruby version.
2014-02-08 23:21:07 -08:00
Noah Lindner
4fa8c8b52f Fixed an issue where reloading of removed dependencies would cause an unexpected circular dependency error 2014-02-08 15:59:08 -08:00
Yves Senn
580f0b61dc synchronize 4.1 release notes with CHANGELOGS. [ci skip]
/cc @chancancode
2014-02-06 11:43:16 +01:00
Rafael Mendonça França
c82dbc6a1c Fix to_query with empty arrays too 2014-02-06 01:03:41 -02:00
Rafael Mendonça França
7aa4b7dc6b Add CHANGELOG entry
Closes #13909
2014-02-05 23:55:50 -02:00
Rafael Mendonça França
ab51b285e2 Refatoring the method to avoid shot-circuit return 2014-02-05 23:55:17 -02:00
Rafael Mendonça França
d6e3fd775b Test with a blank value 2014-02-05 23:47:16 -02:00
Rafael Mendonça França
88b064dfae Move test to the right file 2014-02-05 23:42:43 -02:00
Hincu Petru
326e652749 Fixed "Hash#to_param confused by empty hash values #13892" 2014-02-05 23:31:50 -02:00
Sean Walbran
26698fb91d fix interplay of humanize and html_escape 2014-02-05 17:19:51 -06:00
Marc-Andre Lafortune
a476020567 Return sized enumerator from Enumerable#index_by 2014-02-05 16:53:58 -05:00
Marc-Andre Lafortune
13d2696c10 Return sized enumerator from Batches#find_each 2014-02-05 16:53:02 -05:00
Marc-Andre Lafortune
39b2cc1900 Remove obsolete test (builtin group_by is now used) 2014-02-05 16:45:55 -05:00
Marc-Andre Lafortune
4c3e11d30a Remove obsolete line (was needed for Ruby 1.8.7 support) 2014-02-05 16:45:55 -05:00