Commit 5071a971 authored by Kamil Trzcinski's avatar Kamil Trzcinski

Rename remaining project_metrics to be project_statistics

parent 0828f69d
......@@ -14,8 +14,6 @@ module EE
delegate :actual_shared_runners_minutes_limit,
:shared_runners_minutes_used?, to: :namespace
has_one :project_metrics, dependent: :destroy
end
def shared_runners_available?
......
......@@ -7,7 +7,7 @@ class ClearSharedRunnersMinutesWorker
def perform
return unless try_obtain_lease
ProjectMetrics.update_all(
ProjectStatistics.update_all(
shared_runners_minutes: 0,
shared_runners_minutes_last_reset: Time.now)
......
......@@ -212,7 +212,6 @@ project:
- path_locks
- approver_groups
- route
- project_metrics
- statistics
award_emoji:
- awardable
......
......@@ -2,10 +2,8 @@ require 'spec_helper'
describe Project, models: true do
describe 'associations' do
it { is_expected.to have_one(:project_metrics).dependent(:destroy) }
it { is_expected.to delegate_method(:shared_runners_minutes).to(:project_metrics) }
it { is_expected.to delegate_method(:shared_runners_minutes_last_reset).to(:project_metrics) }
it { is_expected.to delegate_method(:shared_runners_minutes).to(:project_statistics) }
it { is_expected.to delegate_method(:shared_runners_minutes_last_reset).to(:project_statistics) }
it { is_expected.to delegate_method(:actual_shared_runners_minutes_limit).to(:namespace) }
it { is_expected.to delegate_method(:shared_runners_minutes_limit_enabled?).to(:namespace) }
......
require 'spec_helper'
describe ProjectMetrics, models: true do
it { is_expected.to belong_to(:project) }
it { is_expected.to validate_presence_of(:project) }
end
......@@ -19,7 +19,7 @@ describe UpdateBuildMinutesService, services: true do
it "creates a metrics and sets duration" do
subject
expect(project.project_metrics.reload.shared_runners_minutes).
expect(project.project_statistics.reload.shared_runners_minutes).
to eq(build.duration.to_i)
expect(namespace.namespace_statistics.reload.shared_runners_minutes).
......@@ -28,14 +28,14 @@ describe UpdateBuildMinutesService, services: true do
context 'when metrics are created' do
before do
project.create_project_metrics(shared_runners_minutes: 100)
project.create_project_statistics(shared_runners_minutes: 100)
namespace.create_namespace_metrics(shared_runners_minutes: 100)
end
it "updates metrics and adds duration" do
subject
expect(project.project_metrics.reload.shared_runners_minutes).
expect(project.project_statistics.reload.shared_runners_minutes).
to eq(100 + build.duration.to_i)
expect(namespace.namespace_statistics.reload.shared_runners_minutes).
......@@ -50,7 +50,7 @@ describe UpdateBuildMinutesService, services: true do
it "does not create metrics" do
subject
expect(project.project_metrics).to be_nil
expect(project.project_statistics).to be_nil
expect(namespace.namespace_statistics).to be_nil
end
end
......
......@@ -12,18 +12,18 @@ describe ClearSharedRunnersMinutesWorker do
subject { worker.perform }
context 'when project metrics are defined' do
let!(:project_metrics) { create(:project_metrics, shared_runners_minutes: 100) }
let!(:project_statistics) { create(:project_statistics, shared_runners_minutes: 100) }
it 'clears counters' do
subject
expect(project_metrics.reload.shared_runners_minutes).to be_zero
expect(project_statistics.reload.shared_runners_minutes).to be_zero
end
it 'resets timer' do
subject
expect(project_metrics.reload.shared_runners_minutes_last_reset).to be_like_time(Time.now)
expect(project_statistics.reload.shared_runners_minutes_last_reset).to be_like_time(Time.now)
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