diff --git a/spec/support/models.rb b/spec/support/models.rb index edfd3ff579..38b6fcbc06 100644 --- a/spec/support/models.rb +++ b/spec/support/models.rb @@ -36,13 +36,13 @@ def find_or_create_root_taxon_name # @return [Integer, nil] # accessor to the global def user_id - $user_id + Current.user_id || $user_id end # @return [Integer, nil] # accessor to the global def project_id - $project_id + Current.project_id || $project_id end end diff --git a/spec/support/projects_and_users.rb b/spec/support/projects_and_users.rb index 3261de80a6..3b1ac35a2f 100644 --- a/spec/support/projects_and_users.rb +++ b/spec/support/projects_and_users.rb @@ -7,17 +7,22 @@ def self.clean_slate ProjectMember.delete_all Project.delete_all User.delete_all - $user_id = nil + $user_id = nil + Current.user_id = nil $project_id = nil + Current.project_id = nil end # This is used before all tests of type :model, :controller, :helper def self.spin_up_projects_users_and_housekeeping # Order matters FactoryBot.create(:valid_user, id: 1, self_created: true) - $user_id = 1 + $user_id = 1 # TODO: remove + Current.user_id = 1 + FactoryBot.create(:valid_project, id: 1, without_root_taxon_name: true) - $project_id = 1 + Current.project_id = 1 + $project_id = 1 # TODO: remove FactoryBot.create(:project_member, user_id: 1, project_id: 1) # TODO: Not sure why this is required, perhaps Spring related?!