Commit Graph

48 Commits

Author SHA1 Message Date
Sam Saffron
aeb7143aff DEV: correct flaky poll specs
They were relying on a pristine message bus, however current implementation
still uses redis, stuff can get held up and we can end up publishing
distributed cache messages in the middle invalidating the tests
2019-05-17 16:16:02 +10:00
Guo Xiang Tan
9059a8ca90 Fix the build. 2019-05-13 10:16:26 +08:00
Sam Saffron
30990006a9 DEV: enable frozen string literal on all files
This reduces chances of errors where consumers of strings mutate inputs
and reduces memory usage of the app.

Test suite passes now, but there may be some stuff left, so we will run
a few sites on a branch prior to merging
2019-05-13 09:31:32 +08:00
Sam Saffron
b5e32cfe2a DEV: correct spec to test for correct fidelity
This is due to 9ebabc1d
2019-03-28 17:45:36 +11:00
Guo Xiang Tan
71ce9ced47 FIX: Incorrect arguments were being passed to Jobs::ClosePoll.
Also fix spec that wasn't testing anything.
2018-12-13 16:46:00 +08:00
Guo Xiang Tan
dcf9c6da59 DEV: Don't publish post messages to non-human users. 2018-12-06 08:24:13 +08:00
Régis Hanol
aea2d8bbeb FIX: properly secure poll message bus
Co-authored-by: Sam <sam.saffron@gmail.com>
2018-12-05 21:27:49 +01:00
Régis Hanol
4459665dee
REFACTOR: use tables instead of custom fields for polls (#6359)
Co-authored-by: Guo Xiang Tan <tgx_world@hotmail.com>
2018-11-19 14:50:00 +01:00
Guo Xiang Tan
a4aa4a9be4 DEV: Remove the use of mocks in our tests. 2018-10-15 10:38:02 +08:00
Sam
eacb2593ee workaround badly denormalized data in polls 2018-08-17 11:15:29 +10:00
Guo Xiang Tan
3a8f69c3d2 DEV: Assert for 200 response code to avoid changing magic helper in the future. 2018-06-07 16:11:09 +08:00
Sam
e806e6e96f correct specs 2018-06-07 16:13:15 +10:00
Régis Hanol
94163d7f1a add spec for auto-close polls 2018-05-07 11:31:20 +02:00
Régis Hanol
dee35b72f2 FIX: must be able to post in a topic in order to vote on a poll 2018-02-27 00:19:44 +01:00
Joffrey JAFFEUX
316d814130
FIX: staff should always be allowed to create polls if they are enabled 2017-12-05 00:03:56 +01:00
Joffrey JAFFEUX
76bc173d47
FEATURE: adds poll_allow_staff_to_create
This setting will bypass poll_minimum_trust_level_to_create if set to true
2017-12-04 18:12:17 +01:00
Joffrey JAFFEUX
63bab32816 FEATURE: introduces minimum trust level for polls (#5391)
* FEATURE: introduces minimum trust level for polls

This commit makes `poll_enabled` less misleading and introduces `poll_minimum_trust_level_to_create`. If poll are enabled they will always be cooked, and if you have the required trust level you can create polls. As a side effect, it also fixes a bug where rebaking a post created by staff member when `poll_enabled=false` would end up not cooking it.

It also adds more tests to ensure settings are respected.

* admins should be whitelisted

* checks for admin in post validation

* test for >= instead of == trust level
2017-12-04 14:47:11 +01:00
Guo Xiang Tan
77d4c4d8dc Fix all the errors to get our tests green on Rails 5.1. 2017-09-25 13:48:58 +08:00
Sam
43c0111ca1 FIX: multichoice poll with more than 25 votes
In the past we would double up on avatars due to incorrect logic for
handling offset
2017-08-14 15:33:59 -04:00
Guo Xiang Tan
5012d46cbd Add rubocop to our build. (#5004) 2017-07-28 10:20:09 +09:00
Sam Saffron
045a2abcec FEATURE: remove the timecop gem
We should only have one way of mocking time, misuse of timecop
was causing build stability issues
2017-07-24 12:11:10 -04:00
Sam
b7f58fe880 regression polls could not be closed properly 2017-07-18 14:52:58 -04:00
Sam
93e5112dfa correct poll specs 2017-07-18 14:31:22 -04:00
Guo Xiang Tan
8213da20f2 Extract polls edit window to a site settings. 2016-08-10 15:17:16 +08:00
Guo Xiang Tan
ffbfcd7ee2 Fix build. 2016-07-29 14:47:23 +08:00
Guo Xiang Tan
a36203ff78
PERF: Paginate public polls. 2016-06-12 16:14:53 +08:00
Guo Xiang Tan
8ecde35df3
FEATURE: Add public type to polls. 2016-06-08 16:19:13 +08:00
Gerhard Schlager
f1bc7de541
Adds support for anonymous votes to the poll plugin 2016-04-23 22:44:09 +02:00
Régis Hanol
b575f97ece FIX: allows polls on closed topics 2016-03-21 12:12:25 +01: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
Gerhard Schlager
bb52042b46 FIX: Add missing pluralization keys to poll plugin locale 2015-09-27 21:36:57 +02:00
Régis Hanol
2e76c9165a FIX: polls are always editable until the first vote 2015-09-25 18:54:15 +02:00
Régis Hanol
60bbd81607 FIX: polls with votes were preventing users from updating the post 2015-09-14 19:27:54 +02:00
Sam
d16de4a0a1 correct polls spec 2015-08-05 12:39:38 +10:00
Régis Hanol
c240a8bd80 FIX: make sure we can't vote on deleted polls 2015-06-01 22:31:47 +02:00
Régis Hanol
f736b6face FIX: validate poll parameters when type=multiple 2015-06-01 19:28:05 +02:00
Régis Hanol
7c545537a6 FIX: prevent pollception 2015-05-13 23:12:53 +02:00
Régis Hanol
b8005f0b1b FIX: link starting with '[poll' should not break polls 2015-05-13 17:50:25 +02:00
Régis Hanol
3a9907f392 FIX: prevent self-xss in poll attributes 2015-05-11 20:09:17 +02:00
Régis Hanol
c1bb7bc7cc clarify copy when editing a poll after the first 5 minutes 2015-05-07 17:24:35 +02:00
Régis Hanol
9b0ca60f52 FIX: support quotes for poll parameters 2015-05-07 16:40:14 +02:00
Régis Hanol
033761d2f6 FIX: reset all votes when the # of options changes 2015-05-06 18:52:09 +02:00
Régis Hanol
86d7412f30 REFACTOR: rename "total_votes" poll field to the more accurate "voters"
FEATURE: automagically load plugin's migrations
2015-05-04 16:01:57 +02:00
Sam
803feefd54 MessageBus handles readonly redis now, no need to wrap it 2015-05-04 12:21:00 +10:00
Régis Hanol
2954c99a1e FEATURE: new 'poll_maximum_options' site setting to limit the number of options in a poll 2015-05-01 16:44:51 +02:00
Régis Hanol
f83638c154 FIX: check the selected options when casting a vote 2015-05-01 16:33:24 +02:00
Robin Ward
5b3f99aa50 Don't blow up if Redis switches to READONLY 2015-04-24 14:37:16 -04:00
Régis Hanol
a737090442 - FEATURE: revamped poll plugin
- add User.staff scope
- inject MessageBus into Ember views (so it can be used by the poll plugin)
- REFACTOR: use more accurate is_first_post? method instead of post_number == 1
- FEATURE: add support for JSON-typed custom fields
- FEATURE: allow plugins to add validation
- FEATURE: add post_custom_fields to PostSerializer
- FEATURE: allow plugins to whitelist post_custom_fields
- FIX: don't bump when post did not save successfully
- FEATURE: polls are supported in any post
- FEATURE: allow for multiple polls in the same post
- FEATURE: multiple choice polls
- FEATURE: rating polls
- FEATURE: new dialect allowing users to preview polls in the composer
2015-04-23 19:33:29 +02:00