mirror of
https://github.com/opf/openproject.git
synced 2026-06-13 19:20:00 +00:00
user parameters instead of lets for shared acts_as_customizable test parametrization
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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) }
|
||||
|
||||
@@ -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) }
|
||||
|
||||
@@ -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) }
|
||||
|
||||
@@ -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) }
|
||||
|
||||
@@ -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 }
|
||||
|
||||
Reference in New Issue
Block a user