Merge pull request #3475 from betagouv/ship-publish-draft
Ship publish draft
This commit is contained in:
commit
0b6dadb230
3 changed files with 56 additions and 1 deletions
|
@ -65,7 +65,7 @@
|
||||||
pour y accéder vous pouvez utiliser le lien :
|
pour y accéder vous pouvez utiliser le lien :
|
||||||
= link_to procedure_lien(@procedure), sanitize_url(procedure_lien(@procedure)), target: :blank
|
= link_to procedure_lien(@procedure), sanitize_url(procedure_lien(@procedure)), target: :blank
|
||||||
%p
|
%p
|
||||||
Tout personne ayant la connaissance de ce lien pourra ainsi remplir des dossiers sur votre démarche.
|
Tout personne ayant la connaissance de ce lien pourra ainsi remplir des dossiers de test sur votre démarche.
|
||||||
%br
|
%br
|
||||||
|
|
||||||
%h4 Ce que vous pouvez faire lorsque vous êtes en test
|
%h4 Ce que vous pouvez faire lorsque vous êtes en test
|
||||||
|
|
|
@ -130,4 +130,28 @@ namespace :support do
|
||||||
|
|
||||||
user.update(email: new_email)
|
user.update(email: new_email)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
desc <<~EOD
|
||||||
|
Activate feature publish draft
|
||||||
|
EOD
|
||||||
|
task activate_publish_draft: :environment do
|
||||||
|
start_with = ENV['START_WITH']
|
||||||
|
|
||||||
|
administrateurs = Administrateur.where("email like ?", "#{start_with}%")
|
||||||
|
|
||||||
|
rake_puts("Activating publish draft for #{administrateurs.count} administrateurs...")
|
||||||
|
|
||||||
|
administrateurs.each do |a|
|
||||||
|
rake_puts("Activating publish draft for #{a.email}")
|
||||||
|
a.features["publish_draft"] = true
|
||||||
|
a.save
|
||||||
|
|
||||||
|
a.procedures.brouillon.each do |p|
|
||||||
|
if p.path.nil?
|
||||||
|
p.path = SecureRandom.uuid
|
||||||
|
p.save
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
31
spec/lib/tasks/activate_publish_draft_spec.rb
Normal file
31
spec/lib/tasks/activate_publish_draft_spec.rb
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe 'activate_publish_draft#clean' do
|
||||||
|
let(:rake_task) { Rake::Task['support:activate_publish_draft'] }
|
||||||
|
|
||||||
|
let(:administrateur) { create(:administrateur) }
|
||||||
|
let!(:procedure) { create(:procedure, administrateur: administrateur) }
|
||||||
|
let!(:procedure2) { create(:simple_procedure, administrateur: administrateur) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
ENV['START_WITH'] = administrateur.email
|
||||||
|
rake_task.invoke
|
||||||
|
administrateur.reload
|
||||||
|
end
|
||||||
|
|
||||||
|
after { rake_task.reenable }
|
||||||
|
|
||||||
|
it 'activate feature for administrateur' do
|
||||||
|
expect(administrateur.features["publish_draft"]).to eq(true)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'create a path for his brouillon procedure' do
|
||||||
|
expect(administrateur.procedures.brouillon.count).to eq(1)
|
||||||
|
expect(administrateur.procedures.brouillon.first.path).not_to eq(nil)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'does not change the path of his published procedure' do
|
||||||
|
expect(administrateur.procedures.publiee.count).to eq(1)
|
||||||
|
expect(administrateur.procedures.publiee.first.path).to eq(procedure2.path)
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue