Commit 0ae9da0

mo khan <mo@mokhan.ca>
2016-07-10 22:19:46
add planks.
1 parent 5776555
Changed files (3)
app/models/user_recommendation.rb
@@ -10,7 +10,7 @@ class UserRecommendation
   def prepare_sets
     target_weight = next_weight
     work_sets = recommended_sets.times.map do
-      work_set(target_weight, repetitions)
+      work_set(target_weight)
     end
     (WarmUp.new(exercise, target_weight).sets + work_sets).compact
   end
@@ -21,11 +21,11 @@ class UserRecommendation
 
   private
 
-  def work_set(target_weight, repetitions)
+  def work_set(target_weight)
     WorkSet.new(
       exercise: exercise,
       target_repetitions: repetitions,
-      target_weight: target_weight
+      target_weight: target_weight,
     )
   end
 
spec/models/program_spec.rb
@@ -149,5 +149,17 @@ describe Program do
         expect(worksets.map(&:target_repetitions)).to match_array([5])
       end
     end
+
+    describe "planks" do
+      let(:user) { build(:user) }
+
+      it "returns 3 set with 1 rep at 60 seconds" do
+        sets = subject.prepare_sets_for(user, planks)
+        worksets = sets.select(&:work?)
+        expect(worksets.length).to eql(3)
+        expect(worksets.map(&:target_repetitions)).to match_array([1])
+        expect(worksets.map(&:duration)).to match_array([60])
+      end
+    end
   end
 end
spec/support/stronglifts_program.rb
@@ -6,6 +6,7 @@ shared_context "stronglifts_program" do
   let!(:bench_press) { create(:exercise, name: "Bench Press") }
   let!(:barbell_row) { create(:exercise, name: "Barbell Row") }
   let!(:dips) { create(:exercise, name: "Dips") }
+  let!(:planks) { create(:exercise, name: "Planks") }
   let!(:squat_workout) do
     routine_a.add_exercise(squat, sets: 5, repetitions: 5)
   end
@@ -16,6 +17,9 @@ shared_context "stronglifts_program" do
     routine_a.add_exercise(barbell_row, sets: 5, repetitions: 5)
   end
   let!(:dips_workout) { routine_a.add_exercise(dips, sets: 3, repetitions: 5) }
+  let!(:planks_workout) do
+    routine_a.add_exercise(planks, sets: 3, duration: 60.seconds)
+  end
 
   let!(:routine_b) { program.routines.create name: "B" }
   let!(:overhead_press) { create(:exercise, name: "Overhead Press") }