diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2017-07-19 16:19:32 +0000 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2017-07-19 16:19:32 +0000 |
commit | c6e979587af7cf8d85b4e97a8771d44aa04f3ef4 (patch) | |
tree | cd33f2ed61a0fb375228025de16f4065d0c233e9 /spec/support | |
parent | b042765d2f56e6a7c64c2563bba2f795fde439bf (diff) | |
parent | a9d940bffcf7447f8d62012bd1c8f866697a12d6 (diff) | |
download | gitlab-ce-c6e979587af7cf8d85b4e97a8771d44aa04f3ef4.tar.gz |
Merge branch '34930-fix-edited-by' into 'master'
Fix issue detail if user who last edited an issue was deleted
Closes #34930
See merge request !12933
Diffstat (limited to 'spec/support')
-rw-r--r-- | spec/support/services/migrate_to_ghost_user_service_shared_examples.rb | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/spec/support/services/migrate_to_ghost_user_service_shared_examples.rb b/spec/support/services/migrate_to_ghost_user_service_shared_examples.rb index dcc562c684b..855051921f0 100644 --- a/spec/support/services/migrate_to_ghost_user_service_shared_examples.rb +++ b/spec/support/services/migrate_to_ghost_user_service_shared_examples.rb @@ -1,6 +1,6 @@ require "spec_helper" -shared_examples "migrating a deleted user's associated records to the ghost user" do |record_class| +shared_examples "migrating a deleted user's associated records to the ghost user" do |record_class, fields| record_class_name = record_class.to_s.titleize.downcase let(:project) { create(:project) } @@ -11,6 +11,7 @@ shared_examples "migrating a deleted user's associated records to the ghost user context "for a #{record_class_name} the user has created" do let!(:record) { created_record } + let(:migrated_fields) { fields || [:author] } it "does not delete the #{record_class_name}" do service.execute @@ -18,22 +19,20 @@ shared_examples "migrating a deleted user's associated records to the ghost user expect(record_class.find_by_id(record.id)).to be_present end - it "migrates the #{record_class_name} so that the 'Ghost User' is the #{record_class_name} owner" do + it "blocks the user before migrating #{record_class_name}s to the 'Ghost User'" do service.execute - migrated_record = record_class.find_by_id(record.id) - - if migrated_record.respond_to?(:author) - expect(migrated_record.author).to eq(User.ghost) - else - expect(migrated_record.send(author_alias)).to eq(User.ghost) - end + expect(user).to be_blocked end - it "blocks the user before migrating #{record_class_name}s to the 'Ghost User'" do + it 'migrates all associated fields to te "Ghost user"' do service.execute - expect(user).to be_blocked + migrated_record = record_class.find_by_id(record.id) + + migrated_fields.each do |field| + expect(migrated_record.public_send(field)).to eq(User.ghost) + end end context "race conditions" do |