Skip to content

Commit

Permalink
Morning has a different max BG
Browse files Browse the repository at this point in the history
  • Loading branch information
pikesley committed Feb 24, 2016
1 parent 0029864 commit a89ed1d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
20 changes: 18 additions & 2 deletions app/presenters/glucose_measurement_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,24 @@ def units
end

def highlight_class
return 'bg-high' if is_high
return 'bg-high' if model.value > 8
return 'bg-low' if model.value < 4.5
nil
return 'bg-low' if is
end

def is_high
return true if model.value > 7 && is_morning
return true if model.value > 8
false
end

def is_low
return true if model.value < 4.5
false
end

def is_morning
time = model.datetime.strftime '%H:%M'
time > '06:30' && time < '11:00'
end
end
6 changes: 6 additions & 0 deletions spec/presenters/glucose_measurement_presenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,11 @@
it 'has the correct css class for a high BG' do
expect(decorated_high_bg.measurement_cell).to match /<td class='glucose-measurement-value bg-high'>/
end

let(:high_am_bg) { create :glucose_measurement, value: 7.5, datetime: '2016-01-26 07:15:29' }
let(:decorated_high_am_bg) { GlucoseMeasurementPresenter.new high_am_bg }
it 'knows the limits are different in the morning' do
expect(decorated_high_am_bg.measurement_cell).to match /<td class='glucose-measurement-value bg-high'>/
end
end
end

0 comments on commit a89ed1d

Please sign in to comment.