BigW Consortium Gitlab

project.rb 4.83 KB
Newer Older
Nihad Abbasov committed
1 2 3
module SharedProject
  include Spinach::DSL

4
  # Create a project without caring about what it's called
5
  step "I own a project" do
6
    @project = create(:project, namespace: @user.namespace)
7
    @project.team << [@user, :master]
8 9 10
  end

  # Create a specific project called "Shop"
11
  step 'I own project "Shop"' do
skv committed
12
    @project = Project.find_by(name: "Shop")
13
    @project ||= create(:project, name: "Shop", namespace: @user.namespace, snippets_enabled: true)
14
    @project.team << [@user, :master]
Nihad Abbasov committed
15
  end
16

17 18 19 20 21 22 23
  # Add another user to project "Shop"
  step 'I add a user to project "Shop"' do
    @project = Project.find_by(name: "Shop")
    other_user = create(:user, name: 'Alpha')
    @project.team << [other_user, :master]
  end

24
  # Create another specific project called "Forum"
25
  step 'I own project "Forum"' do
skv committed
26
    @project = Project.find_by(name: "Forum")
27
    @project ||= create(:project, name: "Forum", namespace: @user.namespace, path: 'forum_project')
28 29 30
    @project.team << [@user, :master]
  end

31
  # Create an empty project without caring about the name
32
  step 'I own an empty project' do
33 34 35 36 37
    @project = create(:empty_project,
                      name: 'Empty Project', namespace: @user.namespace)
    @project.team << [@user, :master]
  end

38
  step 'I visit my empty project page' do
Vinnie Okada committed
39 40
    project = Project.find_by(name: 'Empty Project')
    visit namespace_project_path(project.namespace, project)
41 42
  end

43
  step 'project "Shop" has push event' do
skv committed
44
    @project = Project.find_by(name: "Shop")
45 46

    data = {
47
      before: Gitlab::Git::BLANK_SHA,
48 49
      after: "6d394385cf567f80a8fd85055db1ab4c5295806f",
      ref: "refs/heads/fix",
50 51 52 53 54 55 56 57 58 59 60 61 62
      user_id: @user.id,
      user_name: @user.name,
      repository: {
        name: @project.name,
        url: "localhost/rubinius",
        description: "",
        homepage: "localhost/rubinius",
        private: true
      }
    }

    @event = Event.create(
      project: @project,
63
      action: Event::PUSHED,
64 65 66 67 68
      data: data,
      author_id: @user.id
    )
  end

69
  step 'I should see project "Shop" activity feed' do
skv committed
70
    project = Project.find_by(name: "Shop")
71
    page.should have_content "#{@user.name} pushed new branch fix at #{project.name_with_namespace}"
72 73
  end

74
  step 'I should see project settings' do
Vinnie Okada committed
75
    current_path.should == edit_namespace_project_path(@project.namespace, @project)
76
    page.should have_content("Project name")
77 78 79
    page.should have_content("Features:")
  end

80 81 82
  def current_project
    @project ||= Project.first
  end
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100

  # ----------------------------------------
  # Visibility level
  # ----------------------------------------

  step 'private project "Enterprise"' do
    create :project, name: 'Enterprise'
  end

  step 'I should see project "Enterprise"' do
    page.should have_content "Enterprise"
  end

  step 'I should not see project "Enterprise"' do
    page.should_not have_content "Enterprise"
  end

  step 'internal project "Internal"' do
101
    create :project, :internal, name: 'Internal'
102 103 104 105 106 107 108 109 110 111 112
  end

  step 'I should see project "Internal"' do
    page.should have_content "Internal"
  end

  step 'I should not see project "Internal"' do
    page.should_not have_content "Internal"
  end

  step 'public project "Community"' do
113
    create :project, :public, name: 'Community'
114 115 116 117 118 119 120 121 122 123
  end

  step 'I should see project "Community"' do
    page.should have_content "Community"
  end

  step 'I should not see project "Community"' do
    page.should_not have_content "Community"
  end

124
  step '"John Doe" owns private project "Enterprise"' do
125
    user = user_exists("John Doe", username: "john_doe")
126
    project = Project.find_by(name: "Enterprise")
127
    project ||= create(:empty_project, name: "Enterprise", namespace: user.namespace)
128 129 130
    project.team << [user, :master]
  end

131
  step '"John Doe" owns internal project "Internal"' do
132
    user = user_exists("John Doe", username: "john_doe")
133
    project = Project.find_by(name: "Internal")
134
    project ||= create :empty_project, :internal, name: 'Internal', namespace: user.namespace
135 136 137
    project.team << [user, :master]
  end

138
  step '"John Doe" owns public project "Community"' do
139
    user = user_exists("John Doe", username: "john_doe")
140
    project = Project.find_by(name: "Community")
141
    project ||= create :empty_project, :public, name: 'Community', namespace: user.namespace
142 143
    project.team << [user, :master]
  end
Ciro Santilli committed
144 145

  step 'public empty project "Empty Public Project"' do
146
    create :project_empty_repo, :public, name: "Empty Public Project"
Ciro Santilli committed
147
  end
148 149 150 151 152

  step 'project "Community" has comments' do
    project = Project.find_by(name: "Community")
    2.times { create(:note_on_issue, project: project) }
  end
Dmitriy Zaporozhets committed
153 154 155 156 157 158 159

  step 'project "Shop" has labels: "bug", "feature", "enhancement"' do
    project = Project.find_by(name: "Shop")
    create(:label, project: project, title: 'bug')
    create(:label, project: project, title: 'feature')
    create(:label, project: project, title: 'enhancement')
  end
Nihad Abbasov committed
160
end