From 56d046c2bf337c4e2d2aff59f3f191429e1646cb Mon Sep 17 00:00:00 2001
From: Khai Do <zaro0508@gmail.com>
Date: Tue, 17 Mar 2015 09:53:48 -0700
Subject: [PATCH] Fix jquery setup on Gerrit server.

The libjs-query package sets up jquery on trusty with these
files and sim links:

 ~$ ll /usr/share/javascript/jquery/
 drwxr-xr-x 2 root root   4096 Jan 15 20:44 ./
 drwxr-xr-x 5 root root   4096 Jan 15 20:44 ../
 -rw-r--r-- 1 root root 252879 Jul  5  2013 jquery.js
 lrwxrwxrwx 1 root root     13 Jul  5  2013 jquery.lite.js -> jquery.min.js
 lrwxrwxrwx 1 root root      9 Jul  5  2013 jquery.min.js -> jquery.js
 lrwxrwxrwx 1 root root     13 Jul  5  2013 jquery.pack.js -> jquery.min.js
 -rw-r--r-- 1 root root      5 May 23  2012 version.txt

The current puppet config is broken for trusty because it attempts to copy
the link instead of the file. This results in a broken sim link to jquery
and breaks the Toggle CI button on Gerrit because that button depends on
jquery.  This change corrects this situation by copying the file provided
jquery.js file instead of the link.

Change-Id: I18056ca528871d9a96218f0919bbd262da005f31
---
 .../files/gerrit/GerritSiteHeader.html             |  2 +-
 modules/openstack_project/manifests/gerrit.pp      | 14 +++++++++-----
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/modules/openstack_project/files/gerrit/GerritSiteHeader.html b/modules/openstack_project/files/gerrit/GerritSiteHeader.html
index 535594079e..218977658d 100644
--- a/modules/openstack_project/files/gerrit/GerritSiteHeader.html
+++ b/modules/openstack_project/files/gerrit/GerritSiteHeader.html
@@ -1,5 +1,5 @@
 <div>
-  <script type="text/javascript" src="static/jquery.min.js" />
+  <script type="text/javascript" src="static/jquery.js" />
   <script type="text/javascript" src="static/hideci.js" />
   <a href="/"><h1 style="color: #CF2F19"><img src="static/title.png" style="vertical-align:middle;" /></h1></a>
 </div>
diff --git a/modules/openstack_project/manifests/gerrit.pp b/modules/openstack_project/manifests/gerrit.pp
index 7254e53648..f1c9a94309 100644
--- a/modules/openstack_project/manifests/gerrit.pp
+++ b/modules/openstack_project/manifests/gerrit.pp
@@ -271,12 +271,16 @@ class openstack_project::gerrit (
     ensure => present,
   }
 
-  file { '/home/gerrit2/review_site/static/jquery.min.js':
+  file { '/home/gerrit2/review_site/static/jquery.js':
     ensure  => present,
-    source  => '/usr/share/javascript/jquery/jquery.min.js',
-    require => [Class['::gerrit'],
-                Package['libjs-jquery']],
-    notify => Exec['reload_gerrit_header'],
+    source  => '/usr/share/javascript/jquery/jquery.js',
+    require     => [
+        File['/home/gerrit2/review_site/static'],
+        Class['::gerrit'],
+        Package['libjs-jquery'],
+      ],
+    subscribe   => Package['libjs-jquery'],
+    notify      => Exec['reload_gerrit_header'],
   }
 
   file { '/home/gerrit2/review_site/static/hideci.js':