summaryrefslogtreecommitdiff
path: root/spec/migrations/remove_dot_git_from_usernames.rb
blob: 1b1d2adc46386cf0bd7c44162c90220faf1db5f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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