mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-07 21:48:16 -08:00
Ensure that construct returns the correct zone when the score is right on a benchmark
This commit is contained in:
parent
8915cb9d45
commit
9007cd3078
2 changed files with 27 additions and 9 deletions
|
|
@ -1,10 +1,3 @@
|
||||||
# This file should contain all the record creation needed to seed the database with its default values.
|
|
||||||
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
|
|
||||||
#
|
|
||||||
# Examples:
|
|
||||||
#
|
|
||||||
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
|
|
||||||
# Mayor.create(name: 'Emanuel', city: cities.first)
|
|
||||||
require 'csv'
|
require 'csv'
|
||||||
|
|
||||||
Item.destroy_all
|
Item.destroy_all
|
||||||
|
|
@ -27,8 +20,6 @@ CSV.parse(csv_file, headers: true).each do |row|
|
||||||
item_prompt = row['Survey Item']
|
item_prompt = row['Survey Item']
|
||||||
Item.create construct: Construct.find_by_construct_id(construct_id), prompt: item_prompt
|
Item.create construct: Construct.find_by_construct_id(construct_id), prompt: item_prompt
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# questions = Category.find_by_name('Family Subcategory').child_categories.map(&:questions).flatten
|
# questions = Category.find_by_name('Family Subcategory').child_categories.map(&:questions).flatten
|
||||||
|
|
|
||||||
|
|
@ -15,4 +15,31 @@ describe Construct, type: :model do
|
||||||
expect(construct.approval_zone).to eq Construct::Zone.new(3.5, 4.71, :approval)
|
expect(construct.approval_zone).to eq Construct::Zone.new(3.5, 4.71, :approval)
|
||||||
expect(construct.ideal_zone).to eq Construct::Zone.new(4.71, 5.0, :ideal)
|
expect(construct.ideal_zone).to eq Construct::Zone.new(4.71, 5.0, :ideal)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '#zone_for_score' do
|
||||||
|
let(:construct) {
|
||||||
|
Construct.new watch_low_benchmark: 1.5, growth_low_benchmark: 2.5, approval_low_benchmark: 3.5, ideal_low_benchmark: 4.5
|
||||||
|
}
|
||||||
|
|
||||||
|
context 'when the score is 1.0' do
|
||||||
|
it 'returns the warning zone' do
|
||||||
|
expect(construct.zone_for_score(1.0)).to eq construct.warning_zone
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when the score is 5.0' do
|
||||||
|
it 'returns the ideal zone' do
|
||||||
|
expect(construct.zone_for_score(5.0)).to eq construct.ideal_zone
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when the score is right on the benchmark' do
|
||||||
|
it 'returns the higher zone' do
|
||||||
|
expect(construct.zone_for_score(1.5)).to eq construct.watch_zone
|
||||||
|
expect(construct.zone_for_score(2.5)).to eq construct.growth_zone
|
||||||
|
expect(construct.zone_for_score(3.5)).to eq construct.approval_zone
|
||||||
|
expect(construct.zone_for_score(4.5)).to eq construct.ideal_zone
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue