diff options
author | Jeff Stubler <brunsa2@gmail.com> | 2017-09-05 16:57:37 -0500 |
---|---|---|
committer | Jeff Stubler <brunsa2@gmail.com> | 2017-09-05 16:57:37 -0500 |
commit | 0429ad80921cb38229cdbe650d1ca113c24eb88d (patch) | |
tree | 50bc106fb0607a4d19a1047e7d69f677e62c43fe /spec/helpers | |
parent | 85c3128a505a999b2ac775aac1336a0d27e7df55 (diff) | |
download | gitlab-ce-0429ad80921cb38229cdbe650d1ca113c24eb88d.tar.gz |
Refactor blame helper age class tests
Diffstat (limited to 'spec/helpers')
-rw-r--r-- | spec/helpers/blame_helper_spec.rb | 37 |
1 files changed, 15 insertions, 22 deletions
diff --git a/spec/helpers/blame_helper_spec.rb b/spec/helpers/blame_helper_spec.rb index 659c53b1b5c..722d21c566f 100644 --- a/spec/helpers/blame_helper_spec.rb +++ b/spec/helpers/blame_helper_spec.rb @@ -35,39 +35,32 @@ describe BlameHelper do end describe '#age_map_class' do - let(:dates) do - [Time.zone.local(2014, 3, 17, 0, 0, 0), Time.zone.now] - end - let(:blame_groups) do - [ - { commit: double(committed_date: dates[0]) } - ] - end - let(:today_blame_groups) do - [ - { commit: double(committed_date: dates[1]) } - ] - end + let(:date) { Time.zone.local(2014, 3, 17, 0, 0, 0) } + let(:blame_groups) { [{ commit: double(committed_date: date) }] } let(:duration) do - project = double(created_at: dates[0]) + project = double(created_at: date) helper.age_map_duration(blame_groups, project) end - let(:same_day_duration) do - project = double(created_at: dates[1]) - helper.age_map_duration(today_blame_groups, project) - end it 'returns blame-commit-age-9 when oldest' do - expect(helper.age_map_class(dates[0], duration)).to eq 'blame-commit-age-9' + expect(helper.age_map_class(date, duration)).to eq 'blame-commit-age-9' end it 'returns blame-commit-age-0 class when newest' do expect(helper.age_map_class(duration[:now], duration)).to eq 'blame-commit-age-0' end - it 'returns blame-commit-age-0 class when created on same day' do - puts(same_day_duration.inspect) - expect(helper.age_map_class(duration[:now], same_day_duration)).to eq 'blame-commit-age-0' + context 'when called on the same day as project creation' do + let(:same_day_duration) do + project = double(created_at: now) + helper.age_map_duration(today_blame_groups, project) + end + let(:today_blame_groups) { [{ commit: double(committed_date: now) }] } + let(:now) { Time.zone.now } + + it 'returns blame-commit-age-0 class' do + expect(helper.age_map_class(duration[:now], same_day_duration)).to eq 'blame-commit-age-0' + end end end end |