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
amend specs for single select list
Markus Kahlc0e7c7345bcb
diff --git a/spec/forms/custom_fields/inputs/single_select_list_spec.rb b/spec/forms/custom_fields/inputs/single_select_list_spec.rbindex 3057f7f8916..e6775e57286 100644--- a/spec/forms/custom_fields/inputs/single_select_list_spec.rb+++ b/spec/forms/custom_fields/inputs/single_select_list_spec.rb@@ -43,4 +43,37 @@ RSpec.describe CustomFields::Inputs::SingleSelectList, type: :forms doexpect(autocompleter["data-model"]).to be_json_eql(%{{"name": "eins"}})endend++ context "with a default value" do+ before do+ custom_field.possible_values[1].update default_value: true+ end++ it_behaves_like "rendering autocompleter", "List field" do+ let(:value) { custom_field.possible_values.last.id }++ ##+ # We specifically test that it doesn't just render the selected option by accident.+ # So we make the last option the selected value with the default being a value+ # before that.+ # This is to rule out the bug (#66433) we had before where both the list items [1] for the+ # default value and the selected value had `selected: true` with the first one+ # 'winning'.+ #+ # [1] CustomFields::Inputs::SingleSelectList#list_items+ describe "with an option selected" do+ it "pre-selects the selected value" do+ expect(autocompleter["data-model"]).to be_json_eql(%{{"name": "drei"}})+ end+ end++ describe "with no option selected" do+ let(:value) { nil }++ it "pre-selects the default value" do+ expect(autocompleter["data-model"]).to be_json_eql(%{{"name": "zwei"}})+ end+ end+ end+ endend