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
fix tests
Ivan Kuchina1918cc5ecd7
diff --git a/modules/reporting/spec/models/cost_query/filter_spec.rb b/modules/reporting/spec/models/cost_query/filter_spec.rbindex e475ee5a8f9..3bec6974ce1 100644--- a/modules/reporting/spec/models/cost_query/filter_spec.rb+++ b/modules/reporting/spec/models/cost_query/filter_spec.rb@@ -389,13 +389,6 @@ RSpec.describe CostQuery, :reporting_query_helper doclear_cacheend- def update_work_package_custom_field(name, options)- fld = WorkPackageCustomField.find_by(name:)- options.each_pair { |k, v| fld.send(:"#{k}=", v) }- fld.save!- clear_cache- end-include OpenProject::Reporting::SpecHelper::CustomFieldFilterHelperit "creates classes for custom fields that get added after starting the server" do@@ -414,25 +407,9 @@ RSpec.describe CostQuery, :reporting_query_helper docustom_field2.saveclear_cache- ao = filter_class_name_string(custom_field2).constantize.available_operators.map(&:name)- CostQuery::Operator.null_operators.each do |o|- expect(ao).to include o.name- end- end- it "updates the available values on change" do- custom_field2.save-- update_work_package_custom_field("Database", field_format: "string")- ao = filter_class_name_string(custom_field2).constantize.available_operators.map(&:name)- CostQuery::Operator.string_operators.each do |o|- expect(ao).to include o.name- end- update_work_package_custom_field("Database", field_format: "int")- ao = filter_class_name_string(custom_field2).constantize.available_operators.map(&:name)- CostQuery::Operator.integer_operators.each do |o|- expect(ao).to include o.name- end+ expect(filter_class_name_string(custom_field2).constantize.available_operators.map(&:name))+ .to include(*CostQuery::Operator.null_operators.map(&:name))endit "includes custom fields classes in CustomFieldEntries.all" dodiff --git a/spec/lib/custom_field_form_builder_spec.rb b/spec/lib/custom_field_form_builder_spec.rbindex 4eac6fc9a78..913071e0642 100644--- a/spec/lib/custom_field_form_builder_spec.rb+++ b/spec/lib/custom_field_form_builder_spec.rb@@ -45,8 +45,9 @@ RSpec.describe CustomFieldFormBuilder dodescribe "#custom_field" dolet(:options) { { class: "custom-class" } }+ let(:field_format) { "bool" }let(:custom_field) do- build_stubbed(:custom_field)+ build_stubbed(:custom_field, field_format:)endlet(:custom_value) dobuild_stubbed(:custom_value, customized: resource, custom_field:)@@ -95,9 +96,7 @@ RSpec.describe CustomFieldFormBuilder doendcontext "for a date custom field" do- before do- custom_field.field_format = "date"- end+ let(:field_format) { "date" }it_behaves_like "wrapped in container", "field-container" dolet(:container_count) { 2 }@@ -118,9 +117,7 @@ RSpec.describe CustomFieldFormBuilder doendcontext "for a text custom field" do- before do- custom_field.field_format = "text"- end+ let(:field_format) { "text" }it_behaves_like "wrapped in container", "text-area-container" dolet(:container_count) { 2 }@@ -140,9 +137,7 @@ RSpec.describe CustomFieldFormBuilder doendcontext "for a string custom field" do- before do- custom_field.field_format = "string"- end+ let(:field_format) { "string" }it_behaves_like "wrapped in container", "text-field-container" dolet(:container_count) { 2 }@@ -153,15 +148,14 @@ RSpec.describe CustomFieldFormBuilder do<input class="custom-class form--text-field"id="user#{custom_field.id}"name="user[#{custom_field.id}]"- type="text" />+ type="text"+ value="" />}).at_path("input")endendcontext "for an int custom field" do- before do- custom_field.field_format = "int"- end+ let(:field_format) { "int" }it_behaves_like "wrapped in container", "text-field-container" dolet(:container_count) { 2 }@@ -178,9 +172,7 @@ RSpec.describe CustomFieldFormBuilder doendcontext "for a float custom field" do- before do- custom_field.field_format = "float"- end+ let(:field_format) { "float" }it_behaves_like "wrapped in container", "text-field-container" dolet(:container_count) { 2 }@@ -256,6 +248,8 @@ RSpec.describe CustomFieldFormBuilder doendcontext "for a user custom field" do+ let(:field_format) { "user" }+let(:project) { build_stubbed(:project) }let(:user1) { build_stubbed(:user) }let(:user2) { build_stubbed(:user) }@@ -263,8 +257,6 @@ RSpec.describe CustomFieldFormBuilder dolet(:resource) { project }before do- custom_field.field_format = "user"-without_partial_double_verification doallow(project).to receive(custom_field.attribute_getter)@@ -320,6 +312,8 @@ RSpec.describe CustomFieldFormBuilder doendcontext "for a version custom field" do+ let(:field_format) { "version" }+let(:project) { build_stubbed(:project) }let(:version1) { build_stubbed(:version) }let(:version2) { build_stubbed(:version) }@@ -327,8 +321,6 @@ RSpec.describe CustomFieldFormBuilder dolet(:resource) { project }before do- custom_field.field_format = "version"-without_partial_double_verification doallow(project).to receive(custom_field.attribute_getter)diff --git a/spec/models/work_package/work_package_acts_as_customizable_spec.rb b/spec/models/work_package/work_package_acts_as_customizable_spec.rbindex 3cd6b4d5a51..24766c743fc 100644--- a/spec/models/work_package/work_package_acts_as_customizable_spec.rb+++ b/spec/models/work_package/work_package_acts_as_customizable_spec.rb@@ -191,10 +191,7 @@ RSpec.describe WorkPackage, "acts_as_customizable" doendcontext "with a default value" do- before do- custom_field.update! default_value: "foobar"- model_instance.custom_values.destroy_all- end+ let(:custom_field) { create(:string_wp_custom_field, default_value: "foobar") }it "returns no changes" doexpect(model_instance.custom_field_changes).to be_empty@@ -202,10 +199,7 @@ RSpec.describe WorkPackage, "acts_as_customizable" doendcontext "with a bool custom_field having a default value" do- before do- custom_field.update! field_format: "bool", default_value: "0"- model_instance.custom_values.destroy_all- end+ let(:custom_field) { create(:boolean_wp_custom_field, default_value: "0") }it "returns no changes" doexpect(model_instance.custom_field_changes).to be_emptydiff --git a/spec/services/work_packages/copy_service_integration_spec.rb b/spec/services/work_packages/copy_service_integration_spec.rbindex 4e1c1bcd393..84a71d05b93 100644--- a/spec/services/work_packages/copy_service_integration_spec.rb+++ b/spec/services/work_packages/copy_service_integration_spec.rb@@ -159,16 +159,9 @@ RSpec.describe WorkPackages::CopyService, "integration", type: :model doendcontext "required custom field in the target project" do+ let(:custom_field) { create(:work_package_custom_field, field_format: "text", is_required: true, is_for_all: false) }let(:target_custom_fields) { [custom_field] }- before do- custom_field.update(- field_format: "text",- is_required: true,- is_for_all: false- )- end-it "does not copy the work package" doexpect(service_result).to be_failureend