From a10252362a7c99ee759699f1f48cef9e3b1e0a66 Mon Sep 17 00:00:00 2001
From: Luke Bennett <lbennett@gitlab.com>
Date: Sat, 11 May 2019 05:16:51 +0100
Subject: [PATCH] Resolve CE/EE diffs in zero_authorized_projects

Part of single codebase changes.
---
 app/helpers/dashboard_helper.rb               |  4 +++
 .../_zero_authorized_projects.html.haml       | 12 ++++----
 ee/app/helpers/ee/dashboard_helper.rb         |  4 +++
 ee/spec/helpers/ee/dashboard_helper_spec.rb   | 29 +++++++++++++++++++
 spec/helpers/dashboard_helper_spec.rb         |  6 ++++
 5 files changed, 48 insertions(+), 7 deletions(-)
 create mode 100644 ee/spec/helpers/ee/dashboard_helper_spec.rb

diff --git a/app/helpers/dashboard_helper.rb b/app/helpers/dashboard_helper.rb
index df1a76f055e..3348cdcb57d 100644
--- a/app/helpers/dashboard_helper.rb
+++ b/app/helpers/dashboard_helper.rb
@@ -21,6 +21,10 @@ module DashboardHelper
     links.any? { |link| dashboard_nav_link?(link) }
   end
 
+  def has_start_trial?
+    false
+  end
+
   private
 
   def get_dashboard_nav_links
diff --git a/app/views/dashboard/projects/_zero_authorized_projects.html.haml b/app/views/dashboard/projects/_zero_authorized_projects.html.haml
index 8ea0262d700..8933c5d7227 100644
--- a/app/views/dashboard/projects/_zero_authorized_projects.html.haml
+++ b/app/views/dashboard/projects/_zero_authorized_projects.html.haml
@@ -1,7 +1,5 @@
-- admin_without_ee_license = !current_license && current_user.admin?
-
-.blank-state-parent-container{ class: ('has-start-trial-container' if admin_without_ee_license) }
-  .section-container.section-welcome
+.blank-state-parent-container{ class: ('has-start-trial-container' if has_start_trial?) }
+  .section-container.section-welcome{ class: "#{ 'section-admin-welcome' if current_user.admin? }" }
     .container.section-body
       .row
         .blank-state-welcome
@@ -10,11 +8,11 @@
           %p.blank-state-text
             Code, test, and deploy together
         .blank-state-row
-          %div{ class: ('column-large' if admin_without_ee_license) }
+          %div{ class: ('column-large' if has_start_trial?) }
             - if current_user.admin?
               = render "blank_state_admin_welcome"
             - else
               = render "blank_state_welcome"
-          - if admin_without_ee_license
+          - if has_start_trial?
             .column-small
-              = render "blank_state_ee_trial"
+              = render_if_exists "blank_state_ee_trial"
diff --git a/ee/app/helpers/ee/dashboard_helper.rb b/ee/app/helpers/ee/dashboard_helper.rb
index 07ae06b1b7b..c21734ec50b 100644
--- a/ee/app/helpers/ee/dashboard_helper.rb
+++ b/ee/app/helpers/ee/dashboard_helper.rb
@@ -24,5 +24,9 @@ module EE
     def user_default_dashboard?(user)
       controller_action_to_child_dashboards.any? {|dashboard| dashboard == user.dashboard }
     end
+
+    def has_start_trial?
+      !current_license && current_user.admin?
+    end
   end
 end
diff --git a/ee/spec/helpers/ee/dashboard_helper_spec.rb b/ee/spec/helpers/ee/dashboard_helper_spec.rb
new file mode 100644
index 00000000000..fc864845291
--- /dev/null
+++ b/ee/spec/helpers/ee/dashboard_helper_spec.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe DashboardHelper, type: :helper do
+  describe '.has_start_trial?' do
+    using RSpec::Parameterized::TableSyntax
+
+    where(:has_license, :current_user, :output) do
+      false | :admin | true
+      false | :user  | false
+      true  | :admin | false
+      true  | :user  | false
+    end
+
+    with_them do
+      let(:user) { create(current_user) }
+      let(:license) { has_license && create(:license) }
+      subject { helper.has_start_trial? }
+
+      before do
+        allow(helper).to receive(:current_user).and_return(user)
+        allow(helper).to receive(:current_license).and_return(license)
+      end
+
+      it { is_expected.to eq(output) }
+    end
+  end
+end
diff --git a/spec/helpers/dashboard_helper_spec.rb b/spec/helpers/dashboard_helper_spec.rb
index 7ba24ba2956..023238ee0ae 100644
--- a/spec/helpers/dashboard_helper_spec.rb
+++ b/spec/helpers/dashboard_helper_spec.rb
@@ -21,4 +21,10 @@ describe DashboardHelper do
       expect(helper.dashboard_nav_links).not_to include(:activity, :milestones)
     end
   end
+
+  describe '.has_start_trial?' do
+    subject { helper.has_start_trial? }
+
+    it { is_expected.to eq(false) }
+  end
 end
-- 
2.30.9