Commit 2f6374cd authored by huzaifaiftikhar1's avatar huzaifaiftikhar1

Handle case when project statistics is nil

parent 9b47c95b
...@@ -2869,7 +2869,7 @@ class Project < ApplicationRecord ...@@ -2869,7 +2869,7 @@ class Project < ApplicationRecord
end end
def inactive? def inactive?
statistics.storage_size > ::Gitlab::CurrentSettings.inactive_projects_min_size_mb.megabytes && (statistics || build_statistics).storage_size > ::Gitlab::CurrentSettings.inactive_projects_min_size_mb.megabytes &&
last_activity_at < ::Gitlab::CurrentSettings.inactive_projects_send_warning_email_after_months.months.ago last_activity_at < ::Gitlab::CurrentSettings.inactive_projects_send_warning_email_after_months.months.ago
end end
......
...@@ -3357,14 +3357,14 @@ RSpec.describe Project do ...@@ -3357,14 +3357,14 @@ RSpec.describe Project do
context 'when project belongs to free namespace' do context 'when project belongs to free namespace' do
let_it_be(:no_plan_group) { create(:group_with_plan, plan: nil) } let_it_be(:no_plan_group) { create(:group_with_plan, plan: nil) }
let_it_be(:project) { create(:project, namespace: no_plan_group) } let_it_be_with_reload(:project) { create(:project, namespace: no_plan_group) }
it_behaves_like 'returns true if project is inactive' it_behaves_like 'returns true if project is inactive'
end end
end end
context 'when not Gitlab.com' do context 'when not Gitlab.com' do
let_it_be(:project) { create(:project, name: 'test-project') } let_it_be_with_reload(:project) { create(:project, name: 'test-project') }
it_behaves_like 'returns true if project is inactive' it_behaves_like 'returns true if project is inactive'
end end
......
...@@ -8179,7 +8179,7 @@ RSpec.describe Project, factory_default: :keep do ...@@ -8179,7 +8179,7 @@ RSpec.describe Project, factory_default: :keep do
end end
describe '#inactive?' do describe '#inactive?' do
let_it_be(:project) { create(:project, name: 'test-project') } let_it_be_with_reload(:project) { create(:project, name: 'test-project') }
it_behaves_like 'returns true if project is inactive' it_behaves_like 'returns true if project is inactive'
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