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
added regression spec for active users and fixed anonymous user's status
Markus Kahlddb40187ba2f
diff --git a/app/models/user.rb b/app/models/user.rbindex a1c35b39bb4..e6223c5825f 100644--- a/app/models/user.rb+++ b/app/models/user.rb@@ -685,7 +685,7 @@ class User < Principalu.login = ''u.firstname = ''u.mail = ''- u.status = 0+ u.status = User::STATUSES[:active]end).saveraise 'Unable to create the anonymous user.' if anonymous_user.new_record?enddiff --git a/db/migrate/20191112111040_fix_system_user_status.rb b/db/migrate/20191112111040_fix_system_user_status.rbnew file mode 100644index 00000000000..d90bba96077--- /dev/null+++ b/db/migrate/20191112111040_fix_system_user_status.rb@@ -0,0 +1,34 @@+class FixSystemUserStatus < ActiveRecord::Migration[6.0]+ def up+ # The previous migration was supposed to make the system user active,+ # but doesn't since it only touches built-in (0) users while the system user+ # used to be locked (3). An oversight on our part.+ #+ # We also update the anonymous user again. While it was correctly updated+ # in the previous migration, newly created anonymous users since have the+ # wrong status (0) because we failed to update the on-the-fly+ # creation of the anonymous user with the correct status.+ users.each do |user|+ user.update_all status: Principal::STATUSES[:active]+ end+ end++ def down+ system_user.update_all status: Principal::STATUSES[:locked]+ # There is no need to update the anonymous user since it was supposed to be+ # active at this point already anyway. The previous migration then makes it+ # built-in (0) again if we rollback even further.+ end++ def users+ [system_user, anonymous_user]+ end++ def system_user+ SystemUser+ end++ def anonymous_user+ AnonymousUser+ end+enddiff --git a/spec/lib/open_project/enterprise_spec.rb b/spec/lib/open_project/enterprise_spec.rbindex 282be8f7510..ec80b39c994 100644--- a/spec/lib/open_project/enterprise_spec.rb+++ b/spec/lib/open_project/enterprise_spec.rb@@ -32,8 +32,14 @@ require 'open_project/passwords'describe OpenProject::Enterprise dodescribe "#user_limit_reached?" dolet(:user_limit) { 2 }+ let(:builtin_user_count) { 3 }before do+ # create 3 built-in users+ User.system+ User.anonymous+ DeletedUser.first+allow(OpenProject::Enterprise).to receive(:user_limit).and_return(user_limit)end@@ -41,7 +47,7 @@ describe OpenProject::Enterprise dobefore doFactoryBot.create :user- expect(User.active.count).to eq 1+ expect(User.active.count).to eq 1 + builtin_user_count # created user + built-in onesendit "is false" do@@ -56,7 +62,7 @@ describe OpenProject::Enterprise dobefore doFactoryBot.create_list :user, num_active_users- expect(User.active.count).to eq num_active_users+ expect(User.active.count).to eq num_active_users + builtin_user_countendit "is true" do