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
Allow non-admins to see/filter created_at of a project
Jan Sandbrink9109ab21bbc2
diff --git a/app/models/queries/projects/filters/created_at_filter.rb b/app/models/queries/projects/filters/created_at_filter.rbindex f1de4ea2818..cd2bdb19424 100644--- a/app/models/queries/projects/filters/created_at_filter.rb+++ b/app/models/queries/projects/filters/created_at_filter.rb@@ -32,10 +32,4 @@ class Queries::Projects::Filters::CreatedAtFilter < Queries::Projects::Filters::def type:datetime_pastend-- def available?- # The column is only available for admins.- # When the filter is used, one could get the same information as with the column.- User.current.admin?- endenddiff --git a/app/models/queries/projects/selects/created_at.rb b/app/models/queries/projects/selects/created_at.rbindex 3a04f73e4c0..f43a9600f55 100644--- a/app/models/queries/projects/selects/created_at.rb+++ b/app/models/queries/projects/selects/created_at.rb@@ -32,8 +32,4 @@ class Queries::Projects::Selects::CreatedAt < Queries::Selects::Basedef self.key:created_atend-- def self.available?- User.current.admin?- endenddiff --git a/spec/features/projects/lists/table_spec.rb b/spec/features/projects/lists/table_spec.rbindex c6cf949ef1f..58547fd4a6e 100644--- a/spec/features/projects/lists/table_spec.rb+++ b/spec/features/projects/lists/table_spec.rb@@ -218,10 +218,6 @@ RSpec.describe "Projects lists table display and actions", :js, with_settings: {within("#project-table") doexpect(page).to have_css("th", text: "REQUIRED DISK STORAGE")- expect(page)- .to have_css("th", text: "CREATED ON")- expect(page)- .to have_css("td", text: project.created_at.strftime("%m/%d/%Y"))expect(page).to have_css("th", text: "LATEST ACTIVITY AT")expect(page)@@ -580,14 +576,8 @@ RSpec.describe "Projects lists table display and actions", :js, with_settings: {within("#project-table") doexpect(page).to have_no_css("th", text: "REQUIRED DISK STORAGE")- expect(page)- .to have_no_css("th", text: "CREATED ON")- expect(page)- .to have_no_css("td", text: project.created_at.strftime("%m/%d/%Y"))expect(page).to have_no_css("th", text: "LATEST ACTIVITY AT")- expect(page)- .to have_no_css("td", text: news.created_at.strftime("%m/%d/%Y"))endendenddiff --git a/spec/features/projects/persisted_lists_spec.rb b/spec/features/projects/persisted_lists_spec.rbindex fccdcef9e6c..c87ee3724fa 100644--- a/spec/features/projects/persisted_lists_spec.rb+++ b/spec/features/projects/persisted_lists_spec.rb@@ -621,10 +621,10 @@ RSpec.describe "Persisted lists on projects index page",let!(:invalid_list) do# Faking a query that has references stored to a custom field that no longer exists (e.g. has been deleted)- create(:project_query, name: "My projects list", user:, select: %w[name created_at cf_1]) do |query|+ create(:project_query, name: "My projects list", user:, select: %w[name latest_activity_at cf_1]) do |query|query.where("member_of", "=", OpenProject::Database::DB_VALUE_TRUE)query.where("cf_1", "=", 1)- query.where("created_at", "=", "2020-01-01")+ query.where("latest_activity_at", "=", "2020-01-01")query.save(validate: false)end@@ -633,11 +633,11 @@ RSpec.describe "Persisted lists on projects index page",it "still shows the query falling back to a valid subset" dovisit projects_path(query_id: invalid_list.id)- # Keeps only the 'Name' column as the cf does not exist and Created on is admin only.+ # Keeps only the 'Name' column as the cf does not exist and "Latest activity at" is admin only.projects_page.expect_columns "Name"- projects_page.expect_no_columns "Created on"+ projects_page.expect_no_columns "Latest activity at"- # Keeps only the 'I am member' filter as the cf does not exist and created_at is admin only.+ # Keeps only the 'I am member' filter as the cf does not exist and latest_activity_at is admin only.projects_page.expect_filter_count 1projects_page.expect_filter_set("member_of")diff --git a/spec/models/queries/factory_project_query_spec.rb b/spec/models/queries/factory_project_query_spec.rbindex 636cef8bcb0..f4335a76c49 100644--- a/spec/models/queries/factory_project_query_spec.rb+++ b/spec/models/queries/factory_project_query_spec.rb@@ -812,7 +812,7 @@ RSpec.describe Queries::Factory,endcontext "without id, as non admin and with a non existing custom field id",- with_settings: { enabled_projects_columns: %w[name created_at cf_1 cf_42] } do+ with_settings: { enabled_projects_columns: %w[name latest_activity_at cf_1 cf_42] } dobefore docustom_fieldenddiff --git a/spec/models/queries/projects/filters/created_at_filter_spec.rb b/spec/models/queries/projects/filters/created_at_filter_spec.rbindex 3ff3067b018..2316172b7ba 100644--- a/spec/models/queries/projects/filters/created_at_filter_spec.rb+++ b/spec/models/queries/projects/filters/created_at_filter_spec.rb@@ -57,9 +57,9 @@ RSpec.describe Queries::Projects::Filters::CreatedAtFilter dologin_as userend- it "is false" do+ it "is true" doexpect(instance)- .not_to be_available+ .to be_availableendendenddiff --git a/spec/models/queries/projects/project_query_spec.rb b/spec/models/queries/projects/project_query_spec.rbindex 5d723e0c700..499e68f1ad7 100644--- a/spec/models/queries/projects/project_query_spec.rb+++ b/spec/models/queries/projects/project_query_spec.rb@@ -143,6 +143,7 @@ RSpec.describe ProjectQuery dohierarchyproject_statusstatus_explanation+ created_atcf_23cf_42budget_available@@ -240,7 +241,7 @@ RSpec.describe ProjectQuery dobefore doinstance.where("active", "=", OpenProject::Database::DB_VALUE_TRUE)- instance.where("created_at", ">t-", ["6"])+ instance.where("latest_activity_at", ">t-", ["6"])instance.valid_subset!end@@ -339,8 +340,8 @@ RSpec.describe ProjectQuery doendcontext "with them being invalid" do- # No admin, hence no created_at column. CF column does not exist.- let(:selects) { %i(bogus created_at cf_1) } # rubocop:disable Naming/VariableNumber+ # No admin, hence no latest_activity_at column. CF column does not exist.+ let(:selects) { %i(bogus latest_activity_at cf_1) } # rubocop:disable Naming/VariableNumberit "removes the values" doexpect(instance.selects.map(&:attribute))@@ -350,11 +351,11 @@ RSpec.describe ProjectQuery docontext "with them being partially invalid" dolet(:current_user) { admin }- let(:selects) { %i(bogus name created_at cf_1 description) } # rubocop:disable Naming/VariableNumber+ let(:selects) { %i(bogus name latest_activity_at cf_1 description) } # rubocop:disable Naming/VariableNumberit "removes only the offending values" doexpect(instance.selects.map(&:attribute))- .to eq %i(name created_at description)+ .to eq %i(name latest_activity_at description)endendenddiff --git a/spec/services/project_queries/set_attributes_service_spec.rb b/spec/services/project_queries/set_attributes_service_spec.rbindex 320db7e1444..090329064d2 100644--- a/spec/services/project_queries/set_attributes_service_spec.rb+++ b/spec/services/project_queries/set_attributes_service_spec.rb@@ -175,7 +175,7 @@ RSpec.describe ProjectQueries::SetAttributesService, type: :model do# rubocop:disable Naming/VariableNumberit "assigns default selects for non admin",- with_settings: { enabled_projects_columns: %w[name created_at cf_1] } do+ with_settings: { enabled_projects_columns: %w[name latest_activity_at cf_1] } dosubjectexpect(model_instance.selects.map(&:attribute))@@ -183,7 +183,7 @@ RSpec.describe ProjectQueries::SetAttributesService, type: :model doendit "assigns default selects for admin",- with_settings: { enabled_projects_columns: %w[name created_at cf_1] } do+ with_settings: { enabled_projects_columns: %w[name latest_activity_at cf_1] } doallow(User.current).to receive(:admin?).and_return(true)@@ -191,7 +191,7 @@ RSpec.describe ProjectQueries::SetAttributesService, type: :model dosubjectexpect(model_instance.selects.map(&:attribute))- .to eql %i[favorited name created_at cf_1]+ .to eql %i[favorited name latest_activity_at cf_1]end# rubocop:enable Naming/VariableNumberend