Consider deleted campaigns in slug naming

This commit is contained in:
Eric Schultz 2019-02-05 16:57:45 -06:00
parent 7eb12b7506
commit 84a48860e2
2 changed files with 2 additions and 2 deletions

View file

@ -21,7 +21,7 @@ class SlugP2pCampaignNamingAlgorithm < CopyNamingAlgorithm
def get_already_used_name_entities(base_name)
end_name = "\\_\\d{3}"
Campaign.where('slug SIMILAR TO ? AND nonprofit_id = ? AND (deleted IS NULL OR deleted = false)', base_name + end_name, nonprofit_id).select('slug')
Campaign.where('slug SIMILAR TO ? AND nonprofit_id = ?', base_name + end_name, nonprofit_id).select('slug')
end
end

View file

@ -24,7 +24,7 @@ describe SlugP2pCampaignNamingAlgorithm do
describe 'campaigns' do
let(:campaign) {force_create(:campaign, :slug => @name, nonprofit: nonprofit)}
let(:campaign) {force_create(:campaign, :slug => @name, nonprofit: nonprofit, deleted:true)}
let(:campaign2) {force_create(:campaign, :slug => @name2, nonprofit:nonprofit)}
let(:campaigns_at_max_copies) { (0..999).collect{|i|
force_create(:campaign, slug: "#{@copy_base}_#{"%03d" % i}", nonprofit:nonprofit)