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

rewrite legacy status specs

ulferts1d7f013f89ae
diff --git a/spec/models/status_spec.rb b/spec/models/status_spec.rb
index 28fb79c0576..b06fce005db 100644
--- a/spec/models/status_spec.rb
+++ b/spec/models/status_spec.rb
@@ -129,4 +129,28 @@ describe Status, type: :model do
.not_to eql old_cache_key
end
end
+
+ context '.update_done_ratios' do
+ let(:status) { FactoryBot.create(:status, default_done_ratio: 50) }
+ let(:work_package) { FactoryBot.create(:work_package, status: status) }
+
+ context 'with Setting.work_package_done_ratio using the field', with_settings: { work_package_done_ratio: 'field' } do
+ it 'changes nothing' do
+ done_ratio_before = work_package.done_ratio
+ Status.update_work_package_done_ratios
+
+ expect(work_package.reload.done_ratio)
+ .to eql done_ratio_before
+ end
+ end
+
+ context 'with Setting.work_package_done_ratio using the status', with_settings: { work_package_done_ratio: 'status' } do
+ it "should update all of the issue's done_ratios to match their Issue Status" do
+ Status.update_work_package_done_ratios
+
+ expect(work_package.reload.done_ratio)
+ .to eql status.default_done_ratio
+ end
+ end
+ end
end
diff --git a/spec_legacy/unit/status_spec.rb b/spec_legacy/unit/status_spec.rb
index de78ec6c254..86f0648d724 100644
--- a/spec_legacy/unit/status_spec.rb
+++ b/spec_legacy/unit/status_spec.rb
@@ -59,11 +59,6 @@ describe Status, type: :model do
assert_raises(RuntimeError, "Can't delete status") { status.destroy }
end
- it 'should default' do
- status = Status.default
- assert_kind_of Status, status
- end
-
it 'should change default' do
status = Status.find(2)
assert !status.is_default
@@ -81,40 +76,4 @@ describe Status, type: :model do
status.reload
assert status.is_default?
end
-
- context '#update_done_ratios' do
- before do
- @issue = WorkPackage.find(1)
- @status = Status.find(1)
- @status.update_attribute(:default_done_ratio, 50)
- end
-
- context 'with Setting.work_package_done_ratio using the field' do
- before do
- Setting.work_package_done_ratio = 'field'
- end
-
- it 'should change nothing' do
- Status.update_work_package_done_ratios
-
- assert_equal 0, WorkPackage.where(done_ratio: 50).count
- end
- end
-
- context 'with Setting.work_package_done_ratio using the status' do
- before do
- Setting.work_package_done_ratio = 'status'
- end
-
- it "should update all of the issue's done_ratios to match their Issue Status" do
- Status.update_work_package_done_ratios
-
- issues = WorkPackage.find([1, 3, 4, 5, 6, 7, 9, 10])
- issues.each do |issue|
- assert_equal @status, issue.status
- assert_equal 50, issue.read_attribute(:done_ratio)
- end
- end
- end
- end
end