forked from SplitTime/OpenSplitTime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
effort_show_view_spec.rb
58 lines (46 loc) · 2.01 KB
/
effort_show_view_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
require 'rails_helper'
RSpec.describe EffortShowView do
subject { EffortShowView.new(effort: effort) }
let(:event) { build_stubbed(:event, efforts: efforts) }
let(:efforts) { other_efforts + [effort] }
before do
allow(subject).to receive(:event).and_return(event)
end
describe '#next_problem_effort' do
context 'when the current effort is a problem effort' do
let(:effort) { build_stubbed(:effort, data_status: :questionable) }
context 'when other problem efforts exist' do
let(:other_efforts) { build_stubbed_list(:effort, 2, data_status: :bad).sort_by(&:last_name) }
it 'returns the next problem effort alphabetically by last name' do
effort.last_name = 'Aaron'
expect(subject.next_problem_effort).to eq(other_efforts.first)
end
it 'returns the first problem effort if the current effort is last alphabetically' do
effort.last_name = 'Zyzyx'
expect(subject.next_problem_effort).to eq(other_efforts.first)
end
end
context 'when no other problem efforts exist' do
let(:other_efforts) { build_stubbed_list(:effort, 2, data_status: :good).sort_by(&:last_name) }
it 'returns nil' do
expect(subject.next_problem_effort).to be_nil
end
end
end
context 'when the current effort is not a problem effort' do
let(:effort) { build_stubbed(:effort, data_status: :good) }
context 'when other problem efforts exist' do
let(:other_efforts) { build_stubbed_list(:effort, 2, data_status: :bad).sort_by(&:last_name) }
it 'returns the first problem effort alphabetically by last name' do
expect(subject.next_problem_effort).to eq(other_efforts.first)
end
end
context 'when no other problem efforts exist' do
let(:other_efforts) { build_stubbed_list(:effort, 2, data_status: :good).sort_by(&:last_name) }
it 'returns nil' do
expect(subject.next_problem_effort).to be_nil
end
end
end
end
end