summaryrefslogtreecommitdiff
path: root/spec/features/projects/project_settings_spec.rb
blob: 55d5d082c6e3174e1fe9f918b50775f777ec73c6 (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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
require 'spec_helper'

describe 'Edit Project Settings', feature: true do
  let(:user) { create(:user) }
  let(:project) { create(:empty_project, path: 'gitlab', name: 'sample') }

  before do
    login_as(user)
    project.team << [user, :master]
  end

  describe 'Project settings', js: true do
    it 'shows errors for invalid project name' do
      visit edit_namespace_project_path(project.namespace, project)

      fill_in 'project_name_edit', with: 'foo&bar'

      click_button 'Save changes'

      expect(page).to have_field 'project_name_edit', with: 'foo&bar'
      expect(page).to have_content "Name can contain only letters, digits, emojis, '_', '.', dash, space. It must start with letter, digit, emoji or '_'."
      expect(page).to have_button 'Save changes'
    end

    scenario 'shows a successful notice when the project is updated' do
      visit edit_namespace_project_path(project.namespace, project)

      fill_in 'project_name_edit', with: 'hello world'

      click_button 'Save changes'

      expect(page).to have_content "Project 'hello world' was successfully updated."
    end
  end

  describe 'Rename repository' do
    it 'shows errors for invalid project path/name' do
      visit edit_namespace_project_path(project.namespace, project)

      fill_in 'Project name', with: 'foo&bar'
      fill_in 'Path', with: 'foo&bar'

      click_button 'Rename project'

      expect(page).to have_field 'Project name', with: 'foo&bar'
      expect(page).to have_field 'Path', with: 'foo&bar'
      expect(page).to have_content "Name can contain only letters, digits, emojis, '_', '.', dash, space. It must start with letter, digit, emoji or '_'."
      expect(page).to have_content "Path can contain only letters, digits, '_', '-' and '.'. Cannot start with '-', end in '.git' or end in '.atom'"
    end
  end

  describe 'Rename repository name with emojis' do
    it 'shows error for invalid project name' do
      visit edit_namespace_project_path(project.namespace, project)

      fill_in 'Project name', with: '🚀 foo bar ☁️'

      click_button 'Rename project'

      expect(page).to have_field 'Project name', with: '🚀 foo bar ☁️'
      expect(page).not_to have_content "Name can contain only letters, digits, emojis '_', '.', dash and space. It must start with letter, digit, emoji or '_'."
    end
  end
end