summaryrefslogtreecommitdiff
path: root/spec/tasks
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2016-10-07 18:35:36 +0200
committerRémy Coutable <remy@rymai.me>2016-10-11 10:21:18 +0200
commitebba49149395ba6fb0f14c3aa9c46a496b234dea (patch)
treea058eedc37b8b6ec8b2a21273771ec2bbd0fe7fe /spec/tasks
parent73adae0f62a3d6048abbee9d076e077185370325 (diff)
downloadgitlab-ce-ebba49149395ba6fb0f14c3aa9c46a496b234dea.tar.gz
Add a new gitlab:users:clear_all_authentication_tokens task
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'spec/tasks')
-rw-r--r--spec/tasks/gitlab/users_rake_spec.rb38
1 files changed, 38 insertions, 0 deletions
diff --git a/spec/tasks/gitlab/users_rake_spec.rb b/spec/tasks/gitlab/users_rake_spec.rb
new file mode 100644
index 00000000000..e6ebef82b78
--- /dev/null
+++ b/spec/tasks/gitlab/users_rake_spec.rb
@@ -0,0 +1,38 @@
+require 'spec_helper'
+require 'rake'
+
+describe 'gitlab:users namespace rake task' do
+ let(:enable_registry) { true }
+
+ before :all do
+ Rake.application.rake_require 'tasks/gitlab/task_helpers'
+ Rake.application.rake_require 'tasks/gitlab/users'
+
+ # empty task as env is already loaded
+ Rake::Task.define_task :environment
+ end
+
+ def run_rake_task(task_name)
+ Rake::Task[task_name].reenable
+ Rake.application.invoke_task task_name
+ end
+
+ describe 'clear_all_authentication_tokens' do
+ before do
+ # avoid writing task output to spec progress
+ allow($stdout).to receive :write
+ end
+
+ context 'gitlab version' do
+ it 'clears the authentication token for all users' do
+ create_list(:user, 2)
+
+ expect(User.pluck(:authentication_token)).to all(be_present)
+
+ run_rake_task('gitlab:users:clear_all_authentication_tokens')
+
+ expect(User.pluck(:authentication_token)).to all(be_nil)
+ end
+ end
+ end
+end