Skip to content

Commit

Permalink
Revert ASSUMED_LAP to cover cases where no effort is located; update …
Browse files Browse the repository at this point in the history
…LiveEffortData spec.
  • Loading branch information
moveson committed Feb 10, 2018
1 parent e6d3dde commit 04662d8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion app/view_models/live_effort_data.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
class LiveEffortData
attr_reader :ordered_splits, :effort, :new_split_times, :indexed_existing_split_times
delegate :person_id, to: :effort
ASSUMED_LAP = 1
SUB_SPLIT_KINDS ||= SubSplit.kinds.map { |kind| kind.downcase.to_sym }
COMPARISON_KEYS ||= %w(time_from_start pacer stopped_here)

Expand Down Expand Up @@ -70,7 +71,7 @@ def subject_split
end

def lap
@lap ||= [[(params[:lap].presence.try(:to_i) || expected_lap), 1].max, event.maximum_laps].compact.min
@lap ||= [[(params[:lap].presence.try(:to_i) || expected_lap || ASSUMED_LAP), 1].max, event.maximum_laps].compact.min
end

def expected_lap
Expand Down
4 changes: 2 additions & 2 deletions spec/view_models/live_effort_data_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -383,12 +383,12 @@ def validate_new_split_times(event, effort, split_times, params_hash, attributes
end

describe '#lap' do
it 'returns 1 if no lap is provided' do
it 'returns the expected lap if no lap is provided' do
split_times = effort.split_times.first(3)
provided_split = event.splits[1]
params_hash = {'split_id' => provided_split.id.to_s, lap: '', 'bib_number' => '205',
'time_in' => '', 'time_out' => '', 'id' => '4'}
expected = 1
expected = 2
validate_lap(event, effort, split_times, params_hash, expected)
end

Expand Down

0 comments on commit 04662d8

Please sign in to comment.