From 99679bc6a09f9bad529bc1e8d6ff365f8e7c0fc1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rub=C3=A9n=20D=C3=A1vila?= <rdavila84@gmail.com>
Date: Fri, 15 Jan 2016 12:35:25 -0500
Subject: [PATCH] Add specs for Forks listing.

---
 features/project/fork.feature  | 15 +++++++++++++++
 features/steps/project/fork.rb | 25 +++++++++++++++++++++++++
 2 files changed, 40 insertions(+)

diff --git a/features/project/fork.feature b/features/project/fork.feature
index 37cd53ee977..12695204e47 100644
--- a/features/project/fork.feature
+++ b/features/project/fork.feature
@@ -25,3 +25,18 @@ Feature: Project Fork
     Then I should see "New merge request"
     And I click link "New merge request"
     Then I should see the new merge request page for my namespace
+
+  Scenario: Viewing forks of a Project
+    Given I click link "Fork"
+    When I fork to my namespace
+    And I visit the forks page of the "Shop" project
+    Then I should see my fork on the list
+
+  Scenario: Viewing private forks of a Project
+    Given There is an existent fork of the "Shop" project
+    And I click link "Fork"
+    When I fork to my namespace
+    And I visit the forks page of the "Shop" project
+    Then I should see my fork on the list
+    And I should not see the other fork listed
+    And I should see a private fork notice
diff --git a/features/steps/project/fork.rb b/features/steps/project/fork.rb
index e98bd51ca89..5810276ced3 100644
--- a/features/steps/project/fork.rb
+++ b/features/steps/project/fork.rb
@@ -49,4 +49,29 @@ class Spinach::Features::ProjectFork < Spinach::FeatureSteps
   step 'I should see the new merge request page for my namespace' do
     current_path.should have_content(/#{current_user.namespace.name}/i)
   end
+
+  step 'I visit the forks page of the "Shop" project' do
+    @project = Project.where(name: 'Shop').last
+    visit namespace_project_forks_path(@project.namespace, @project)
+  end
+
+  step 'I should see my fork on the list' do
+    page.within('.projects-list-holder') do
+      project = @user.fork_of(@project)
+      expect(page).to have_content("#{project.namespace.human_name} / #{project.name}")
+    end
+  end
+
+  step 'There is an existent fork of the "Shop" project' do
+    user = create(:user, name: 'Mike')
+    @forked_project = Projects::ForkService.new(@project, user).execute
+  end
+
+  step 'I should not see the other fork listed' do
+    expect(page).not_to have_content("#{@forked_project.namespace.human_name} / #{@forked_project.name}")
+  end
+
+  step 'I should see a private fork notice' do
+    expect(page).to have_content("1 private fork")
+  end
 end
-- 
GitLab