Commit Graph

22 Commits

Author SHA1 Message Date
Joffrey JAFFEUX d16a39dc53
FIX: prevents exception when text input is nil (#12922)
nil was converted to "" and the matching regex would return [] and then be converted to nil with max usage.

Example exception:

```
NoMethodError (undefined method `<=' for nil:NilClass)

lib/text_sentinel.rb:71:in `seems_unpretentious?'
lib/validators/quality_title_validator.rb:13:in `validate_each'
lib/topic_creator.rb:25:in `valid?'
```
2021-05-03 09:21:35 +02:00
Sam Saffron 4ea21fa2d0 DEV: use #frozen_string_literal: true on all spec
This change both speeds up specs (less strings to allocate) and helps catch
cases where methods in Discourse are mutating inputs.

Overall we will be migrating everything to use #frozen_string_literal: true
it will take a while, but this is the first and safest move in this direction
2019-04-30 10:27:42 +10:00
Erick Guan 9dd325f805 FIX: skip some checks for CJK locale in TextSentinel (#7322) 2019-04-05 15:07:49 +02:00
Arpit Jalan 25ec077eca rename 'min_private_message_{post/title}_length' to 'min_personal_message_{post/title}_length' 2018-02-01 13:25:29 +05:30
Guo Xiang Tan 13f3de4bf6 Nuke all `SiteSetting.stubs` from our codebase. 2017-07-07 15:09:14 +09:00
Arpit Jalan e46204d195 FIX: allow long words if they contain periods 2016-09-13 09:15:05 +05:30
Rafael dos Santos Silva 5915929166 FIX: Unicode aware text sentinel (#4301)
* FIX: Handle unicode text on Text Sentinel

Uses active_support to properly handle unicode text

* Adds test cases to unicode Text Sentinel
2016-07-12 11:08:55 -04:00
Andy Waite 3e50313fdc Prepare for separation of RSpec helper files
Since rspec-rails 3, the default installation creates two helper files:
* `spec_helper.rb`
* `rails_helper.rb`

`spec_helper.rb` is intended as a way of running specs that do not
require Rails, whereas `rails_helper.rb` loads Rails (as Discourse's
current `spec_helper.rb` does).

For more information:

https://www.relishapp.com/rspec/rspec-rails/docs/upgrade#default-helper-files

In this commit, I've simply replaced all instances of `spec_helper` with
`rails_helper`, and renamed the original `spec_helper.rb`.

This brings the Discourse project closer to the standard usage of RSpec
in a Rails app.

At present, every spec relies on loading Rails, but there are likely
many that don't need to. In a future pull request, I hope to introduce a
separate, minimal `spec_helper.rb` which can be used in tests which
don't rely on Rails.
2015-12-01 20:39:42 +00:00
Jeff Wong cf86f27415 FEATURE: New setting to allow all caps posts
Adds a setting to ignore text_sentinel's check on all caps content.
2015-11-18 09:50:50 -08:00
Robin Ward 4ab9ef3497 FIX: Allow long words if they contain periods 2015-05-19 13:10:25 -04:00
Luciano Sousa 0fd98b56d8 few components with rspec3 syntax 2015-01-09 13:34:37 -03:00
Nathan Nontell d95172cb5d Allow TextSentinel#seems_unpretentious? to accept words joined with dashes or forward slashes. (Issue 1133) 2013-09-16 09:45:57 -04:00
Neil Lalonde f611a5d898 If min entropy setting is greater than min post/body length setting, then use a sensible min entropy value instead 2013-08-28 11:04:28 -04:00
Neil Lalonde 876a570e3a Fix to prevent check for all upper case for non-ascii messages 2013-06-17 12:22:50 -04:00
Michael Brown bb77d2c38b More entropy for foreign titles
* Treat strings with non-ASCII characters as having more entropy
2013-06-07 14:47:07 -04:00
Régis Hanol c5cf8be864 auto replace rules in titles 2013-04-10 11:00:50 +02:00
Gosha Arinich cafc75b238 remove trailing whitespaces ❤️ 2013-02-26 07:31:35 +03:00
Jeremy Banks eb2a5e4654 Merge branch 'origin/master'
Conflicts:
	lib/text_sentinel.rb
2013-02-18 21:41:20 -05:00
Jeremy Banks 6af69f7e77 Do not strip leading and trailing whitespace from raw posts. 2013-02-15 20:58:33 -05:00
Alexander 6c4ae05454 Removes iconv dependency
Fixes #100
2013-02-15 13:36:19 -08:00
Robin Ward d740d7b25f Fix for foreign language titles: Only enforce upper case rule on english alphabet. 2013-02-14 16:09:57 -05:00
Robin Ward 40da901e5d Introduction of TextSentinel to enforce title and body quality. 2013-02-06 20:53:34 -05:00