summaryrefslogtreecommitdiff
path: root/spec/features/projects/new_project_spec.rb
blob: 52196ce49bd2059285a5ce62626ef99da271295c (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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
require "spec_helper"

feature "New project", feature: true do
  let(:user) { create(:admin) }

  before do
    login_as(user)
  end

  context "Visibility level selector" do
    Gitlab::VisibilityLevel.options.each do |key, level|
      it "sets selector to #{key}" do
        stub_application_setting(default_project_visibility: level)

        visit new_project_path

        expect(find_field("project_visibility_level_#{level}")).to be_checked
      end

      it 'saves visibility level on validation error' do
        visit new_project_path

        choose(key)
        click_button('Create project')

        expect(find_field("project_visibility_level_#{level}")).to be_checked
      end
    end
  end

  context "Namespace selector" do
    context "with user namespace" do
      before do
        visit new_project_path
      end

      it "selects the user namespace" do
        namespace = find("#project_namespace_id")

        expect(namespace.text).to eq user.username
      end
    end

    context "with group namespace" do
      let(:group) { create(:group, :private, owner: user) }

      before do
        group.add_owner(user)
        visit new_project_path(namespace_id: group.id)
      end

      it "selects the group namespace" do
        namespace = find("#project_namespace_id option[selected]")

        expect(namespace.text).to eq group.name
      end

      context "on validation error" do
        before do
          fill_in('project_path', with: 'private-group-project')
          choose('Internal')
          click_button('Create project')

          expect(page).to have_css '.project-edit-errors .alert.alert-danger'
        end

        it "selects the group namespace" do
          namespace = find("#project_namespace_id option[selected]")

          expect(namespace.text).to eq group.name
        end
      end
    end
  end

  context 'Import project options' do
    before do
      visit new_project_path
    end

    it 'does not autocomplete sensitive git repo URL' do
      autocomplete = find('#project_import_url')['autocomplete']

      expect(autocomplete).to eq('off')
    end
  end
end