Commit 09760e6

mo khan <mo@mokhan.ca>
2015-06-01 03:43:45
key by date rather than epoch.
1 parent 06feff2
Changed files (2)
app/models/training_history.rb
@@ -14,7 +14,7 @@ class TrainingHistory
       joins(:exercise).
       where(exercises: { name: exercise.name }).
       inject({}) do |memo, session|
-        memo[session.training_session.occurred_at.to_i] = session.target_weight
+        memo[session.training_session.occurred_at] = session.target_weight
         memo
       end
   end
spec/models/training_history_spec.rb
@@ -18,7 +18,8 @@ describe TrainingHistory do
     it "returns the history in the format required for the chart" do
       result = subject.to_line_chart
       expect(result).to_not be_nil
-      expect(result[date.to_i]).to eql(target_weight.to_f)
+      expect(result.keys.first.to_i).to eql(date.to_i)
+      expect(result.values.first).to eql(target_weight.to_f)
     end
   end
 end