From bffe2b651c1d38b7b209f576d812bdb2e7472abb Mon Sep 17 00:00:00 2001 From: cmrd Senya Date: Fri, 26 Apr 2019 20:58:28 +0300 Subject: [PATCH] AccountMigration spec: flatten shared examples more --- spec/integration/account_migration_spec.rb | 64 ++++++++++++---------- spec/shared_behaviors/account_deletion.rb | 12 ---- 2 files changed, 34 insertions(+), 42 deletions(-) diff --git a/spec/integration/account_migration_spec.rb b/spec/integration/account_migration_spec.rb index 6e5b6d740..804269ad2 100644 --- a/spec/integration/account_migration_spec.rb +++ b/spec/integration/account_migration_spec.rb @@ -14,34 +14,6 @@ def create_remote_contact(user, pod_host) ) end -shared_examples_for "old person account is closed and profile is cleared" do - subject { old_person } - - before do - run_migration - subject.reload - end - - include_examples "it makes account closed and clears profile" -end - -shared_examples_for "old person doesn't have any reference left" do - let(:person) { old_person } - - before do - DataGenerator.create(person, :generic_person_data) - end - - def account_removal_method - run_migration - person.reload - end - - include_examples "it removes the person associations" - - include_examples "it removes the person conversations" -end - shared_examples_for "every migration scenario" do it "updates person references" do contact = FactoryGirl.create(:contact, person: old_person) @@ -91,9 +63,41 @@ shared_examples_for "every migration scenario" do expect(actor.reload.person).to eq(new_person) end - it_behaves_like "old person account is closed and profile is cleared" + describe "old person account is closed and profile is cleared" do + subject { old_person } - it_behaves_like "old person doesn't have any reference left" + before do + run_migration + subject.reload + end + + include_examples "it makes account closed and clears profile" + end + + describe "old person doesn't have any reference left" do + let(:person) { old_person } + + before do + DataGenerator.create(person, :generic_person_data) + end + + def account_removal_method + run_migration + person.reload + end + + include_examples "it removes the person associations" + + it "removes the person conversations" do + expect { + account_removal_method + }.to change(nil, "conversations empty?") { Conversation.where(author: person).empty? } + .to(be_truthy) + .and(change(nil, "conversation visibilities of other participants empty?") { + ConversationVisibility.where(conversation: Conversation.where(author: person)).empty? + }.to(be_truthy)) + end + end end shared_examples_for "migration scenarios with local old user" do diff --git a/spec/shared_behaviors/account_deletion.rb b/spec/shared_behaviors/account_deletion.rb index 25ce9a6d9..1b2297b2d 100644 --- a/spec/shared_behaviors/account_deletion.rb +++ b/spec/shared_behaviors/account_deletion.rb @@ -55,18 +55,6 @@ shared_examples_for "it keeps the person conversations" do end end -shared_examples_for "it removes the person conversations" do - it "removes the person conversations" do - expect { - account_removal_method - }.to change(nil, "conversations empty?") { Conversation.where(author: person).empty? } - .to(be_truthy) - .and(change(nil, "conversation visibilities of other participants empty?") { - ConversationVisibility.where(conversation: Conversation.where(author: person)).empty? - }.to(be_truthy)) - end -end - # In fact this example group if for testing effect of AccountDeleter.tombstone_person_and_profile shared_examples_for "it makes account closed and clears profile" do it "" do