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

allow rubocop not to fail

Ivan Kuchin6be3ffce0dee
diff --git a/app/models/work_package.rb b/app/models/work_package.rb
index 4de4b0b0024..f4d2c99c043 100644
--- a/app/models/work_package.rb
+++ b/app/models/work_package.rb
@@ -335,7 +335,7 @@ class WorkPackage < ApplicationRecord
end
def duration_in_hours
- duration ? duration * 24 : nil
+ duration * 24 if duration
end
def project_phase
diff --git a/spec/models/work_package_spec.rb b/spec/models/work_package_spec.rb
index f5f0abc2069..4221dd860a8 100644
--- a/spec/models/work_package_spec.rb
+++ b/spec/models/work_package_spec.rb
@@ -708,7 +708,7 @@ RSpec.describe WorkPackage do
describe "#duration" do
context "when not setting a value" do
it "is nil" do
- expect(work_package.duration).to be_nil
+ expect(work_package).to have_attributes(duration: nil)
end
end
@@ -718,7 +718,25 @@ RSpec.describe WorkPackage do
end
it "is the value" do
- expect(work_package.duration).to eq(5)
+ expect(work_package).to have_attributes(duration: 5)
+ end
+ end
+ end
+
+ describe "#duration_in_hours" do
+ context "when not setting duration" do
+ it "is nil" do
+ expect(work_package).to have_attributes(duration_in_hours: nil)
+ end
+ end
+
+ context "when setting duration value" do
+ before do
+ work_package.duration = 5
+ end
+
+ it "is the value" do
+ expect(work_package).to have_attributes(duration_in_hours: 120)
end
end
end