-
Notifications
You must be signed in to change notification settings - Fork 53
FIX: handle boolean correctly on server #116
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| require 'rails_helper' | ||
|
|
||
| describe CategoriesController do | ||
| fab!(:category) { Fabricate(:category) } | ||
| fab!(:topic) { Fabricate(:topic, category: category) } | ||
| fab!(:admin) { Fabricate(:user, admin: true) } | ||
|
|
||
| before do | ||
| SiteSetting.voting_enabled = true | ||
| sign_in(admin) | ||
| end | ||
|
|
||
| it "enables voting correctly" do | ||
| put "/categories/#{category.id}.json", params: { | ||
| custom_fields: { "enable_topic_voting" => true } | ||
| } | ||
| expect(Category.can_vote?(category.id)).to eq(true) | ||
| end | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice nice, can you add a failing scenario please too?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, I think the failure should be with a simple
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yup! Actually there's other cases where other custom_fields may exist after deleting enable_topic_voting. But that's alright. I trust you clicked through the scenarios.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, the following piece of code(with |
||
|
|
||
| it "disables voting correctly" do | ||
| put "/categories/#{category.id}.json", params: { | ||
| custom_fields: { "enable_topic_voting" => false } | ||
| } | ||
| expect(Category.can_vote?(category.id)).to eq(false) | ||
| end | ||
| end | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw is this needed? (I don't see it used above)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed yes. Category.can_vote? will be
falseif the plugin is disabled.