Merge pull request #1853 from 0xF013/feature/15354_user_is_shown_as_deleted_incorrectly

pull/1867/merge
Hagen Schink 10 years ago
commit a5e6fce4a3
  1. 3
      app/models/journal_manager.rb
  2. 48
      spec/models/journal_manager_spec.rb

@ -197,8 +197,7 @@ class JournalManager
end
# change journal user
journal.user_id = substitute_id if journal.user_id = current_user_id
journal.user_id = substitute_id if journal.user_id == current_user_id
journal.save if journal.data.changed?
end

@ -100,4 +100,52 @@ describe JournalManager, :type => :model do
it { is_expected.to be_truthy }
end
end
describe "self.#update_user_references" do
let!(:work_package) {FactoryGirl.create :work_package}
let!(:doomed_user) {work_package.author}
let!(:data1) {
FactoryGirl.build(:journal_work_package_journal,
subject: work_package.subject,
status_id: work_package.status_id,
type_id: work_package.type_id,
author_id: doomed_user.id,
project_id: work_package.project_id)
}
let!(:data2) {
FactoryGirl.build(:journal_work_package_journal,
subject: work_package.subject,
status_id: work_package.status_id,
type_id: work_package.type_id,
author_id: doomed_user.id,
project_id: work_package.project_id)
}
let!(:doomed_user_journal) {
FactoryGirl.create :work_package_journal,
notes: "1",
user: doomed_user,
journable_id: work_package.id,
data: data1
}
let!(:some_other_journal) {
FactoryGirl.create :work_package_journal,
notes: "2",
journable_id: work_package.id,
data: data2
}
before do
doomed_user.destroy
end
it "should mark the user's journal as deleted" do
expect(doomed_user_journal.reload.user.is_a?(DeletedUser)).to be_truthy
end
it "should not mark an unrelated journal's user as deleted" do
expect(some_other_journal.reload.user.is_a?(DeletedUser)).to be_falsy
end
end
end

Loading…
Cancel
Save