Commit Graph

84 Commits

Author SHA1 Message Date
Guo Xiang Tan a849fae5ee Add specs for polls (#4246)
* Extract validation logic into a service object.

* Extract logic for updating polls custom fields into a service object.

* Use `strip_heredoc` instead.

* FIX: Polls do not update when configuration has been changed.
2016-06-06 17:04:56 +02: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
Godfrey Chan 5352a7f53c Don't `use_route`
See https://github.com/rails/rails/pull/17453 and https://github.com/rails/rails/pull/17725
2014-11-30 21:25:54 -08:00
Régis Hanol 57f7b92bb4 fix poll plugin specs deprecations 2014-09-25 18:12:28 +02:00
Régis Hanol de76b512c1 fix most deprecations in the specs (still some left) 2014-09-25 17:44:48 +02:00
Vikhyat Korrapati 5de7d889fd Add close/open poll buttons to poll UI. 2014-04-12 22:53:21 +05:30
Vikhyat Korrapati 2928ce6ca1 Remove the colon from the poll prefix, drop regex support.
This is needed to make it possible to programmatically toggle between
open and closed polls.
2014-04-11 08:41:37 +05:30
Sam 93d79080bb BUGFIX: broken specs after pulling in closed poll stuff 2014-04-09 12:38:21 +10:00
Vikhyat Korrapati ff43aac603 Live update poll votes. 2014-03-24 09:40:09 +05:30
Vikhyat Korrapati 9ef104bbce Poll Plugin: Don't allow voting on closed topics. 2014-03-16 19:21:17 +05:30
Vikhyat Korrapati ae3f135c33 Poll Plugin: Allow staff to edit options. 2014-03-16 19:21:17 +05:30
Vikhyat Korrapati 0950dde8d0 Add a test to make sure the poll prefix translation can be a regex. 2014-03-11 16:54:12 +05:30
Vikhyat Korrapati 33cb4bc5ac Fallback to using the first list if [poll] isn't present. 2014-02-20 13:46:27 +05:30
Vikhyat Korrapati 74ab14de19 Add poll plugin. 2014-02-13 07:39:01 +05:30