No need for special helper to reset SiteSetting state.
* SiteSetting in tests uses a local provider that resets it.
This commit is contained in:
parent
7ead3e1f18
commit
0e5d490b05
|
@ -15,9 +15,9 @@ describe "Groups" do
|
|||
end
|
||||
|
||||
context 'when group directory is disabled' do
|
||||
site_setting(:enable_group_directory, false)
|
||||
|
||||
it 'should deny access' do
|
||||
SiteSetting.enable_group_directory = false
|
||||
|
||||
get "/groups.json"
|
||||
expect(response).to be_forbidden
|
||||
end
|
||||
|
|
|
@ -5,15 +5,17 @@ require 'rails_helper'
|
|||
describe SpamRulesEnforcer do
|
||||
|
||||
describe 'auto-blocking users based on flagging' do
|
||||
site_setting(:flags_required_to_hide_post, 0)
|
||||
site_setting(:num_spam_flags_to_block_new_user, 2)
|
||||
site_setting(:num_users_to_block_new_user, 2)
|
||||
|
||||
let!(:admin) { Fabricate(:admin) } # needed to send a system message
|
||||
let!(:moderator) { Fabricate(:moderator) }
|
||||
let(:user1) { Fabricate(:user) }
|
||||
let(:user2) { Fabricate(:user) }
|
||||
|
||||
before do
|
||||
SiteSetting.flags_required_to_hide_post = 0
|
||||
SiteSetting.num_spam_flags_to_block_new_user = 2
|
||||
SiteSetting.num_users_to_block_new_user = 2
|
||||
end
|
||||
|
||||
context 'spammer is a new user' do
|
||||
let(:spammer) { Fabricate(:user, trust_level: TrustLevel[0]) }
|
||||
|
||||
|
@ -86,9 +88,8 @@ describe SpamRulesEnforcer do
|
|||
end
|
||||
|
||||
context 'flags_required_to_hide_post takes effect too' do
|
||||
site_setting(:flags_required_to_hide_post, 2)
|
||||
|
||||
it 'should block the spammer' do
|
||||
SiteSetting.flags_required_to_hide_post = 2
|
||||
PostAction.act(user2, spam_post, PostActionType.types[:spam])
|
||||
expect(spammer.reload).to be_blocked
|
||||
expect(Guardian.new(spammer).can_create_topic?(nil)).to be false
|
||||
|
|
|
@ -15,9 +15,9 @@ describe Topic do
|
|||
|
||||
describe 'censored words' do
|
||||
describe 'when title contains censored words' do
|
||||
site_setting(:censored_words, 'pineapple|pen')
|
||||
|
||||
it 'should not be valid' do
|
||||
SiteSetting.censored_words = 'pineapple|pen'
|
||||
|
||||
topic.title = 'pen PinEapple apple pen '
|
||||
|
||||
expect(topic).to_not be_valid
|
||||
|
@ -29,9 +29,9 @@ describe Topic do
|
|||
end
|
||||
|
||||
describe 'when title matches censored pattern' do
|
||||
site_setting(:censored_pattern, 'orange.*')
|
||||
|
||||
it 'should not be valid' do
|
||||
SiteSetting.censored_pattern = 'orange.*'
|
||||
|
||||
topic.title = 'I have orangEjuice orange monkey orange stuff'
|
||||
|
||||
expect(topic).to_not be_valid
|
||||
|
|
|
@ -1,20 +1,6 @@
|
|||
module Helpers
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
class_methods do
|
||||
def site_setting(setting_name, value)
|
||||
original_value = SiteSetting.public_send(setting_name.to_sym)
|
||||
|
||||
self.before do
|
||||
SiteSetting.public_send("#{setting_name}=", value)
|
||||
end
|
||||
|
||||
self.after do
|
||||
SiteSetting.public_send("#{setting_name}=", original_value)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self.next_seq
|
||||
@next_seq = (@next_seq || 0) + 1
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue