user parameters instead of lets for shared acts_as_customizable test parametrization

This commit is contained in:
Ivan Kuchin
2026-03-06 14:51:58 +01:00
parent 683f4b3c25
commit 1b73390da1
7 changed files with 9 additions and 21 deletions
+1 -3
View File
@@ -648,9 +648,7 @@ RSpec.describe TimeEntry do
end
end
it_behaves_like "acts_as_customizable included" do
let(:admin_only_custom_fields_allowed) { false }
let(:can_have_custom_comments) { false }
it_behaves_like "acts_as_customizable included", admin_only_allowed: false, comments: false do
let!(:model_instance) { time_entry }
let!(:new_model_instance) do
build(:time_entry,
+1 -3
View File
@@ -207,9 +207,7 @@ RSpec.describe Group do
subject { create(:attachment) }
end
it_behaves_like "acts_as_customizable included" do
let(:admin_only_custom_fields_allowed) { false }
let(:can_have_custom_comments) { false }
it_behaves_like "acts_as_customizable included", admin_only_allowed: false, comments: false do
let!(:model_instance) { group }
let!(:new_model_instance) { new_group }
let!(:custom_field) { create(:group_custom_field, :string, is_required: false) }
+1 -3
View File
@@ -492,9 +492,7 @@ RSpec.describe Project do
let(:instance) { project }
end
it_behaves_like "acts_as_customizable included" do
let(:admin_only_custom_fields_allowed) { true }
let(:can_have_custom_comments) { true }
it_behaves_like "acts_as_customizable included", admin_only_allowed: true, comments: true do
let!(:model_instance) { project }
let!(:new_model_instance) { build_project }
let!(:custom_field) { create(:string_project_custom_field) }
+1 -3
View File
@@ -1079,9 +1079,7 @@ RSpec.describe User do
subject { create(:attachment) }
end
it_behaves_like "acts_as_customizable included" do
let(:admin_only_custom_fields_allowed) { true }
let(:can_have_custom_comments) { false }
it_behaves_like "acts_as_customizable included", admin_only_allowed: true, comments: false do
let!(:model_instance) { create(:user) }
let!(:new_model_instance) { user }
let!(:custom_field) { create(:user_custom_field, :string) }
+1 -3
View File
@@ -489,9 +489,7 @@ RSpec.describe Version do
end
end
it_behaves_like "acts_as_customizable included" do
let(:admin_only_custom_fields_allowed) { false }
let(:can_have_custom_comments) { false }
it_behaves_like "acts_as_customizable included", admin_only_allowed: false, comments: false do
let!(:model_instance) { create(:version) }
let!(:new_model_instance) { version }
let!(:custom_field) { create(:version_custom_field) }
@@ -185,9 +185,7 @@ RSpec.describe WorkPackage, "acts_as_customizable" do
end
end
it_behaves_like "acts_as_customizable included" do
let(:admin_only_custom_fields_allowed) { false }
let(:can_have_custom_comments) { false }
it_behaves_like "acts_as_customizable included", admin_only_allowed: false, comments: false do
let(:model_instance) { work_package }
let(:new_model_instance) { new_work_package }
let(:custom_field) { create(:string_wp_custom_field) }
+3 -3
View File
@@ -28,9 +28,9 @@
# See COPYRIGHT and LICENSE files for more details.
#++
RSpec.shared_examples_for "acts_as_customizable included" do
RSpec.shared_examples_for "acts_as_customizable included" do |admin_only_allowed:, comments:|
describe "admin_only_custom_fields_allowed? instance and class methods" do
let(:expectation) { admin_only_custom_fields_allowed ? be_truthy : be_falsey }
let(:expectation) { admin_only_allowed ? be_truthy : be_falsey }
describe ".admin_only_custom_fields_allowed?" do
it { expect(described_class.admin_only_custom_fields_allowed?).to expectation }
@@ -42,7 +42,7 @@ RSpec.shared_examples_for "acts_as_customizable included" do
end
describe "can_have_custom_comments? instance and class methods" do
let(:expectation) { can_have_custom_comments ? be_truthy : be_falsey }
let(:expectation) { comments ? be_truthy : be_falsey }
describe ".can_have_custom_comments?" do
it { expect(described_class.can_have_custom_comments?).to expectation }