mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-09 07:28:41 -07:00
Refactor variance chart to make view responsible for sorting measures
This commit is contained in:
parent
f5e5abc27e
commit
ad7dd85524
9 changed files with 58 additions and 62 deletions
|
|
@ -9,18 +9,18 @@ describe 'dashboard/index.html.erb' do
|
|||
|
||||
before :each do
|
||||
assign :category_presenters, []
|
||||
assign :measure_graph_row_presenters, measure_graph_row_presenters
|
||||
assign :variance_chart_row_presenters, variance_chart_row_presenters
|
||||
|
||||
render
|
||||
end
|
||||
|
||||
context 'when some presenters have a nil score' do
|
||||
let(:measure_graph_row_presenters) {
|
||||
let(:variance_chart_row_presenters) {
|
||||
[
|
||||
MeasureGraphRowPresenter.new(measure: support_for_teaching, score: nil),
|
||||
MeasureGraphRowPresenter.new(measure: create(:measure, name: 'Should Be Displayed', measure_id: 'should-be-displayed'), score: rand),
|
||||
MeasureGraphRowPresenter.new(measure: effective_leadership, score: nil),
|
||||
MeasureGraphRowPresenter.new(measure: professional_qualifications, score: nil)
|
||||
VarianceChartRowPresenter.new(measure: support_for_teaching, score: nil),
|
||||
VarianceChartRowPresenter.new(measure: create(:measure, name: 'Should Be Displayed', measure_id: 'should-be-displayed'), score: rand),
|
||||
VarianceChartRowPresenter.new(measure: effective_leadership, score: nil),
|
||||
VarianceChartRowPresenter.new(measure: professional_qualifications, score: nil)
|
||||
]
|
||||
}
|
||||
|
||||
|
|
@ -40,9 +40,9 @@ describe 'dashboard/index.html.erb' do
|
|||
end
|
||||
|
||||
context 'when all the presenters have a non-nil score' do
|
||||
let(:measure_graph_row_presenters) {
|
||||
let(:variance_chart_row_presenters) {
|
||||
[
|
||||
MeasureGraphRowPresenter.new(measure: create(:measure, name: 'Display Me', measure_id: 'display-me'), score: rand)
|
||||
VarianceChartRowPresenter.new(measure: create(:measure, name: 'Display Me', measure_id: 'display-me'), score: rand)
|
||||
]
|
||||
}
|
||||
|
||||
|
|
|
|||
26
spec/views/dashboard/variance_chart.html.erb_spec.rb
Normal file
26
spec/views/dashboard/variance_chart.html.erb_spec.rb
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
require 'rails_helper'
|
||||
|
||||
describe 'dashboard/_variance_chart.html.erb' do
|
||||
subject { Nokogiri::HTML(rendered) }
|
||||
|
||||
let(:higher_scoring_measure) { create(:measure) }
|
||||
let(:lower_scoring_measure) { create(:measure) }
|
||||
|
||||
before :each do
|
||||
presenters = [
|
||||
VarianceChartRowPresenter.new(measure: lower_scoring_measure, score: 1),
|
||||
VarianceChartRowPresenter.new(measure: higher_scoring_measure, score: 5)
|
||||
]
|
||||
|
||||
render partial: 'variance_chart', locals: { presenters: presenters }
|
||||
end
|
||||
|
||||
it 'displays higher scoring measures above lower scoring measures' do
|
||||
measure_row_bars = subject.css("rect.measure-row-bar")
|
||||
|
||||
higher_scoring_measure_index = measure_row_bars.find_index { |bar| bar['data-for-measure-id'] == higher_scoring_measure.measure_id }
|
||||
lower_scoring_measure_index = measure_row_bars.find_index { |bar| bar['data-for-measure-id'] == lower_scoring_measure.measure_id }
|
||||
|
||||
expect(higher_scoring_measure_index).to be < lower_scoring_measure_index
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue