aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext/string_ext_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Removed mocha stubbing in active_supportRonak Jangir2015-06-071-86/+92
|
* Merge pull request #19076 from nygrenh/truncate-words-fixRafael Mendonça França2015-02-251-0/+9
|\ | | | | | | Fix a backtracking problem in String#truncate_words
| * Fix a backtracking problem in String#truncate_wordsHenrik Nygren2015-02-251-0/+9
|/ | | | Fixes #19070.
* Removed magic comments # encoding: utf-8 , since its default from ruby 2.0 ↵Vipul A M2015-02-031-1/+0
| | | | onwards.
* Remove deprecated `ActiveSupport::SafeBuffer#prepend`Rafael Mendonça França2015-01-041-10/+0
|
* Pass symbol as an argument instead of a blockErik Michaels-Ober2014-11-291-6/+2
|
* added example of squish!, remove, test case for multiple occurrence ofRishi Jain2014-11-061-0/+6
| | | | | | | | pattern removal added example for string#remove and test case for remove of multiple occurence of pattern removed extra whitespaces
* tests, add note about the usage of a specific timezone. Closes #17448.Yves Senn2014-11-051-1/+1
|
* Fix broken string_ext_test due to change in timezonePrathamesh Sonpatki2014-11-051-1/+1
| | | | | - Russian time was changed to UTC+3 from UTC+4 recently. This broke the string_to_ext test.
* Make `String#remove` and `String#remove!` accept multiple argumentsPavel Pravosud2014-10-251-2/+12
|
* As of Unicode 6.3, Mongolian Vowel Separator is not whitespaceMatthew Draper2014-09-151-3/+3
| | | | | Ruby 2.2 knows this, and no longer matches it with [[:space:]], so it's not a good candidate for testing String#squish.
* Expectations firstAkira Matsuda2014-08-181-4/+4
|
* missing activesupport test coverageEugene Gilburg2014-07-191-0/+8
|
* Fix typos in string_ext_test.rb [ci skip]Jon Atack2014-07-161-4/+4
|
* Merge pull request #16190 from oss92/word_truncationMatthew Draper2014-07-171-0/+21
|\ | | | | | | Word truncation
| * Added truncate_words method to activesupport stringsroot2014-07-161-0/+20
|/
* Extract out with_env_tz helper method.Zuhao Wan2014-06-181-8/+4
| | | | | It’s used at so many places that extracting it out into a helper file is worth doing.
* Fix inconsistent behavior from String#pluralizeKuldeep Aggarwal2014-04-191-0/+5
| | | | | | | | | | | Before: When calling String#pluralize with count=1 then it returned same string, but with count other than 1, returned new string. After: String#pluralize always return a new string. => Prevent mutation of a string inadvertently.
* Fix inconsistent behavior from String#first/#lastErnie Miller2014-04-181-0/+12
| | | | | | | While calling String#first or String#last with zero or a Fixnum < the string's length returns a new string, a Fixnum >= the string's length returns the string itself. This inconsistency can lead to inadvertent mutation of a string.
* Move require to actual fileCarlos Antonio da Silva2014-04-021-1/+0
| | | | | Change to require all active_support/deprecation since that's the actual entry point for the deprecation methods.
* Use asert_deprecatedRafael Mendonça França2014-04-021-3/+5
|
* Make AS::SafeBuffer#prepend act like String#prependPavel Pravosud2014-03-311-0/+22
| | | | | | | Make `#prepend` method modify instance in-place and return self instead of just returning modified value. That is exactly what `#prepend!` method was doing previously, so it's deprecated from now on.
* fix interplay of humanize and html_escapeSean Walbran2014-02-051-0/+4
|
* Revert "Speedup String#to"Yves Senn2014-01-081-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 2ef1fb2c455ca53a0c1e1768f50824926ce28bd3. As described in PR #13627 this commit broke functionality when passing a negative Fixnum to the `String#to` method: ```ruby assert_equal "hell", s.to(-2) ``` Before the revert, this failed with: ``` 1) Failure: StringAccessTest#test_#to_with_negative_Fixnum,_position_is_counted_from_the_end [test/core_ext/string_ext_test.rb:275]: Expected: "hell" Actual: nil ``` This revert is to keep the functionality on `master` working. If there is another way to get the performance benefit and keep the documented functionality we can add that. /cc @amatsuda @carlosantoniodasilva
* typo fix in test name. [ci skip].Yves Senn2014-01-081-1/+1
|
* `core_ext/string/access.rb` test what we are documenting.Yves Senn2014-01-081-50/+89
| | | | | | | | | | | | | I also extracted the tests from a single bulk method into a separate test-case. The new tests cover the API described in the docs. There are two skipped tests, which are broken as of 2ef1fb2c455ca53a0c1e1768f50824926ce28bd3 * #to with negative Fixnum, position is counted from the end * #from and #to can be combined This was brought to my attention by #13627. Closes #13627.
* Add +capitalize+ option to Inflector.humanizeclaudiob2013-11-061-1/+7
| | | | | | | So strings can be humanized without being capitalized: 'employee_salary'.humanize # => "Employee salary" 'employee_salary'.humanize(capitalize: false) # => "employee salary"
* Removed unused modules and classesAnupam Choudhury2013-09-101-7/+0
|
* Add String#remove(pattern) as a short-hand for the common pattern of ↵David Heinemeier Hansson2013-08-131-0/+5
| | | | String#gsub(pattern, '')
* Remove deprecated `String#encoding_aware?` Arun Agrawal2013-07-031-6/+0
| | | core extensions (`core_ext/string/encoding`).
* Adjust for daylight savings in String#to_timeAndrew White2013-04-231-2/+118
| | | | | | | | | | | | | | | The changes in b79adc4323 had a bug where if the time in the String was in standard time but the current time was in daylight savings then the calculated adjustment was off by an hour. This commit fixes this and adds extra tests for the following: * time in string is standard time, current time is standard time * time in string is standard time, current time is daylight savings * time in string is daylight savings, current time is standard time * time in string is daylight savings, current time is daylight savings Fixes #10306.
* Fixed tests for returning an instance of `Time` in the local system timezone.Paul Nikitochkin2013-03-101-5/+5
|
* Merge pull request #8830 from antoinelyset/masterXavier Noria2013-01-281-3/+4
|\ | | | | Improve String#squish whitespaces matching
| * Improve String#squish whitespaces matchingAntoine Lyset2013-01-221-3/+4
| |
* | Use Encoding::UTF_8 constant :do_not_litter:Akira Matsuda2013-01-281-2/+2
| |
* | Fix some wrong String extensions testsAkira Matsuda2013-01-231-7/+9
| | | | | | | | | | | | * ASCII_STRING was not an ASCII String * BYTE_STRING was not an in valid UTF-8 String * added an assertion for non-UTF-8 String
* | Test String#dasherizeAkira Matsuda2013-01-231-0/+6
|/
* Use `DateTime.parse` inside `String#to_datetime`Andrew White2013-01-211-0/+6
| | | | | | | | | | Use the standard library's `DateTime.parse` because it's marginally faster and supports partial date/time strings. Benchmark: user system total real old 3.980000 0.000000 3.980000 ( 3.987606) new 3.640000 0.010000 3.650000 ( 3.641342)
* Standardise the return value of `to_time`Andrew White2013-01-211-8/+39
| | | | | | | | | | | | | | | | | | | | | | This commit standardises the return value of `to_time` to an instance of `Time` in the local system timezone, matching the Ruby core and standard library behavior. The default form for `String#to_time` has been changed from :utc to :local but research seems to suggest the latter is the more common form. Also fix an edge condition with `String#to_time` where the string has a timezone offset in it and the mode is :local. e.g: # Before: >> "2000-01-01 00:00:00 -0500".to_time(:local) => 2000-01-01 05:00:00 -0500 # After: >> "2000-01-01 00:00:00 -0500".to_time(:local) => 2000-01-01 00:00:00 -0500 Closes #2453
* Better error message for String#to_dateKelly Stannard2013-01-041-0/+1
| | | | | | | | | | I did this because to_date gives a very unhelpful error message if you do not pass in a correct date. In the process I think this cleans up the code nicely and even better it tends to be slightly faster than the current implementation. Benchmark https://gist.github.com/4440875
* Deprecate obsolete Time to DateTime fallback methodsAndrew White2012-12-111-1/+1
| | | | | | | The Time.time_with_datetime_fallback, Time.utc_time and Time.local_time methods were added to handle the limitations of Ruby's native Time implementation. Those limitations no longer apply so we are deprecating them in 4.0 and they will be removed in 4.1.
* Beef up tests for String#in_time_zone and Date#in_time_zoneAndrew White2012-12-111-18/+0
|
* Add String#in_time_zone methodAndrew White2012-12-111-24/+44
| | | | | | This commit adds a convenience method for converting a string to an ActiveSupport::TimeWithZone instance using the configured Time.zone or another passed as an argument.
* &#39 dates back to SGML when &#x27 was introduced in HTML 4.0Kalys Osmonov2012-09-091-1/+1
|
* defines String#indent [closes #7263] [Xavier Noria & Ace Suares]Xavier Noria2012-08-071-0/+56
|
* html_escape should escape single quotesSantiago Pastorino2012-07-311-2/+2
| | | | | https://www.owasp.org/index.php/XSS_%28Cross_Site_Scripting%29_Prevention_Cheat_Sheet#RULE_.231_-_HTML_Escape_Before_Inserting_Untrusted_Data_into_HTML_Element_Content Closes #7215
* Truncate now has the ability to receive a html option that allows it to call ↵Li Ellis Gallardo2012-05-261-0/+4
| | | | | | | | | | | | rails helpers. This way if my text is long I don't have to do something like this: .text = truncate(@text, :length => 27) if @text.size >= 27 = link_to "continue", notes_path, ....."")
* Fix warning: possibly useless use of % in void contextkennyj2012-05-191-1/+1
|
* doesn't modify params in SafeBuffer#%Vasiliy Ermolovich2012-05-181-0/+7
|
* fix safe string interpolation with SafeBuffer#%, closes #6352Vasiliy Ermolovich2012-05-161-0/+24
|