diff --git a/lib/subjects/remover.rb b/lib/subjects/remover.rb index daaa5167a..b9f544556 100644 --- a/lib/subjects/remover.rb +++ b/lib/subjects/remover.rb @@ -60,9 +60,9 @@ def has_been_collected_or_classified? end def belongs_to_other_subject_set? - return false if !subject_set_id + return false unless subject_set_id != nil - orphan_subject.set_member_subjects.where.not(subject_set_id: subject_set_id).count > 0 + orphan_subject.set_member_subjects.where.not(subject_set_id: subject_set_id).count.positive? end def has_been_talked_about? diff --git a/spec/lib/subjects/remover_spec.rb b/spec/lib/subjects/remover_spec.rb index 6f84efc26..249a36467 100644 --- a/spec/lib/subjects/remover_spec.rb +++ b/spec/lib/subjects/remover_spec.rb @@ -105,11 +105,11 @@ expect { SetMemberSubject.find(sms_ids) }.to raise_error(ActiveRecord::RecordNotFound) end - context "with multiple subject sets" do + context 'with multiple subject sets' do let(:alternate_subject_set) { create(:subject_set) } - let(:remover) { Subjects::Remover.new(subject.id, panoptes_client, alternate_subject_set.id) } - it "should not remove subjects associated with multiple set_member_subjects" do - create(:set_member_subject, subject: subject, subject_set: alternate_subject_set) + let(:remover) { described_class.new(subject.id, panoptes_client, alternate_subject_set.id) } + let(:new_sms) { create(:set_member_subject, subject: subject, subject_set: alternate_subject_set) } + it 'should not remove subjects associated with multiple set_member_subjects' do remover.cleanup expect(Subject.where(id: subject.id)).to exist end diff --git a/spec/workers/subject_removal_worker_spec.rb b/spec/workers/subject_removal_worker_spec.rb index 4681ba43f..4cc25653d 100644 --- a/spec/workers/subject_removal_worker_spec.rb +++ b/spec/workers/subject_removal_worker_spec.rb @@ -18,8 +18,8 @@ def stub_discussions_request(subject_id) stub_request(:get, discussions_url) - .with(query: { focus_id: subject_id, focus_type: "Subject" }) - .to_return(status: 200, body: "[]", headers: {}) + .with(query: { focus_id: subject_id, focus_type: 'Subject' }) + .to_return(status: 200, body: '[]', headers: {}) end before do