summaryrefslogtreecommitdiff
path: root/spec/serializers
diff options
context:
space:
mode:
authorJames Lopez <james@jameslopez.es>2016-11-16 15:55:20 +0100
committerJames Lopez <james@jameslopez.es>2016-11-17 08:22:59 +0100
commitcbd7d000395ff60fe3726e67ec351bd4d44582ec (patch)
treef497cc29ef7cb87a9f6bd4334ea536f6b6aa81fd /spec/serializers
parent4844476e77f625829d99b7db2680186939ef660a (diff)
downloadgitlab-ce-cbd7d000395ff60fe3726e67ec351bd4d44582ec.tar.gz
added custom date helper and spec and fixed some unrelated spec failures
Diffstat (limited to 'spec/serializers')
-rw-r--r--spec/serializers/entity_date_helper_spec.rb45
1 files changed, 45 insertions, 0 deletions
diff --git a/spec/serializers/entity_date_helper_spec.rb b/spec/serializers/entity_date_helper_spec.rb
new file mode 100644
index 00000000000..90e57833de7
--- /dev/null
+++ b/spec/serializers/entity_date_helper_spec.rb
@@ -0,0 +1,45 @@
+require 'spec_helper'
+
+describe EntityDateHelper do
+ let(:date_helper_class) { Class.new { include EntityDateHelper }.new }
+
+ it 'converts 0 seconds' do
+ expect(date_helper_class.distance_of_time_as_hash(0)).to eq(seconds: 0)
+ end
+
+ it 'converts 40 seconds' do
+ expect(date_helper_class.distance_of_time_as_hash(40)).to eq(seconds: 40)
+ end
+
+ it 'converts 60 seconds' do
+ expect(date_helper_class.distance_of_time_as_hash(60)).to eq(mins: 1)
+ end
+
+ it 'converts 70 seconds' do
+ expect(date_helper_class.distance_of_time_as_hash(70)).to eq(mins: 1, seconds: 10)
+ end
+
+ it 'converts 3600 seconds' do
+ expect(date_helper_class.distance_of_time_as_hash(3600)).to eq(hours: 1)
+ end
+
+ it 'converts 3750 seconds' do
+ expect(date_helper_class.distance_of_time_as_hash(3750)).to eq(hours: 1, mins: 2, seconds: 30)
+ end
+
+ it 'converts 86400 seconds' do
+ expect(date_helper_class.distance_of_time_as_hash(86400)).to eq(days: 1)
+ end
+
+ it 'converts 86560 seconds' do
+ expect(date_helper_class.distance_of_time_as_hash(86560)).to eq(days: 1, mins: 2, seconds: 40)
+ end
+
+ it 'converts 86760 seconds' do
+ expect(date_helper_class.distance_of_time_as_hash(99760)).to eq(days: 1, hours: 3, mins: 42, seconds: 40)
+ end
+
+ it 'converts 986760 seconds' do
+ expect(date_helper_class.distance_of_time_as_hash(986760)).to eq(days: 11, hours: 10, mins: 6)
+ end
+end \ No newline at end of file