Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
7c79dba3
Commit
7c79dba3
authored
Apr 08, 2021
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Very first changes for loading JH extension
parent
409ada30
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
183 additions
and
75 deletions
+183
-75
app/helpers/appearances_helper.rb
app/helpers/appearances_helper.rb
+1
-0
app/helpers/application_helper.rb
app/helpers/application_helper.rb
+8
-1
config/application.rb
config/application.rb
+17
-0
config/initializers/0_inject_enterprise_edition_module.rb
config/initializers/0_inject_enterprise_edition_module.rb
+6
-0
config/initializers/0_license.rb
config/initializers/0_license.rb
+9
-0
config/initializers_before_autoloader/000_inflections.rb
config/initializers_before_autoloader/000_inflections.rb
+1
-0
ee/spec/features/billings/billing_plans_spec.rb
ee/spec/features/billings/billing_plans_spec.rb
+1
-1
lib/gitlab.rb
lib/gitlab.rb
+11
-0
lib/gitlab/subscription_portal.rb
lib/gitlab/subscription_portal.rb
+6
-1
scripts/rspec_helpers.sh
scripts/rspec_helpers.sh
+4
-0
spec/features/admin/admin_settings_spec.rb
spec/features/admin/admin_settings_spec.rb
+1
-1
spec/helpers/application_helper_spec.rb
spec/helpers/application_helper_spec.rb
+8
-6
spec/lib/gitlab/subscription_portal_spec.rb
spec/lib/gitlab/subscription_portal_spec.rb
+29
-27
spec/lib/gitlab_spec.rb
spec/lib/gitlab_spec.rb
+80
-38
spec/spec_helper.rb
spec/spec_helper.rb
+1
-0
No files found.
app/helpers/appearances_helper.rb
View file @
7c79dba3
...
...
@@ -84,3 +84,4 @@ module AppearancesHelper
end
AppearancesHelper
.
prepend_if_ee
(
'EE::AppearancesHelper'
)
AppearancesHelper
.
prepend_if_jh
(
'JH::AppearancesHelper'
)
app/helpers/application_helper.rb
View file @
7c79dba3
...
...
@@ -194,10 +194,16 @@ module ApplicationHelper
end
end
def
promo_host
# This needs to be used outside of Rails
def
self
.
promo_host
'about.gitlab.com'
end
# Convenient method for Rails helper
def
promo_host
ApplicationHelper
.
promo_host
end
def
promo_url
'https://'
+
promo_host
end
...
...
@@ -406,3 +412,4 @@ module ApplicationHelper
end
ApplicationHelper
.
prepend_if_ee
(
'EE::ApplicationHelper'
)
ApplicationHelper
.
prepend_if_jh
(
'JH::ApplicationHelper'
)
config/application.rb
View file @
7c79dba3
...
...
@@ -73,6 +73,23 @@ module Gitlab
config
.
paths
[
'app/views'
].
unshift
"
#{
config
.
root
}
/ee/app/views"
end
if
Gitlab
.
jh?
jh_paths
=
config
.
eager_load_paths
.
each_with_object
([])
do
|
path
,
memo
|
jh_path
=
config
.
root
.
join
(
'jh'
,
Pathname
.
new
(
path
).
relative_path_from
(
config
.
root
))
memo
<<
jh_path
.
to_s
end
jh_paths
<<
"
#{
config
.
root
}
/jh/app/replicators"
# Eager load should load CE/EE first
config
.
eager_load_paths
.
push
(
*
jh_paths
)
config
.
helpers_paths
.
push
"
#{
config
.
root
}
/jh/app/helpers"
# Other than Ruby modules we load JH first
config
.
paths
[
'lib/tasks'
].
unshift
"
#{
config
.
root
}
/jh/lib/tasks"
config
.
paths
[
'app/views'
].
unshift
"
#{
config
.
root
}
/jh/app/views"
end
# Rake tasks ignore the eager loading settings, so we need to set the
# autoload paths explicitly
config
.
autoload_paths
=
config
.
eager_load_paths
.
dup
...
...
config/initializers/0_inject_enterprise_edition_module.rb
View file @
7c79dba3
...
...
@@ -31,6 +31,12 @@ module InjectEnterpriseEditionModule
include
(
ee_module
)
if
Gitlab
.
ee?
end
def
prepend_if_jh
(
constant
,
with_descendants:
false
)
return
unless
Gitlab
.
jh?
prepend_module
(
constant
.
constantize
,
with_descendants
)
end
private
def
prepend_module
(
mod
,
with_descendants
)
...
...
config/initializers/0_license.rb
View file @
7c79dba3
...
...
@@ -8,3 +8,12 @@ Gitlab.ee do
rescue
warn
"WARNING: No valid license encryption key provided."
end
Gitlab
.
jh
do
prefix
=
ENV
[
'GITLAB_LICENSE_MODE'
]
==
'test'
?
'test_'
:
''
public_key_file
=
File
.
read
(
Rails
.
root
.
join
(
"jh"
,
".
#{
prefix
}
license_encryption_key.pub"
))
public_key
=
OpenSSL
::
PKey
::
RSA
.
new
(
public_key_file
)
Gitlab
::
License
.
encryption_key
=
public_key
rescue
warn
"WARNING: No valid JH license encryption key provided."
end
config/initializers_before_autoloader/000_inflections.rb
View file @
7c79dba3
...
...
@@ -35,5 +35,6 @@ ActiveSupport::Inflector.inflections do |inflect|
vulnerability_feedback
)
inflect
.
acronym
'EE'
inflect
.
acronym
'JH'
inflect
.
acronym
'CSP'
end
ee/spec/features/billings/billing_plans_spec.rb
View file @
7c79dba3
...
...
@@ -65,7 +65,7 @@ RSpec.describe 'Billing plan pages', :feature, :js do
it
'displays the contact sales link'
do
# see ApplicationHelper#contact_sales_url
contact_sales_url
=
'https://about.gitlab.com/sales'
contact_sales_url
=
"https://
#{
ApplicationHelper
.
promo_host
}
/sales"
page
.
within
(
'.content'
)
do
expect
(
page
).
to
have_link
(
'Contact sales'
,
href:
%r{
#{
contact_sales_url
}
\?
test=inappcontactsales(bronze|premium|gold)}
)
end
...
...
lib/gitlab.rb
View file @
7c79dba3
...
...
@@ -108,10 +108,21 @@ module Gitlab
!
%w[true 1]
.
include?
(
ENV
[
'FOSS_ONLY'
].
to_s
)
end
def
self
.
jh?
@is_jh
||=
ee?
&&
root
.
join
(
'jh/app/helpers/jh/appearances_helper.rb'
).
exist?
&&
!
%w[true 1]
.
include?
(
ENV
[
'EE_ONLY'
].
to_s
)
end
def
self
.
ee
yield
if
ee?
end
def
self
.
jh
yield
if
jh?
end
def
self
.
http_proxy_env?
HTTP_PROXY_ENV_VARS
.
any?
{
|
name
|
ENV
[
name
]
}
end
...
...
lib/gitlab/subscription_portal.rb
View file @
7c79dba3
...
...
@@ -6,6 +6,11 @@ module Gitlab
::
Gitlab
.
dev_or_test_env?
?
'https://customers.stg.gitlab.com'
:
'https://customers.gitlab.com'
end
SUBSCRIPTIONS_URL
=
ENV
.
fetch
(
'CUSTOMER_PORTAL_URL'
,
default_subscriptions_url
).
freeze
def
self
.
subscriptions_url
ENV
.
fetch
(
'CUSTOMER_PORTAL_URL'
,
default_subscriptions_url
)
end
end
end
Gitlab
::
SubscriptionPortal
.
prepend_if_jh
(
'JH::Gitlab::SubscriptionPortal'
)
Gitlab
::
SubscriptionPortal
::
SUBSCRIPTIONS_URL
=
Gitlab
::
SubscriptionPortal
.
subscriptions_url
.
freeze
scripts/rspec_helpers.sh
View file @
7c79dba3
...
...
@@ -97,6 +97,10 @@ function rspec_paralellized_job() {
spec_folder_prefix
=
"ee/"
fi
if
[[
"
${
test_tool
}
"
=
~
"-jh"
]]
;
then
spec_folder_prefix
=
"jh/"
fi
export
KNAPSACK_LOG_LEVEL
=
"debug"
export
KNAPSACK_REPORT_PATH
=
"knapsack/
${
report_name
}
_report.json"
...
...
spec/features/admin/admin_settings_spec.rb
View file @
7c79dba3
...
...
@@ -588,7 +588,7 @@ RSpec.describe 'Admin updates settings' do
context
'Nav bar'
do
it
'shows default help links in nav'
do
default_support_url
=
'https://about.gitlab.com/getting-help/'
default_support_url
=
"https://
#{
ApplicationHelper
.
promo_host
}
/getting-help/"
visit
root_dashboard_path
...
...
spec/helpers/application_helper_spec.rb
View file @
7c79dba3
...
...
@@ -168,11 +168,13 @@ RSpec.describe ApplicationHelper do
it
{
expect
(
helper
.
active_when
(
false
)).
to
eq
(
nil
)
}
end
describe
'#promo_host'
do
subject
{
helper
.
promo_host
}
unless
Gitlab
.
jh?
describe
'#promo_host'
do
subject
{
helper
.
promo_host
}
it
'returns the url'
do
is_expected
.
to
eq
(
'about.gitlab.com'
)
it
'returns the url'
do
is_expected
.
to
eq
(
'about.gitlab.com'
)
end
end
end
...
...
@@ -180,7 +182,7 @@ RSpec.describe ApplicationHelper do
subject
{
helper
.
promo_url
}
it
'returns the url'
do
is_expected
.
to
eq
(
'https://about.gitlab.com'
)
is_expected
.
to
eq
(
"https://
#{
helper
.
promo_host
}
"
)
end
it
'changes if promo_host changes'
do
...
...
@@ -194,7 +196,7 @@ RSpec.describe ApplicationHelper do
subject
{
helper
.
contact_sales_url
}
it
'returns the url'
do
is_expected
.
to
eq
(
'https://about.gitlab.com/sales'
)
is_expected
.
to
eq
(
"https://
#{
helper
.
promo_host
}
/sales"
)
end
it
'changes if promo_url changes'
do
...
...
spec/lib/gitlab/subscription_portal_spec.rb
View file @
7c79dba3
...
...
@@ -3,39 +3,41 @@
require
'spec_helper'
RSpec
.
describe
::
Gitlab
::
SubscriptionPortal
do
describe
'.default_subscriptions_url'
do
subject
{
described_class
.
default_subscriptions_url
}
context
'on non test and non dev environments'
do
before
do
allow
(
Rails
).
to
receive_message_chain
(
:env
,
:test?
).
and_return
(
false
)
allow
(
Rails
).
to
receive_message_chain
(
:env
,
:development?
).
and_return
(
false
)
unless
Gitlab
.
jh?
describe
'.default_subscriptions_url'
do
subject
{
described_class
.
default_subscriptions_url
}
context
'on non test and non dev environments'
do
before
do
allow
(
Rails
).
to
receive_message_chain
(
:env
,
:test?
).
and_return
(
false
)
allow
(
Rails
).
to
receive_message_chain
(
:env
,
:development?
).
and_return
(
false
)
end
it
'returns production subscriptions app URL'
do
is_expected
.
to
eq
(
'https://customers.gitlab.com'
)
end
end
it
'returns production subscriptions app URL'
do
is_expected
.
to
eq
(
'https://customers.gitlab.com'
)
end
end
context
'on dev environment'
do
before
do
allow
(
Rails
).
to
receive_message_chain
(
:env
,
:test?
).
and_return
(
false
)
allow
(
Rails
).
to
receive_message_chain
(
:env
,
:development?
).
and_return
(
true
)
end
context
'on dev environment'
do
before
do
allow
(
Rails
).
to
receive_message_chain
(
:env
,
:test?
).
and_return
(
false
)
allow
(
Rails
).
to
receive_message_chain
(
:env
,
:development?
).
and_return
(
true
)
it
'returns staging subscriptions app url'
do
is_expected
.
to
eq
(
'https://customers.stg.gitlab.com'
)
end
end
it
'returns staging subscriptions app url'
do
is_expected
.
to
eq
(
'https://customers.stg.gitlab.com'
)
end
end
context
'on test environment'
do
before
do
allow
(
Rails
).
to
receive_message_chain
(
:env
,
:test?
).
and_return
(
true
)
allow
(
Rails
).
to
receive_message_chain
(
:env
,
:development?
).
and_return
(
false
)
end
context
'on test environment'
do
before
do
allow
(
Rails
).
to
receive_message_chain
(
:env
,
:test?
).
and_return
(
true
)
allow
(
Rails
).
to
receive_message_chain
(
:env
,
:development?
).
and_return
(
false
)
end
it
'returns staging subscriptions app url'
do
is_expected
.
to
eq
(
'https://customers.stg.gitlab.com'
)
it
'returns staging subscriptions app url'
do
is_expected
.
to
eq
(
'https://customers.stg.gitlab.com'
)
end
end
end
end
...
...
spec/lib/gitlab_spec.rb
View file @
7c79dba3
...
...
@@ -247,75 +247,117 @@ RSpec.describe Gitlab do
end
end
describe
'
.ee
?'
do
describe
'
ee? and jh
?'
do
before
do
stub_env
(
'FOSS_ONLY'
,
nil
)
# Make sure the ENV is clean
# Make sure the ENV is clean
stub_env
(
'FOSS_ONLY'
,
nil
)
stub_env
(
'EE_ONLY'
,
nil
)
described_class
.
instance_variable_set
(
:@is_ee
,
nil
)
described_class
.
instance_variable_set
(
:@is_jh
,
nil
)
end
after
do
described_class
.
instance_variable_set
(
:@is_ee
,
nil
)
described_class
.
instance_variable_set
(
:@is_jh
,
nil
)
end
context
'for EE'
do
before
do
root
=
Pathname
.
new
(
'dummy'
)
license_path
=
double
(
:path
,
exist?:
true
)
def
stub_path
(
*
paths
,
**
arguments
)
root
=
Pathname
.
new
(
'dummy'
)
pathname
=
double
(
:path
,
**
arguments
)
allow
(
described_class
)
.
to
receive
(
:root
)
.
and_return
(
root
)
allow
(
described_class
)
.
to
receive
(
:root
)
.
and_return
(
root
)
allow
(
root
).
to
receive
(
:join
)
paths
.
each
do
|
path
|
allow
(
root
)
.
to
receive
(
:join
)
.
with
(
'ee/app/models/license.rb'
)
.
and_return
(
license_path
)
.
with
(
path
)
.
and_return
(
pathname
)
end
end
context
'when using FOSS_ONLY=1'
do
describe
'.ee?'
do
context
'for EE'
do
before
do
stub_
env
(
'FOSS_ONLY'
,
'1'
)
stub_
path
(
'ee/app/models/license.rb'
,
exist?:
true
)
end
it
'returns not to be EE'
do
expect
(
described_class
).
not_to
be_ee
context
'when using FOSS_ONLY=1'
do
before
do
stub_env
(
'FOSS_ONLY'
,
'1'
)
end
it
'returns not to be EE'
do
expect
(
described_class
).
not_to
be_ee
end
end
end
context
'when using FOSS_ONLY=0'
do
before
do
stub_env
(
'FOSS_ONLY'
,
'0'
)
context
'when using FOSS_ONLY=0'
do
before
do
stub_env
(
'FOSS_ONLY'
,
'0'
)
end
it
'returns to be EE'
do
expect
(
described_class
).
to
be_ee
end
end
it
'returns to be EE'
do
expect
(
described_class
).
to
be_ee
context
'when using default FOSS_ONLY'
do
it
'returns to be EE'
do
expect
(
described_class
).
to
be_ee
end
end
end
context
'when using default FOSS_ONLY'
do
it
'returns to be EE'
do
expect
(
described_class
).
to
be_ee
context
'for CE'
do
before
do
stub_path
(
'ee/app/models/license.rb'
,
exist?:
false
)
end
it
'returns not to be EE'
do
expect
(
described_class
).
not_to
be_ee
end
end
end
context
'for CE'
do
before
do
root
=
double
(
:path
)
license_path
=
double
(
:path
,
exists?:
false
)
describe
'.jh?'
do
context
'for JH'
do
before
do
stub_path
(
'ee/app/models/license.rb'
,
'jh/app/helpers/jh/appearances_helper.rb'
,
exist?:
true
)
end
allow
(
described_class
)
.
to
receive
(
:root
)
.
and_return
(
Pathname
.
new
(
'dummy'
))
context
'when using default FOSS_ONLY and EE_ONLY'
do
it
'returns to be JH'
do
expect
(
described_class
).
to
be_jh
end
end
allow
(
root
)
.
to
receive
(
:join
)
.
with
(
'ee/app/models/license.rb'
)
.
and_return
(
license_path
)
end
context
'when using FOSS_ONLY=1'
do
before
do
stub_env
(
'FOSS_ONLY'
,
'1'
)
end
it
'returns not to be JH'
do
expect
(
described_class
).
not_to
be_jh
end
end
context
'when using EE_ONLY=1'
do
before
do
stub_env
(
'EE_ONLY'
,
'1'
)
end
it
'returns not to be EE'
do
expect
(
described_class
).
not_to
be_ee
it
'returns not to be JH'
do
expect
(
described_class
).
not_to
be_jh
end
end
end
end
end
...
...
spec/spec_helper.rb
View file @
7c79dba3
...
...
@@ -57,6 +57,7 @@ require 'rainbow/ext/string'
Rainbow
.
enabled
=
false
require_relative
(
'../ee/spec/spec_helper'
)
if
Gitlab
.
ee?
require_relative
(
'../jh/spec/spec_helper'
)
if
Gitlab
.
jh?
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment