Files

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

113 lines
3.0 KiB
Ruby
Raw Permalink Normal View History

2025-05-05 09:29:55 +02:00
# frozen_string_literal: true
#-- copyright
2020-01-15 11:31:26 +01:00
# OpenProject is an open source project management software.
# Copyright (C) the OpenProject GmbH
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
2013-09-16 17:59:31 +02:00
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
2021-01-13 17:47:45 +01:00
# Copyright (C) 2006-2013 Jean-Philippe Lang
2013-09-16 17:59:31 +02:00
# Copyright (C) 2010-2013 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See COPYRIGHT and LICENSE files for more details.
#++
2012-12-19 15:44:03 +01:00
require "spec_helper"
2023-05-31 12:15:15 +02:00
RSpec.describe DeletedUser do
let(:user) { DeletedUser.new }
describe "#admin" do
it { expect(user.admin).to be_falsey }
end
describe "#logged?" do
it { expect(user).not_to be_logged }
end
describe "#name" do
it { expect(user.name).to eq(I18n.t("user.deleted")) }
end
describe "#mail" do
it { expect(user.mail).to be_nil }
end
describe "#time_zone" do
2024-09-02 18:11:41 +02:00
it { expect(user.time_zone).to eql ActiveSupport::TimeZone["Etc/UTC"] }
end
describe "#rss_key" do
it { expect(user.rss_key).to be_nil }
end
describe "#destroy" do
it { expect(user.destroy).to be_falsey }
end
describe "#available_custom_fields" do
before do
2022-01-24 19:22:35 +01:00
create(:user_custom_field)
end
it { expect(user.available_custom_fields).to eq([]) }
end
describe "#create" do
2014-11-03 23:43:33 +01:00
describe "WHEN creating a second deleted user" do
2022-01-24 19:22:35 +01:00
let(:u1) { build(:deleted_user) }
let(:u2) { build(:deleted_user) }
before do
u1.save!
u2.save
end
it { expect(u1).not_to be_new_record }
it { expect(u2).to be_new_record }
it { expect(u2.errors[:base]).to include "A DeletedUser already exists." }
end
end
describe "#valid" do
2014-11-03 23:43:33 +01:00
describe "WHEN no login, first-, lastname and mail is provided" do
let(:user) { DeletedUser.new }
it { expect(user).to be_valid }
end
end
describe "#first" do
2014-11-03 23:43:33 +01:00
describe "WHEN a deleted user already exists" do
2022-01-24 19:22:35 +01:00
let(:user) { build(:deleted_user) }
before do
user.save!
end
it { expect(DeletedUser.first).to eq(user) }
end
2014-11-03 23:43:33 +01:00
describe "WHEN no deleted user exists" do
it { expect(DeletedUser.first.is_a?(DeletedUser)).to be_truthy }
it { expect(DeletedUser.first).not_to be_new_record }
end
end
end