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
rework test for Queries::Projects::Orders::CustomFieldOrder#available?
Ivan Kuchin8605c3d8ff18
diff --git a/spec/models/queries/projects/orders/custom_field_order_spec.rb b/spec/models/queries/projects/orders/custom_field_order_spec.rbindex 48550002ffd..c9085d2243c 100644--- a/spec/models/queries/projects/orders/custom_field_order_spec.rb+++ b/spec/models/queries/projects/orders/custom_field_order_spec.rb@@ -29,20 +29,27 @@require "spec_helper"RSpec.describe Queries::Projects::Orders::CustomFieldOrder do- let!(:cf_text) { FactoryBot.create(:text_project_custom_field) }- let!(:cf_int) { FactoryBot.create(:integer_project_custom_field) }+ describe "#available?" do+ let(:instance) { described_class.new("cf_#{custom_field.id}") }- before do- allow(User).to receive(:current).and_return build_stubbed(:admin)- end+ before do+ allow(User).to receive(:current).and_return build_stubbed(:admin)+ end- it "does not allow to sort by the text field" do- cf = described_class.new("cf_#{cf_text.id}")- expect(cf).not_to be_available- end+ context "for int custom field" do+ let!(:custom_field) { create(:project_custom_field, :integer) }++ it "allows to sort by it" do+ expect(instance).to be_available+ end+ end++ context "for text custom field" do+ let!(:custom_field) { create(:project_custom_field, :text) }- it "allows to sort by all other fields" do- cf = described_class.new("cf_#{cf_int.id}")- expect(cf).to be_available+ it "does not allow to sort by it" do+ expect(instance).not_to be_available+ end+ endendend