Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

calm rubocop

Ivan Kuchin0ff8caa75a1d
diff --git a/app/models/custom_value/date_strategy.rb b/app/models/custom_value/date_strategy.rb
index 9b301376c96..523aab51d84 100644
--- a/app/models/custom_value/date_strategy.rb
+++ b/app/models/custom_value/date_strategy.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) the OpenProject GmbH
diff --git a/spec/models/custom_value/date_strategy_spec.rb b/spec/models/custom_value/date_strategy_spec.rb
index 8aaed69a426..b6f5fdc9c9a 100644
--- a/spec/models/custom_value/date_strategy_spec.rb
+++ b/spec/models/custom_value/date_strategy_spec.rb
@@ -33,32 +33,31 @@ require "spec_helper"
RSpec.describe CustomValue::DateStrategy do
let(:instance) { described_class.new(custom_value) }
let(:custom_value) do
- double("CustomValue",
- value:)
+ instance_double(CustomValue, value:)
end
describe "#typed_value" do
subject { instance.typed_value }
- context "value is some date string" do
+ context "when value is a date string" do
let(:value) { "2015-01-03" }
it { is_expected.to eql(Date.iso8601(value)) }
end
- context "value is not a date" do
+ context "when value is not a date" do
let(:value) { "hello, world!" }
it { is_expected.to be_nil }
end
- context "value is blank" do
+ context "when value is blank" do
let(:value) { "" }
it { is_expected.to be_nil }
end
- context "value is nil" do
+ context "when value is nil" do
let(:value) { nil }
it { is_expected.to be_nil }
@@ -68,17 +67,15 @@ RSpec.describe CustomValue::DateStrategy do
describe "#formatted_value" do
subject { instance.formatted_value }
- context "value is some date string" do
+ context "when value is some date string", with_settings: { date_format: "%Y-%m-%d" } do
let(:value) { "2015-01-03" }
- context "date format", with_settings: { date_format: "%Y-%m-%d" } do
- it "is the date" do
- expect(subject).to eql value
- end
+ it "is the date" do
+ expect(subject).to eql value
end
end
- context "value is blank" do
+ context "when value is blank" do
let(:value) { "" }
it "is a blank string" do
@@ -86,7 +83,7 @@ RSpec.describe CustomValue::DateStrategy do
end
end
- context "value is nil" do
+ context "when value is nil" do
let(:value) { nil }
it "is a blank string" do
@@ -98,7 +95,7 @@ RSpec.describe CustomValue::DateStrategy do
describe "#validate_type_of_value" do
subject { instance.validate_type_of_value }
- context "value is valid date string" do
+ context "when value is valid date string" do
let(:value) { "2015-01-03" }
it "accepts" do
@@ -106,7 +103,7 @@ RSpec.describe CustomValue::DateStrategy do
end
end
- context "value is invalid date string in good format" do
+ context "when value is invalid date string in good format" do
let(:value) { "2015-02-30" }
it "rejects" do
@@ -114,7 +111,7 @@ RSpec.describe CustomValue::DateStrategy do
end
end
- context "value is date string in bad format" do
+ context "when value is date string in bad format" do
let(:value) { "03.01.2015" }
it "rejects" do
@@ -122,7 +119,7 @@ RSpec.describe CustomValue::DateStrategy do
end
end
- context "value is not a date string at all" do
+ context "when value is not a date string at all" do
let(:value) { "chicken" }
it "rejects" do
@@ -130,7 +127,7 @@ RSpec.describe CustomValue::DateStrategy do
end
end
- context "value is valid date" do
+ context "when value is valid date" do
let(:value) { Date.iso8601("2015-01-03") }
it "accepts" do