From 39a4bb2abda20fe85a362c1718eab9dfd7de13a3 Mon Sep 17 00:00:00 2001
From: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Date: Wed, 8 Jul 2015 16:55:04 +0200
Subject: [PATCH] Cleanup and some test fixes after refactoring project home
 page

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
---
 app/assets/javascripts/project_show.js.coffee |  9 +--------
 app/views/projects/buttons/_star.html.haml    | 19 +++++++++----------
 app/views/projects/show.html.haml             |  2 +-
 features/project/issues/issues.feature        |  1 +
 features/project/shortcuts.feature            |  1 -
 features/steps/project/issues/issues.rb       |  5 +++++
 features/steps/project/star.rb                |  2 +-
 features/steps/shared/project_tab.rb          |  4 ++++
 8 files changed, 22 insertions(+), 21 deletions(-)

diff --git a/app/assets/javascripts/project_show.js.coffee b/app/assets/javascripts/project_show.js.coffee
index cb47062842e..1fdf28f2528 100644
--- a/app/assets/javascripts/project_show.js.coffee
+++ b/app/assets/javascripts/project_show.js.coffee
@@ -1,10 +1,3 @@
 class @ProjectShow
   constructor: ->
-    $("a[data-toggle='tab']").on "shown.bs.tab", (e) ->
-        $.cookie "default_view", $(e.target).attr("href"), { expires: 30, path: '/' }
-
-      defaultView = $.cookie("default_view")
-      if defaultView
-        $("a[href=" + defaultView + "]").tab "show"
-      else
-        $("a[data-toggle='tab']:first").tab "show"
+    # I kept class for future
diff --git a/app/views/projects/buttons/_star.html.haml b/app/views/projects/buttons/_star.html.haml
index 89e3f4ac738..664ebd18295 100644
--- a/app/views/projects/buttons/_star.html.haml
+++ b/app/views/projects/buttons/_star.html.haml
@@ -1,22 +1,21 @@
 - if current_user
-  = link_to toggle_star_namespace_project_path(@project.namespace, @project), class: 'btn toggle-star', method: :post, remote: true do
+  = link_to toggle_star_namespace_project_path(@project.namespace, @project), class: 'btn star-btn toggle-star', method: :post, remote: true do
     - if current_user.starred?(@project)
       Unstar
     - else
       Star
     %span.count
       = @project.star_count
+
+  :coffeescript
+    $('.project-home-panel .toggle-star').on 'ajax:success', (e, data, status, xhr) ->
+      $(@).replaceWith(data.html)
+    .on 'ajax:error', (e, xhr, status, error) ->
+      new Flash('Star toggle failed. Try again later.', 'alert')
+
 - else
-  = link_to new_user_session_path, class: 'btn has_tooltip', title: 'You must sign in to star a project' do
+  = link_to new_user_session_path, class: 'btn has_tooltip star-btn', title: 'You must sign in to star a project' do
     = icon('star')
     Star
     %span.count
       = @project.star_count
-
-:coffeescript
-  $('.project-home-panel .toggle-star').on 'ajax:success', (e, data, status, xhr) ->
-    $(@).replaceWith(data.html)
-  .on 'ajax:error', (e, xhr, status, error) ->
-    new Flash('Star toggle failed. Try again later.', 'alert')
-
-
diff --git a/app/views/projects/show.html.haml b/app/views/projects/show.html.haml
index 8fb5f25c2f6..17907a42e3c 100644
--- a/app/views/projects/show.html.haml
+++ b/app/views/projects/show.html.haml
@@ -51,7 +51,7 @@
         = render_readme(readme)
   - else
     %h3.page-title
-      This project does not have README yet :(
+      This project does not have README yet
     - if can?(current_user, :push_code, @project)
       %p.slead
         A
diff --git a/features/project/issues/issues.feature b/features/project/issues/issues.feature
index a15298fc452..28cc43ef710 100644
--- a/features/project/issues/issues.feature
+++ b/features/project/issues/issues.feature
@@ -189,6 +189,7 @@ Feature: Project Issues
     Given I logout
     Given public project "Community"
     When I visit project "Community" page
+    And I visit project "Community" issues page
     And I click link "New Issue"
     And I should not see assignee field
     And I should not see milestone field
diff --git a/features/project/shortcuts.feature b/features/project/shortcuts.feature
index 9567b571120..2369c02806f 100644
--- a/features/project/shortcuts.feature
+++ b/features/project/shortcuts.feature
@@ -53,6 +53,5 @@ Feature: Project Shortcuts
 
   @javascript
   Scenario: Navigate to project feed
-    Given I visit my project's files page
     Given I press "g" and "e"
     Then the active main tab should be Activity
diff --git a/features/steps/project/issues/issues.rb b/features/steps/project/issues/issues.rb
index 9ace6436b15..239392eab96 100644
--- a/features/steps/project/issues/issues.rb
+++ b/features/steps/project/issues/issues.rb
@@ -194,6 +194,11 @@ class Spinach::Features::ProjectIssues < Spinach::FeatureSteps
     end
   end
 
+  When "I visit project \"Community\" issues page" do
+    project = Project.find_by(name: 'Community')
+    visit namespace_project_issues_path(project.namespace, project)
+  end
+
   When "I visit empty project's issues page" do
     project = Project.find_by(name: 'Empty Project')
     visit namespace_project_issues_path(project.namespace, project)
diff --git a/features/steps/project/star.rb b/features/steps/project/star.rb
index 8b50bfcef04..bd2e0619cdd 100644
--- a/features/steps/project/star.rb
+++ b/features/steps/project/star.rb
@@ -5,7 +5,7 @@ class Spinach::Features::ProjectStar < Spinach::FeatureSteps
   include SharedUser
 
   step "The project has no stars" do
-    expect(page).not_to have_content '.star-buttons'
+    expect(page).not_to have_content '.toggle-star'
   end
 
   step "The project has 0 stars" do
diff --git a/features/steps/shared/project_tab.rb b/features/steps/shared/project_tab.rb
index 3b94b7d8621..c67e5e4a06a 100644
--- a/features/steps/shared/project_tab.rb
+++ b/features/steps/shared/project_tab.rb
@@ -49,4 +49,8 @@ module SharedProjectTab
       expect(page).to have_content('Back to project')
     end
   end
+
+  step 'the active main tab should be Activity' do
+    ensure_active_main_tab('Activity')
+  end
 end
-- 
GitLab