From f2dee8e8555409d3b1d333703581c6d62166cf83 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Fri, 9 Jun 2017 18:12:00 -0400 Subject: Test todos_count_format helper at the correct level to improve speed Instead of an integration test that creates 101 Todo records to test a simple view helper, just unit test the helper. --- spec/helpers/todos_helper_spec.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'spec/helpers') diff --git a/spec/helpers/todos_helper_spec.rb b/spec/helpers/todos_helper_spec.rb index 50060a0925d..18a41ca24e3 100644 --- a/spec/helpers/todos_helper_spec.rb +++ b/spec/helpers/todos_helper_spec.rb @@ -1,6 +1,19 @@ require "spec_helper" describe TodosHelper do + describe '#todos_count_format' do + it 'shows fuzzy count for 100 or more items' do + expect(helper.todos_count_format(100)).to eq '99+' + expect(helper.todos_count_format(1000)).to eq '99+' + end + + it 'shows exact count for 99 or fewer items' do + expect(helper.todos_count_format(99)).to eq '99' + expect(helper.todos_count_format(50)).to eq '50' + expect(helper.todos_count_format(1)).to eq '1' + end + end + describe '#todo_projects_options' do let(:projects) { create_list(:empty_project, 3) } let(:user) { create(:user) } -- cgit v1.2.1