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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
refactor: make tests more expressive and explicit
Christophe Bliardf1ea26c38113
diff --git a/spec/models/relation_spec.rb b/spec/models/relation_spec.rbindex 4b28413bb24..e68e4bb3c09 100644--- a/spec/models/relation_spec.rb+++ b/spec/models/relation_spec.rb@@ -38,24 +38,10 @@ RSpec.describe Relation dolet(:relation) { build(:relation, from:, to:, relation_type: type) }it "validates lag numericality" do- relation.lag = nil- expect(relation).to be_valid- relation.lag = -1- expect(relation).to be_valid- relation.lag = 2_000- expect(relation).to be_valid- relation.lag = -2_000- expect(relation).to be_valid-- relation.lag = 2_001- expect(relation).not_to be_valid- expect(relation.errors[:lag])- .to eq(["must be less than or equal to #{Relation::MAX_LAG}."])-- relation.lag = -2_001- expect(relation).not_to be_valid- expect(relation.errors[:lag])- .to eq(["must be greater than or equal to #{Relation::MIN_LAG}."])+ expect(relation).to validate_numericality_of(:lag)+ .is_greater_than_or_equal_to(Relation::MIN_LAG)+ .is_less_than_or_equal_to(Relation::MAX_LAG)+ .allow_nilendit "validates relation uniqueness on both from_id and to_id" dodiff --git a/spec/services/work_packages/shared/all_days_spec.rb b/spec/services/work_packages/shared/all_days_spec.rbindex 2b47a526d78..229ac27ee11 100644--- a/spec/services/work_packages/shared/all_days_spec.rb+++ b/spec/services/work_packages/shared/all_days_spec.rb@@ -44,7 +44,7 @@ RSpec.describe WorkPackages::Shared::AllDays doendend- context "with weekend days (Saturday and Sunday)", :weekend_saturday_sunday do+ context "with Saturday and Sunday being non-working days", :weekend_saturday_sunday doit "considers all days as working days and returns the number of days between two dates, inclusive" doexpect(subject.duration(sunday_2022_07_31, sunday_2022_07_31 + 6)).to eq(7)expect(subject.duration(sunday_2022_07_31, sunday_2022_07_31 + 50)).to eq(51)@@ -94,7 +94,7 @@ RSpec.describe WorkPackages::Shared::AllDays doexpect(subject.start_date(sunday_2022_07_31, nil)).to be_nilend- context "with weekend days (Saturday and Sunday)", :weekend_saturday_sunday do+ context "with Saturday and Sunday being non-working days", :weekend_saturday_sunday doinclude_examples "start_date", due_date: sunday_2022_07_31, duration: 1, expected: sunday_2022_07_31include_examples "start_date", due_date: sunday_2022_07_31, duration: 5, expected: sunday_2022_07_31 - 4.daysinclude_examples "start_date", due_date: sunday_2022_07_31, duration: 10, expected: sunday_2022_07_31 - 9.days@@ -127,7 +127,7 @@ RSpec.describe WorkPackages::Shared::AllDays doexpect(subject.due_date(sunday_2022_07_31, nil)).to be_nilend- context "with weekend days (Saturday and Sunday)", :weekend_saturday_sunday do+ context "with Saturday and Sunday being non-working days", :weekend_saturday_sunday doinclude_examples "due_date", start_date: sunday_2022_07_31, duration: 1, expected: sunday_2022_07_31include_examples "due_date", start_date: sunday_2022_07_31, duration: 5, expected: sunday_2022_07_31 + 4.daysinclude_examples "due_date", start_date: sunday_2022_07_31, duration: 10, expected: sunday_2022_07_31 + 9.days@@ -148,7 +148,7 @@ RSpec.describe WorkPackages::Shared::AllDays doexpect(subject.soonest_working_day(nil)).to be_nilend- context "with weekend days (Saturday and Sunday)", :weekend_saturday_sunday do+ context "with Saturday and Sunday being non-working days", :weekend_saturday_sunday doit "returns the given day" doexpect(subject.soonest_working_day(sunday_2022_07_31)).to eq(sunday_2022_07_31)enddiff --git a/spec/services/work_packages/shared/shared_examples_days.rb b/spec/services/work_packages/shared/shared_examples_days.rbindex 49549ca521c..084fd6159c3 100644--- a/spec/services/work_packages/shared/shared_examples_days.rb+++ b/spec/services/work_packages/shared/shared_examples_days.rb@@ -136,7 +136,7 @@ RSpec.shared_examples "lag computation excluding non-working days" doendend- context "with weekend days (Saturday and Sunday)", :weekend_saturday_sunday do+ context "with Saturday and Sunday being non-working days", :weekend_saturday_sunday doinclude_examples "it returns lag", 0, sunday_2022_07_31, monday_2022_08_01include_examples "it returns lag", 4, sunday_2022_07_31, Date.new(2022, 8, 5) # Fridayinclude_examples "it returns lag", 5, sunday_2022_07_31, Date.new(2022, 8, 6) # Saturday@@ -209,7 +209,7 @@ RSpec.shared_examples "add lag to a date" do.not_to raise_errorend- context "with weekend days (Saturday and Sunday)", :weekend_saturday_sunday do+ context "with Saturday and Sunday being non-working days", :weekend_saturday_sunday doinclude_examples "it adds lag", date: saturday_2022_07_30, lag: 0, expected_result: sunday_2022_07_31include_examples "it adds lag", date: saturday_2022_07_30, lag: 1, expected_result: Date.new(2022, 8, 2)include_examples "it adds lag", date: saturday_2022_07_30, lag: -1, expected_result: Date.new(2022, 7, 29) # previous Fridaydiff --git a/spec/services/work_packages/shared/working_days_spec.rb b/spec/services/work_packages/shared/working_days_spec.rbindex 4224854dd24..cb1edbe490f 100644--- a/spec/services/work_packages/shared/working_days_spec.rb+++ b/spec/services/work_packages/shared/working_days_spec.rb@@ -52,7 +52,7 @@ RSpec.describe WorkPackages::Shared::WorkingDays doendend- context "with weekend days (Saturday and Sunday)", :weekend_saturday_sunday do+ context "with Saturday and Sunday being non-working days", :weekend_saturday_sunday doinclude_examples "it returns duration", 0, sunday_2022_07_31, sunday_2022_07_31include_examples "it returns duration", 5, sunday_2022_07_31, Date.new(2022, 8, 5)include_examples "it returns duration", 5, sunday_2022_07_31, Date.new(2022, 8, 6)@@ -124,7 +124,7 @@ RSpec.describe WorkPackages::Shared::WorkingDays doendend- context "with weekend days (Saturday and Sunday)", :weekend_saturday_sunday do+ context "with Saturday and Sunday being non-working days", :weekend_saturday_sunday doinclude_examples "start_date", due_date: monday_2022_08_01, duration: 1, expected: monday_2022_08_01include_examples "start_date", due_date: monday_2022_08_01, duration: 5, expected: monday_2022_08_01 - 6.daysinclude_examples "start_date", due_date: wednesday_2022_08_03, duration: 10, expected: wednesday_2022_08_03 - 13.days@@ -168,7 +168,7 @@ RSpec.describe WorkPackages::Shared::WorkingDays doendend- context "with weekend days (Saturday and Sunday)", :weekend_saturday_sunday do+ context "with Saturday and Sunday being non-working days", :weekend_saturday_sunday doinclude_examples "due_date", start_date: monday_2022_08_01, duration: 1, expected: monday_2022_08_01include_examples "due_date", start_date: monday_2022_08_01, duration: 5, expected: monday_2022_08_01 + 4.daysinclude_examples "due_date", start_date: wednesday_2022_08_03, duration: 10, expected: wednesday_2022_08_03 + 13.days@@ -194,7 +194,7 @@ RSpec.describe WorkPackages::Shared::WorkingDays doexpect(subject.soonest_working_day(nil)).to be_nilend- context "with weekend days (Saturday and Sunday)", :weekend_saturday_sunday do+ context "with Saturday and Sunday being non-working days", :weekend_saturday_sunday doinclude_examples "soonest working day", date: friday_2022_07_29, expected: friday_2022_07_29include_examples "soonest working day", date: saturday_2022_07_30, expected: monday_2022_08_01include_examples "soonest working day", date: sunday_2022_07_31, expected: monday_2022_08_01