Skip to content

Commit

Permalink
Rename current_checks to checks
Browse files Browse the repository at this point in the history
There is no more conflict with the relationship
  • Loading branch information
coolo committed Nov 22, 2018
1 parent d0b971b commit fdac465
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
12 changes: 6 additions & 6 deletions src/api/app/models/staging/staging_project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ def unassign_managers_group(managers)
relationships.find_by(group: managers, role: role).try(:destroy!)
end

def current_checks
@current_checks ||= Status::Check.where(status_reports_id: relevant_status_reports_for_repositories | relevant_status_reports_for_architectures)
def checks
@checks ||= Status::Check.where(status_reports_id: relevant_status_reports_for_repositories | relevant_status_reports_for_architectures)
end

def current_missing_checks
@current_missing_checks ||= (relevant_status_reports_for_repositories + relevant_status_reports_for_architectures).map(&:missing_checks).flatten
def missing_checks
@missing_checks ||= (relevant_status_reports_for_repositories + relevant_status_reports_for_architectures).map(&:missing_checks).flatten
end

def failed_status_checks
Expand Down Expand Up @@ -166,8 +166,8 @@ def relevant_status_reports_for_architectures
end

def check_state
return :testing if current_missing_checks.present? || current_checks.pending.exists?
return :failed if current_checks.failed.exists?
return :testing if missing_checks.present? || checks.pending.exists?
return :failed if checks.failed.exists?
return :acceptable
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
locals: { staging_project: @staging_project, items: @staging_project.broken_packages, type: 'broken_packages' }
%tr
= render partial: 'checks',
locals: { checks: @staging_project.current_checks,
missing_checks: @staging_project.current_missing_checks }
locals: { checks: @staging_project.checks, missing_checks: @staging_project.missing_checks }
.col-xl-2
= render partial: 'webui/staging/shared/legend'
6 changes: 3 additions & 3 deletions src/api/spec/models/staging/staging_project_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
let!(:check) { create(:check, name: 'check_1', status_report: build_report, state: 'failure') }

it { expect(staging_project.overall_state).to eq(:failed) }
it { expect(staging_project.current_checks).to contain_exactly(check) }
it { expect(staging_project.checks).to contain_exactly(check) }
end

context 'when there are succeeded checks' do
Expand All @@ -151,8 +151,8 @@
end

it { expect(staging_project.overall_state).to eq(:testing) }
it { expect(staging_project.current_missing_checks).to contain_exactly('check_1') }
it { expect(staging_project.current_checks).to be_empty }
it { expect(staging_project.missing_checks).to contain_exactly('check_1') }
it { expect(staging_project.checks).to be_empty }
end
end

Expand Down

0 comments on commit fdac465

Please sign in to comment.