From e617cf95d448891d51361154d6845218cb5a4508 Mon Sep 17 00:00:00 2001
From: Marin Jankovski <marin@gitlab.com>
Date: Tue, 8 Apr 2014 17:12:57 +0200
Subject: [PATCH] Add issue to an empty repo, test.

---
 app/views/projects/issues/_form.html.haml |  2 +-
 features/project/issues/issues.feature    |  9 +++++++++
 features/steps/project/issues.rb          | 21 +++++++++++++++++++++
 3 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/app/views/projects/issues/_form.html.haml b/app/views/projects/issues/_form.html.haml
index 05cae80e50c..91d0de8e47c 100644
--- a/app/views/projects/issues/_form.html.haml
+++ b/app/views/projects/issues/_form.html.haml
@@ -1,7 +1,7 @@
 %div.issue-form-holder
   %h3.page-title= @issue.new_record? ? "New Issue" : "Edit Issue ##{@issue.iid}"
   %hr
-  - if !@repository.empty? && @repository.contribution_guide && !@issue.persisted?
+  - if @repository.exists? && !@repository.empty? && @repository.contribution_guide && !@issue.persisted?
     - contribution_guide_url = project_blob_path(@project, tree_join(@repository.root_ref, @repository.contribution_guide.name))
     .alert.alert-info.col-sm-10.col-sm-offset-2
       ="Please review the <strong>#{link_to "guidelines for contribution", contribution_guide_url}</strong> to this repository.".html_safe
diff --git a/features/project/issues/issues.feature b/features/project/issues/issues.feature
index 033051991e2..c5311544efa 100644
--- a/features/project/issues/issues.feature
+++ b/features/project/issues/issues.feature
@@ -67,3 +67,12 @@ Feature: Project Issues
     Given I visit issue page "Release 0.4"
     And I leave a comment with a header containing "Comment with a header"
     Then The comment with the header should not have an ID
+
+  Scenario: Issues on empty project
+    Given empty project "Empty Project"
+    When I visit empty project page
+    And I see empty project details with ssh clone info
+    When I visit empty project's issues page
+    Given I click link "New Issue"
+    And I submit new issue "500 error on profile"
+    Then I should see issue "500 error on profile"
diff --git a/features/steps/project/issues.rb b/features/steps/project/issues.rb
index a92fd50584d..d1f3ba25a21 100644
--- a/features/steps/project/issues.rb
+++ b/features/steps/project/issues.rb
@@ -142,4 +142,25 @@ class ProjectIssues < Spinach::FeatureSteps
            project: project,
            author: project.users.first)
   end
+
+  Given 'empty project "Empty Project"' do
+    create :empty_project, name: 'Empty Project', namespace: @user.namespace
+  end
+
+  When 'I visit empty project page' do
+    project = Project.find_by(name: 'Empty Project')
+    visit project_path(project)
+  end
+
+  And 'I see empty project details with ssh clone info' do
+    project = Project.find_by(name: 'Empty Project')
+    page.all(:css, '.git-empty .clone').each do |element|
+      element.text.should include(project.url_to_repo)
+    end
+  end
+
+  When "I visit empty project's issues page" do
+    project = Project.find_by(name: 'Empty Project')
+    visit project_issues_path(project)
+  end
 end
-- 
GitLab