summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke "Jared" Bennett <lbennett@gitlab.com>2017-01-06 20:17:37 +0000
committerLuke "Jared" Bennett <lbennett@gitlab.com>2017-01-07 10:54:05 +0000
commit37bbdb604c89ce3a17ad56eb03bf3c8d5be3bc4f (patch)
treedcf34d21b785e6f56eb412efec0bce954471e633
parenta57597108fdc3d05a1996b2e09b1d0f56acc57fc (diff)
downloadgitlab-ce-ryancharris/gitlab-ce-25277-milestone-counter-number-with-delimiter.tar.gz
-rw-r--r--spec/javascripts/fixtures/issuables.html.haml5
-rw-r--r--spec/javascripts/milestones_spec.js.es621
-rw-r--r--spec/views/shared/milestones/_issuables.html.haml.rb32
3 files changed, 32 insertions, 26 deletions
diff --git a/spec/javascripts/fixtures/issuables.html.haml b/spec/javascripts/fixtures/issuables.html.haml
deleted file mode 100644
index 42daf8508d9..00000000000
--- a/spec/javascripts/fixtures/issuables.html.haml
+++ /dev/null
@@ -1,5 +0,0 @@
-.panel.panel-default
- .panel-heading
- Unstarted Issues (open and unassigned)
- .pull-right
- 1
diff --git a/spec/javascripts/milestones_spec.js.es6 b/spec/javascripts/milestones_spec.js.es6
deleted file mode 100644
index 7c1f9cbde12..00000000000
--- a/spec/javascripts/milestones_spec.js.es6
+++ /dev/null
@@ -1,21 +0,0 @@
-/*= require jquery */
-(() => {
- describe('MilestonePanel', () => {
- const issuesCount = '.pull-right';
- const fixtureTemplate = 'issuables.html';
-
- function setIssuesCount(newCount) {
- $(issuesCount).text(newCount);
- }
-
- fixture.preload(fixtureTemplate);
- beforeEach(() => {
- fixture.load(fixtureTemplate);
- });
-
- it('should add delimiter to the issues count', () => {
- setIssuesCount(1000);
- expect($(issuesCount).text()).toEqual('1,000');
- });
- });
-})();
diff --git a/spec/views/shared/milestones/_issuables.html.haml.rb b/spec/views/shared/milestones/_issuables.html.haml.rb
new file mode 100644
index 00000000000..4769d569548
--- /dev/null
+++ b/spec/views/shared/milestones/_issuables.html.haml.rb
@@ -0,0 +1,32 @@
+require 'spec_helper'
+
+describe 'shared/milestones/_issuables.html.haml' do
+ let(:issuables_size) { 100 }
+
+ before do
+ allow(view).to receive_messages(title: nil, id: nil, show_project_name: nil,
+ show_full_project_name: nil, dom_class: '',
+ issuables: double(size: issuables_size).as_null_object)
+
+ stub_template 'shared/milestones/_issuable.html.haml' => ''
+ end
+
+ it 'should show the issuables count if show_counter is true' do
+ render 'shared/milestones/issuables', show_counter: true
+ expect(rendered).to have_content('100')
+ end
+
+ it 'should not show the issuables count if show_counter is false' do
+ render 'shared/milestones/issuables', show_counter: false
+ expect(rendered).not_to have_content('100')
+ end
+
+ describe 'a high issuables count' do
+ let(:issuables_size) { 1000 }
+
+ it 'should show a delimited number if show_counter is true' do
+ render 'shared/milestones/issuables', show_counter: true
+ expect(rendered).to have_content('1,000')
+ end
+ end
+end