From 54b508dda34c4ffe72d5e13171de34ab65832a09 Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Mon, 24 Jul 2017 20:46:44 +0900 Subject: [PATCH] Add back test to ensure user can't edit name after `SiteSetting.username_change_period`. --- spec/controllers/users_controller_spec.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index bb9dabedbe9..81b2e2295bd 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -936,11 +936,13 @@ describe UsersController do expect(user.reload.username).to eq(new_username) end - skip 'should fail if the user is old', 'ensure_can_edit_username! is not throwing' do + it 'should fail if the user is old' do # Older than the change period and >1 post user.created_at = Time.now - (SiteSetting.username_change_period + 1).days - user.stubs(:post_count).returns(200) - expect(Guardian.new(user).can_edit_username?(user)).to eq(false) + PostCreator.new(user, + title: 'This is a test topic', + raw: 'This is a test this is a test' + ).create xhr :put, :username, username: user.username, new_username: new_username