Commit 1ea69589 authored by Luke Bennett's avatar Luke Bennett

Update user_has_namespace_with_gold? to check for any plan instead of just gold plan

parent f8e74da7
# frozen_string_literal: true
module EE
module UsersHelper
def users_sentence(users, link_class: nil)
users.map { |user| link_to(user.name, user, class: link_class) }.to_sentence.html_safe
end
def user_namespace_union(user = current_user, select = :id)
::Gitlab::SQL::Union.new([
::Namespace.select(select).where(type: nil, owner: user),
user.owned_groups.select(select).where(parent_id: nil)
]).to_sql
end
def user_has_namespace_with_trial?(user = current_user)
::Namespace
.from("(#{user_namespace_union(user, :trial_ends_on)}) #{::Namespace.table_name}")
.where('trial_ends_on > ?', Time.now.utc)
.any?
end
def user_has_namespace_with_gold?(user = current_user)
::Namespace
.includes(:plan)
.where("namespaces.id IN (#{user_namespace_union(user)})") # rubocop:disable GitlabSecurity/SqlInjection
.where.not(plans: { id: nil })
.any?
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment