mirror of
https://github.com/discourse/discourse.git
synced 2025-09-05 08:59:27 +08:00
Merge branch 'master' of github.com:discourse/discourse
This commit is contained in:
commit
7d7d8c7d4f
16 changed files with 127 additions and 13 deletions
|
@ -2,6 +2,11 @@ require 'spec_helper'
|
|||
|
||||
describe UsersController do
|
||||
|
||||
before do
|
||||
UsersController.any_instance.stubs(:honeypot_value).returns(nil)
|
||||
UsersController.any_instance.stubs(:challenge_value).returns(nil)
|
||||
end
|
||||
|
||||
describe '.show' do
|
||||
let!(:user) { log_in }
|
||||
|
||||
|
@ -339,7 +344,41 @@ describe UsersController do
|
|||
User.where(username: @user.username).first.active.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
shared_examples_for 'honeypot fails' do
|
||||
it 'should not create a new user' do
|
||||
expect {
|
||||
xhr :post, :create, create_params
|
||||
}.to_not change { User.count }
|
||||
end
|
||||
|
||||
it 'should not send an email' do
|
||||
User.any_instance.expects(:enqueue_welcome_message).never
|
||||
xhr :post, :create, create_params
|
||||
end
|
||||
|
||||
it 'should say it was successful' do
|
||||
xhr :post, :create, create_params
|
||||
json = JSON::parse(response.body)
|
||||
json["success"].should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context 'when honeypot value is wrong' do
|
||||
before do
|
||||
UsersController.any_instance.stubs(:honeypot_value).returns('abc')
|
||||
end
|
||||
let(:create_params) { {:name => @user.name, :username => @user.username, :password => "strongpassword", :email => @user.email, :password_confirmation => 'wrong'} }
|
||||
it_should_behave_like 'honeypot fails'
|
||||
end
|
||||
|
||||
context 'when challenge answer is wrong' do
|
||||
before do
|
||||
UsersController.any_instance.stubs(:challenge_value).returns('abc')
|
||||
end
|
||||
let(:create_params) { {:name => @user.name, :username => @user.username, :password => "strongpassword", :email => @user.email, :challenge => 'abc'} }
|
||||
it_should_behave_like 'honeypot fails'
|
||||
end
|
||||
end
|
||||
|
||||
context '.username' do
|
||||
|
|
|
@ -111,6 +111,13 @@ describe PostAction do
|
|||
|
||||
describe 'flagging' do
|
||||
|
||||
it 'does not allow you to flag stuff with 2 reasons' do
|
||||
post = Fabricate(:post)
|
||||
u1 = Fabricate(:evil_trout)
|
||||
PostAction.act(u1, post, PostActionType.Types[:spam])
|
||||
lambda { PostAction.act(u1, post, PostActionType.Types[:off_topic]) }.should raise_error(PostAction::AlreadyFlagged)
|
||||
end
|
||||
|
||||
it 'should update counts when you clear flags' do
|
||||
post = Fabricate(:post)
|
||||
u1 = Fabricate(:evil_trout)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue