Skip to content

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

Update specs

Dombi Attila82d492a2d70f
diff --git a/app/contracts/custom_fields/base_contract.rb b/app/contracts/custom_fields/base_contract.rb
index 42d7ff8ff48..6648bfc213b 100644
--- a/app/contracts/custom_fields/base_contract.rb
+++ b/app/contracts/custom_fields/base_contract.rb
@@ -42,7 +42,7 @@ module CustomFields
attribute :possible_values
attribute :regexp
attribute :searchable
- attribute :visible
+ attribute :admin_only
attribute :default_value
attribute :possible_values
attribute :multi_value
diff --git a/spec/components/users/profile/attributes_component_spec.rb b/spec/components/users/profile/attributes_component_spec.rb
index d58d6ca87f3..54e81d95e59 100644
--- a/spec/components/users/profile/attributes_component_spec.rb
+++ b/spec/components/users/profile/attributes_component_spec.rb
@@ -63,7 +63,7 @@ RSpec.describe Users::Profile::AttributesComponent, type: :component do
end
context "when user has a non-visible custom field with a present value" do
- let(:custom_field) { create(:user_custom_field, :string, visible: false) }
+ let(:custom_field) { create(:user_custom_field, :string, admin_only: true) }
let(:user) { build(:user, custom_values: [build(:custom_value, custom_field:, value: "Hello")]) }
it { is_expected.to be(false) }
@@ -71,11 +71,11 @@ RSpec.describe Users::Profile::AttributesComponent, type: :component do
end
describe "Custom field" do
- let(:custom_field) { create(:user_custom_field, :string, visible:) }
+ let(:custom_field) { create(:user_custom_field, :string, admin_only:) }
let(:custom_values) do
[build(:custom_value, custom_field:, value: "Hello custom field")]
end
- let(:visible) { true }
+ let(:admin_only) { false }
let(:user) { build_stubbed(:user, custom_values:) }
current_user { build(:admin) }
@@ -89,7 +89,7 @@ RSpec.describe Users::Profile::AttributesComponent, type: :component do
end
context "when not visible" do
- let(:visible) { false }
+ let(:admin_only) { true }
it "does not render the field" do
expect(page).to have_no_text("Hello custom field")
@@ -97,8 +97,8 @@ RSpec.describe Users::Profile::AttributesComponent, type: :component do
end
context "with multiple custom fields" do
- let(:list_custom_field) { create(:user_custom_field, :multi_list, visible:, name: "Ze list") }
- let(:text_custom_field) { create(:user_custom_field, :text, visible:, name: "A portrait") }
+ let(:list_custom_field) { create(:user_custom_field, :multi_list, admin_only:, name: "Ze list") }
+ let(:text_custom_field) { create(:user_custom_field, :text, admin_only:, name: "A portrait") }
let(:custom_values) do
[
build(:custom_value, custom_field: list_custom_field, value: list_custom_field.possible_values[0]),
diff --git a/spec/contracts/project_custom_field_project_mappings/base_contract_spec.rb b/spec/contracts/project_custom_field_project_mappings/base_contract_spec.rb
index 67dd21a7b1b..d50157db756 100644
--- a/spec/contracts/project_custom_field_project_mappings/base_contract_spec.rb
+++ b/spec/contracts/project_custom_field_project_mappings/base_contract_spec.rb
@@ -49,7 +49,7 @@ RSpec.describe ProjectCustomFieldProjectMappings::BaseContract do
end
context "with non-visible custom field and admin user" do
- let(:project_custom_field) { build_stubbed(:project_custom_field, visible: false) }
+ let(:project_custom_field) { build_stubbed(:project_custom_field, admin_only: true) }
before do
allow(ProjectCustomField).to receive(:all).and_return([project_custom_field])
@@ -60,7 +60,7 @@ RSpec.describe ProjectCustomFieldProjectMappings::BaseContract do
context "with non-visible custom field and non-admin user" do
let(:user) { build_stubbed(:user) }
- let(:project_custom_field) { build_stubbed(:project_custom_field, visible: false) }
+ let(:project_custom_field) { build_stubbed(:project_custom_field, admin_only: true) }
before do
allow(ProjectCustomField).to receive(:visible).and_return([project_custom_field])
diff --git a/spec/contracts/projects/shared_contract_examples.rb b/spec/contracts/projects/shared_contract_examples.rb
index 8884872a583..a765a3727c1 100644
--- a/spec/contracts/projects/shared_contract_examples.rb
+++ b/spec/contracts/projects/shared_contract_examples.rb
@@ -269,8 +269,8 @@ RSpec.shared_examples_for "project contract" do
end
describe "available_custom_fields" do
- let(:visible_custom_field) { build_stubbed(:integer_project_custom_field, visible: true) }
- let(:invisible_custom_field) { build_stubbed(:integer_project_custom_field, visible: false) }
+ let(:visible_custom_field) { build_stubbed(:integer_project_custom_field, admin_only: false) }
+ let(:invisible_custom_field) { build_stubbed(:integer_project_custom_field, admin_only: true) }
before do
allow(project)
diff --git a/spec/features/projects/copy_spec.rb b/spec/features/projects/copy_spec.rb
index 161f10519d2..18253e9452a 100644
--- a/spec/features/projects/copy_spec.rb
+++ b/spec/features/projects/copy_spec.rb
@@ -293,7 +293,7 @@ RSpec.describe "Projects copy", :js, :with_cuprite,
context "with correct handling of invisible values" do
let!(:invisible_field) do
create(:string_project_custom_field, name: "Text for Admins only",
- visible: false,
+ admin_only: true,
project_custom_field_section:,
projects: [project])
end
diff --git a/spec/features/projects/create_spec.rb b/spec/features/projects/create_spec.rb
index 8f95c1a2c7f..c58f3f88f84 100644
--- a/spec/features/projects/create_spec.rb
+++ b/spec/features/projects/create_spec.rb
@@ -339,7 +339,7 @@ RSpec.describe "Projects", "creation",
context "with correct handling of invisible values" do
let!(:invisible_field) do
create(:string_project_custom_field, name: "Text for Admins only",
- visible: false,
+ admin_only: true,
project_custom_field_section:)
end
diff --git a/spec/features/projects/persisted_lists_spec.rb b/spec/features/projects/persisted_lists_spec.rb
index 310e967f41a..c7fad929373 100644
--- a/spec/features/projects/persisted_lists_spec.rb
+++ b/spec/features/projects/persisted_lists_spec.rb
@@ -38,7 +38,7 @@ RSpec.describe "Persisted lists on projects index page",
shared_let(:developer) { create(:project_role, name: "Developer") }
shared_let(:custom_field) { create(:text_project_custom_field) }
- shared_let(:invisible_custom_field) { create(:project_custom_field, visible: false) }
+ shared_let(:invisible_custom_field) { create(:project_custom_field, admin_only: true) }
shared_let(:project) do
create(:project,
diff --git a/spec/features/projects/project_custom_fields/overview_page/dialog/render_spec.rb b/spec/features/projects/project_custom_fields/overview_page/dialog/render_spec.rb
index d1f503a8479..15ca249574e 100644
--- a/spec/features/projects/project_custom_fields/overview_page/dialog/render_spec.rb
+++ b/spec/features/projects/project_custom_fields/overview_page/dialog/render_spec.rb
@@ -148,7 +148,7 @@ RSpec.describe "Edit project custom fields on project overview page", :js do
let!(:visible_project_custom_field) do
create(:project_custom_field,
name: "Normal field",
- visible: true,
+ admin_only: false,
projects: [project],
project_custom_field_section: section_with_invisible_fields)
end
@@ -156,7 +156,7 @@ RSpec.describe "Edit project custom fields on project overview page", :js do
let!(:invisible_project_custom_field) do
create(:project_custom_field,
name: "Admin only field",
- visible: false,
+ admin_only: true,
projects: [project],
project_custom_field_section: section_with_invisible_fields)
end
diff --git a/spec/features/projects/project_custom_fields/overview_page/dialog/update_spec.rb b/spec/features/projects/project_custom_fields/overview_page/dialog/update_spec.rb
index 4c8779341bc..9c82c049bdb 100644
--- a/spec/features/projects/project_custom_fields/overview_page/dialog/update_spec.rb
+++ b/spec/features/projects/project_custom_fields/overview_page/dialog/update_spec.rb
@@ -659,7 +659,7 @@ RSpec.describe "Edit project custom fields on project overview page", :js do
let(:field) { FormFields::Primerized::InputField.new(custom_field) }
before do
- all_fields.without(string_project_custom_field).each { |cf| cf.update(visible: false) }
+ all_fields.without(string_project_custom_field).each { |cf| cf.update(admin_only: true) }
end
it "does not clears them after a project admin updates" do
diff --git a/spec/features/projects/project_custom_fields/settings/mapping_spec.rb b/spec/features/projects/project_custom_fields/settings/mapping_spec.rb
index edd7b66e49a..f94c13871ee 100644
--- a/spec/features/projects/project_custom_fields/settings/mapping_spec.rb
+++ b/spec/features/projects/project_custom_fields/settings/mapping_spec.rb
@@ -332,7 +332,7 @@ RSpec.describe "Projects custom fields mapping via project settings", :js, :with
let!(:visible_project_custom_field) do
create(:project_custom_field,
name: "Normal field",
- visible: true,
+ admin_only: false,
projects: [project],
project_custom_field_section: section_with_invisible_fields)
end
@@ -340,7 +340,7 @@ RSpec.describe "Projects custom fields mapping via project settings", :js, :with
let!(:invisible_project_custom_field) do
create(:project_custom_field,
name: "Admin only field",
- visible: false,
+ admin_only: true,
projects: [project],
project_custom_field_section: section_with_invisible_fields)
end
diff --git a/spec/features/projects/projects_index_spec.rb b/spec/features/projects/projects_index_spec.rb
index dbc95b6f7a6..181468bf93f 100644
--- a/spec/features/projects/projects_index_spec.rb
+++ b/spec/features/projects/projects_index_spec.rb
@@ -35,7 +35,7 @@ RSpec.describe "Projects index page", :js, :with_cuprite, with_settings: { login
shared_let(:developer) { create(:project_role, name: "Developer") }
shared_let(:custom_field) { create(:text_project_custom_field) }
- shared_let(:invisible_custom_field) { create(:project_custom_field, visible: false) }
+ shared_let(:invisible_custom_field) { create(:project_custom_field, admin_only: true) }
shared_let(:project) { create(:project, name: "Plain project", identifier: "plain-project") }
shared_let(:public_project) do
diff --git a/spec/lib/api/v3/projects/project_representer_rendering_spec.rb b/spec/lib/api/v3/projects/project_representer_rendering_spec.rb
index f8f1bebc6b0..9220dd8f698 100644
--- a/spec/lib/api/v3/projects/project_representer_rendering_spec.rb
+++ b/spec/lib/api/v3/projects/project_representer_rendering_spec.rb
@@ -53,8 +53,8 @@ RSpec.describe API::V3::Projects::ProjectRepresenter, "rendering" do
end
end
- let(:int_custom_field) { build_stubbed(:integer_project_custom_field, visible: false) }
- let(:version_custom_field) { build_stubbed(:version_project_custom_field, visible: true) }
+ let(:int_custom_field) { build_stubbed(:integer_project_custom_field, admin_only: true) }
+ let(:version_custom_field) { build_stubbed(:version_project_custom_field, admin_only: false) }
let(:int_custom_value) do
CustomValue.new(custom_field: int_custom_field,
value: "1234",
@@ -164,7 +164,7 @@ RSpec.describe API::V3::Projects::ProjectRepresenter, "rendering" do
context "if the user is no admin and the field is visible" do
before do
- int_custom_field.visible = true
+ int_custom_field.admin_only = false
end
it "has a property for the int custom field" do
@@ -177,7 +177,7 @@ RSpec.describe API::V3::Projects::ProjectRepresenter, "rendering" do
let(:permissions) { [] }
before do
- int_custom_field.visible = true
+ int_custom_field.admin_only = false
end
it "has no property for the int custom field" do
@@ -512,7 +512,7 @@ RSpec.describe API::V3::Projects::ProjectRepresenter, "rendering" do
.to receive(:admin?)
.and_return(true)
- version_custom_field.visible = false
+ version_custom_field.admin_only = true
end
it "links custom fields" do
@@ -523,7 +523,7 @@ RSpec.describe API::V3::Projects::ProjectRepresenter, "rendering" do
context "if the user is no admin and the field is invisible" do
before do
- version_custom_field.visible = false
+ version_custom_field.admin_only = true
end
it "does not link the custom field" do
diff --git a/spec/models/project_custom_field_spec.rb b/spec/models/project_custom_field_spec.rb
index 7e9858f9bb6..966fb094054 100644
--- a/spec/models/project_custom_field_spec.rb
+++ b/spec/models/project_custom_field_spec.rb
@@ -103,7 +103,7 @@ RSpec.describe ProjectCustomField do
end
describe ".visible" do
- shared_let(:invisible_cf) { create(:string_project_custom_field, visible: false) }
+ shared_let(:invisible_cf) { create(:string_project_custom_field, admin_only: true) }
shared_let(:other_cf) { create(:string_project_custom_field) }
shared_let(:project_cf) { create(:string_project_custom_field) }
shared_let(:public_cf) { create(:string_project_custom_field) }
diff --git a/spec/models/projects/exporter/exportable_project_context.rb b/spec/models/projects/exporter/exportable_project_context.rb
index 94e7835096c..339491e5784 100644
--- a/spec/models/projects/exporter/exportable_project_context.rb
+++ b/spec/models/projects/exporter/exportable_project_context.rb
@@ -35,7 +35,7 @@ RSpec.shared_context "with a project with an arrangement of custom fields" do
shared_let(:text_cf) { create(:text_project_custom_field, position: 6) }
shared_let(:string_cf) { create(:string_project_custom_field, position: 7) }
shared_let(:date_cf) { create(:date_project_custom_field, position: 8) }
- shared_let(:hidden_cf) { create(:string_project_custom_field, position: 9, visible: false) }
+ shared_let(:hidden_cf) { create(:string_project_custom_field, position: 9, admin_only: true) }
let!(:not_used_string_cf) { create(:string_project_custom_field, position: 10) }
diff --git a/spec/models/work_packages/pdf_export/work_package_to_pdf_spec.rb b/spec/models/work_packages/pdf_export/work_package_to_pdf_spec.rb
index 528c5cd77a8..d73b936f128 100644
--- a/spec/models/work_packages/pdf_export/work_package_to_pdf_spec.rb
+++ b/spec/models/work_packages/pdf_export/work_package_to_pdf_spec.rb
@@ -46,7 +46,7 @@ RSpec.describe WorkPackage::PDFExport::WorkPackageToPdf do
let(:project_custom_field_string) do
create(:project_custom_field, :string,
name: "Secret string", default_value: "admin eyes only",
- visible: false)
+ admin_only: true)
end
let(:project_custom_field_long_text) do
create(:project_custom_field, :text,
diff --git a/spec/requests/api/v3/projects/create_resource_spec.rb b/spec/requests/api/v3/projects/create_resource_spec.rb
index f48f88354f0..fdfb2873965 100644
--- a/spec/requests/api/v3/projects/create_resource_spec.rb
+++ b/spec/requests/api/v3/projects/create_resource_spec.rb
@@ -37,7 +37,7 @@ RSpec.describe "API v3 Project resource create", content_type: :json do
create(:text_project_custom_field)
end
let(:invisible_custom_field) do
- create(:text_project_custom_field, visible: false)
+ create(:text_project_custom_field, admin_only: true)
end
let(:custom_value) do
CustomValue.create(custom_field:,
diff --git a/spec/requests/api/v3/projects/show_resource_spec.rb b/spec/requests/api/v3/projects/show_resource_spec.rb
index 7cbb790b561..6bf1204d012 100644
--- a/spec/requests/api/v3/projects/show_resource_spec.rb
+++ b/spec/requests/api/v3/projects/show_resource_spec.rb
@@ -55,7 +55,7 @@ RSpec.describe "API v3 Project resource show", content_type: :json do
customized: project)
end
let(:invisible_custom_field) do
- create(:text_project_custom_field, visible: false)
+ create(:text_project_custom_field, admin_only: true)
end
let(:invisible_custom_value) do
CustomValue.create(custom_field: invisible_custom_field,
diff --git a/spec/requests/api/v3/projects/update_resource_spec.rb b/spec/requests/api/v3/projects/update_resource_spec.rb
index c24c769d1e8..756c01a5463 100644
--- a/spec/requests/api/v3/projects/update_resource_spec.rb
+++ b/spec/requests/api/v3/projects/update_resource_spec.rb
@@ -45,7 +45,7 @@ RSpec.describe "API v3 Project resource update", content_type: :json do
create(:text_project_custom_field)
end
let(:invisible_custom_field) do
- create(:text_project_custom_field, visible: false)
+ create(:text_project_custom_field, admin_only: true)
end
let(:permissions) { %i[edit_project view_project_attributes edit_project_attributes] }
let(:path) { api_v3_paths.project(project.id) }
diff --git a/spec/services/project_custom_field_project_mappings/bulk_update_service_spec.rb b/spec/services/project_custom_field_project_mappings/bulk_update_service_spec.rb
index 34f375aee39..b22d207018a 100644
--- a/spec/services/project_custom_field_project_mappings/bulk_update_service_spec.rb
+++ b/spec/services/project_custom_field_project_mappings/bulk_update_service_spec.rb
@@ -35,14 +35,14 @@ RSpec.describe ProjectCustomFieldProjectMappings::BulkUpdateService do
let!(:visible_project_custom_field) do
create(:project_custom_field,
name: "Visible field",
- visible: true,
+ admin_only: false,
project_custom_field_section: section_with_invisible_fields)
end
let!(:visible_required_project_custom_field) do
create(:project_custom_field,
name: "Visible required field",
- visible: true,
+ admin_only: false,
is_required: true,
project_custom_field_section: section_with_invisible_fields)
end
@@ -50,7 +50,7 @@ RSpec.describe ProjectCustomFieldProjectMappings::BulkUpdateService do
let!(:invisible_project_custom_field) do
create(:project_custom_field,
name: "Admin only field",
- visible: false,
+ admin_only: true,
project_custom_field_section: section_with_invisible_fields)
end
diff --git a/spec/services/project_custom_field_project_mappings/toggle_service_spec.rb b/spec/services/project_custom_field_project_mappings/toggle_service_spec.rb
index 51a62e0d4ae..ac2c05a54e4 100644
--- a/spec/services/project_custom_field_project_mappings/toggle_service_spec.rb
+++ b/spec/services/project_custom_field_project_mappings/toggle_service_spec.rb
@@ -35,14 +35,14 @@ RSpec.describe ProjectCustomFieldProjectMappings::ToggleService do
let!(:visible_project_custom_field) do
create(:project_custom_field,
name: "Visible field",
- visible: true,
+ admin_only: false,
project_custom_field_section: section_with_invisible_fields)
end
let!(:visible_required_project_custom_field) do
create(:project_custom_field,
name: "Visible required field",
- visible: true,
+ admin_only: false,
is_required: true,
project_custom_field_section: section_with_invisible_fields)
end
@@ -50,7 +50,7 @@ RSpec.describe ProjectCustomFieldProjectMappings::ToggleService do
let!(:invisible_project_custom_field) do
create(:project_custom_field,
name: "Admin only field",
- visible: false,
+ admin_only: true,
project_custom_field_section: section_with_invisible_fields)
end
diff --git a/spec/services/projects/create_service_spec.rb b/spec/services/projects/create_service_spec.rb
index 682f4e7e4d9..8c697e15675 100644
--- a/spec/services/projects/create_service_spec.rb
+++ b/spec/services/projects/create_service_spec.rb
@@ -84,7 +84,7 @@ RSpec.describe Projects::CreateService, type: :model do
create(:list_project_custom_field, project_custom_field_section: section)
end
let!(:hidden_custom_field) do
- create(:text_project_custom_field, project_custom_field_section: section, visible: false)
+ create(:text_project_custom_field, project_custom_field_section: section, admin_only: true)
end
let(:project) { subject.result }
let(:project_attributes) { {} }