From dbfac0de066c4770a15d4e9a96dbc01edf9add3f Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 26 Dec 2016 16:14:41 +0200 Subject: Rename users with namespace ending with .git Signed-off-by: Dmitriy Zaporozhets --- spec/migrations/remove_dot_git_from_usernames.rb | 29 ++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 spec/migrations/remove_dot_git_from_usernames.rb (limited to 'spec/migrations') diff --git a/spec/migrations/remove_dot_git_from_usernames.rb b/spec/migrations/remove_dot_git_from_usernames.rb new file mode 100644 index 00000000000..1b1d2adc463 --- /dev/null +++ b/spec/migrations/remove_dot_git_from_usernames.rb @@ -0,0 +1,29 @@ +# encoding: utf-8 + +require 'spec_helper' +require Rails.root.join('db', 'migrate', '20161226122833_remove_dot_git_from_usernames.rb') + +describe RemoveDotGitFromUsernames do + let(:user) { create(:user) } + + describe '#up' do + let(:migration) { described_class.new } + + before do + namespace = user.namespace + namespace.path = 'test.git' + namespace.save!(validate: false) + + user.username = 'test.git' + user.save!(validate: false) + end + + it 'renames user with .git in username' do + migration.up + + expect(user.reload.username).to eq('test_git') + expect(user.namespace.reload.path).to eq('test_git') + expect(user.namespace.route.path).to eq('test_git') + end + end +end -- cgit v1.2.1