Commit 4d2d7099 authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch 'fix-plan-projects-finder' into 'master'

Fix Project.for_plan_name to use the correct plan

See merge request gitlab-org/gitlab!29019
parents 1af6b957 01112e54
...@@ -112,7 +112,7 @@ module EE ...@@ -112,7 +112,7 @@ module EE
scope :outside_shards, -> (shard_names) { where.not(repository_storage: Array(shard_names)) } scope :outside_shards, -> (shard_names) { where.not(repository_storage: Array(shard_names)) }
scope :verification_failed_repos, -> { joins(:repository_state).merge(ProjectRepositoryState.verification_failed_repos) } scope :verification_failed_repos, -> { joins(:repository_state).merge(ProjectRepositoryState.verification_failed_repos) }
scope :verification_failed_wikis, -> { joins(:repository_state).merge(ProjectRepositoryState.verification_failed_wikis) } scope :verification_failed_wikis, -> { joins(:repository_state).merge(ProjectRepositoryState.verification_failed_wikis) }
scope :for_plan_name, -> (name) { joins(namespace: :plan).where(plans: { name: name }) } scope :for_plan_name, -> (name) { joins(namespace: { gitlab_subscription: :hosted_plan }).where(plans: { name: name }) }
scope :requiring_code_owner_approval, scope :requiring_code_owner_approval,
-> { joins(:protected_branches).where(protected_branches: { code_owner_approval_required: true }) } -> { joins(:protected_branches).where(protected_branches: { code_owner_approval_required: true }) }
scope :with_active_services, -> { joins(:services).merge(::Service.active) } scope :with_active_services, -> { joins(:services).merge(::Service.active) }
......
...@@ -4,18 +4,19 @@ require 'spec_helper' ...@@ -4,18 +4,19 @@ require 'spec_helper'
describe ProjectsFinder do describe ProjectsFinder do
describe '#execute' do describe '#execute' do
let_it_be(:user) { create(:user) }
let(:finder) { described_class.new(current_user: user, params: params, project_ids_relation: project_ids_relation) } let(:finder) { described_class.new(current_user: user, params: params, project_ids_relation: project_ids_relation) }
let(:user) { create(:user) }
subject { finder.execute } subject { finder.execute }
describe 'filter by plans' do describe 'filter by plans' do
let(:params) { { plans: plans } } let(:params) { { plans: plans } }
let(:project_ids_relation) { nil } let(:project_ids_relation) { nil }
let!(:gold_project) { create_project(:gold_plan) }
let!(:gold_project2) { create_project(:gold_plan) } let_it_be(:gold_project) { create_project(:gold_plan) }
let!(:silver_project) { create_project(:silver_plan) } let_it_be(:gold_project2) { create_project(:gold_plan) }
let!(:no_plan_project) { create_project(nil) } let_it_be(:silver_project) { create_project(:silver_plan) }
let_it_be(:no_plan_project) { create_project(nil) }
context 'with gold plan' do context 'with gold plan' do
let(:plans) { ['gold'] } let(:plans) { ['gold'] }
...@@ -50,10 +51,7 @@ describe ProjectsFinder do ...@@ -50,10 +51,7 @@ describe ProjectsFinder do
private private
def create_project(plan) def create_project(plan)
namespace = create(:namespace_with_plan, plan: plan) create(:project, :public, namespace: create(:namespace_with_plan, plan: plan))
namespace.update(plan: namespace.gitlab_subscription&.hosted_plan)
create(:project, :public, namespace: namespace)
end end
end 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