summaryrefslogtreecommitdiff
path: root/spec/helpers
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2017-06-09 18:12:00 -0400
committerRobert Speicher <rspeicher@gmail.com>2017-06-09 18:23:19 -0400
commitf2dee8e8555409d3b1d333703581c6d62166cf83 (patch)
tree6096261b6d7aa2d15f1c51f8c3e671f19ff40782 /spec/helpers
parentb16730fc8317b282d5dc86dbc8936c74303f5a36 (diff)
downloadgitlab-ce-f2dee8e8555409d3b1d333703581c6d62166cf83.tar.gz
Test todos_count_format helper at the correct level to improve speedrs-simplify-todo-count-spec
Instead of an integration test that creates 101 Todo records to test a simple view helper, just unit test the helper.
Diffstat (limited to 'spec/helpers')
-rw-r--r--spec/helpers/todos_helper_spec.rb13
1 files changed, 13 insertions, 0 deletions
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) }