summaryrefslogtreecommitdiff
path: root/spec/helpers
diff options
context:
space:
mode:
authorWinnie Hellmann <winnie@gitlab.com>2018-09-27 13:44:03 +0200
committerAlessio Caiazza <acaiazza@gitlab.com>2018-10-02 17:08:13 +0200
commitea38e832f0f197c5121504d7e193227d3d9c7867 (patch)
tree83450ab82d52b00fa674a9b95e7724e9967e0972 /spec/helpers
parentf976418d128e9f00d6bc6e7eb2862e553e82934c (diff)
downloadgitlab-ce-ea38e832f0f197c5121504d7e193227d3d9c7867.tar.gz
Allow remaining time of scheduled jobs to overflow one day
Diffstat (limited to 'spec/helpers')
-rw-r--r--spec/helpers/time_helper_spec.rb38
1 files changed, 28 insertions, 10 deletions
diff --git a/spec/helpers/time_helper_spec.rb b/spec/helpers/time_helper_spec.rb
index 0b371d69ecf..37455c3e491 100644
--- a/spec/helpers/time_helper_spec.rb
+++ b/spec/helpers/time_helper_spec.rb
@@ -20,17 +20,35 @@ describe TimeHelper do
end
describe "#duration_in_numbers" do
- it "returns minutes and seconds" do
- durations_and_expectations = {
- 100 => "01:40",
- 121 => "02:01",
- 3721 => "01:02:01",
- 0 => "00:00",
- 42 => "00:42"
- }
+ using RSpec::Parameterized::TableSyntax
+
+ context "without passing allow_overflow" do
+ where(:duration, :formatted_string) do
+ 0 | "00:00"
+ 1.second | "00:01"
+ 42.seconds | "00:42"
+ 2.minutes + 1.second | "02:01"
+ 3.hours + 2.minutes + 1.second | "03:02:01"
+ 30.hours | "06:00:00"
+ end
+
+ with_them do
+ it { expect(duration_in_numbers(duration)).to eq formatted_string }
+ end
+ end
+
+ context "with allow_overflow = true" do
+ where(:duration, :formatted_string) do
+ 0 | "00:00"
+ 1.second | "00:01"
+ 42.seconds | "00:42"
+ 2.minutes + 1.second | "02:01"
+ 3.hours + 2.minutes + 1.second | "03:02:01"
+ 30.hours | "30:00:00"
+ end
- durations_and_expectations.each do |duration, expectation|
- expect(duration_in_numbers(duration)).to eq(expectation)
+ with_them do
+ it { expect(duration_in_numbers(duration, true)).to eq formatted_string }
end
end
end