Remove feature flag for publish draft
This commit is contained in:
parent
694cb21371
commit
44f28ec565
14 changed files with 28 additions and 65 deletions
|
@ -99,7 +99,7 @@ class Admin::ProceduresController < AdminController
|
||||||
@availability = @procedure.path_availability(@path)
|
@availability = @procedure.path_availability(@path)
|
||||||
end
|
end
|
||||||
render 'edit'
|
render 'edit'
|
||||||
elsif Flipflop.publish_draft? && @procedure.brouillon?
|
elsif @procedure.brouillon?
|
||||||
reset_procedure
|
reset_procedure
|
||||||
flash.notice = 'Démarche modifiée. Tous les dossiers de cette démarche ont été supprimés.'
|
flash.notice = 'Démarche modifiée. Tous les dossiers de cette démarche ont été supprimés.'
|
||||||
redirect_to edit_admin_procedure_path(id: @procedure.id)
|
redirect_to edit_admin_procedure_path(id: @procedure.id)
|
||||||
|
@ -273,10 +273,7 @@ class Admin::ProceduresController < AdminController
|
||||||
if @procedure&.locked?
|
if @procedure&.locked?
|
||||||
params.require(:procedure).permit(*editable_params)
|
params.require(:procedure).permit(*editable_params)
|
||||||
else
|
else
|
||||||
if Flipflop.publish_draft?
|
params.require(:procedure).permit(*editable_params, :duree_conservation_dossiers_dans_ds, :duree_conservation_dossiers_hors_ds, :for_individual, :individual_with_siret, :ask_birthday, :path).merge(administrateur_id: current_administrateur.id)
|
||||||
editable_params << :path
|
|
||||||
end
|
|
||||||
params.require(:procedure).permit(*editable_params, :duree_conservation_dossiers_dans_ds, :duree_conservation_dossiers_hors_ds, :for_individual, :individual_with_siret, :ask_birthday).merge(administrateur_id: current_administrateur.id)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -124,7 +124,7 @@ class Procedure < ApplicationRecord
|
||||||
|
|
||||||
# This method is needed for transition. Eventually this will be the same as brouillon?.
|
# This method is needed for transition. Eventually this will be the same as brouillon?.
|
||||||
def brouillon_avec_lien?
|
def brouillon_avec_lien?
|
||||||
Flipflop.publish_draft? && brouillon? && path.present?
|
brouillon? && path.present?
|
||||||
end
|
end
|
||||||
|
|
||||||
def publiee_ou_archivee?
|
def publiee_ou_archivee?
|
||||||
|
@ -472,10 +472,8 @@ class Procedure < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def ensure_path_exists
|
def ensure_path_exists
|
||||||
if Flipflop.publish_draft?
|
if self.path.nil?
|
||||||
if self.path.nil?
|
self.path = SecureRandom.uuid
|
||||||
self.path = SecureRandom.uuid
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,10 +3,7 @@
|
||||||
%li{ class: @draft_class }
|
%li{ class: @draft_class }
|
||||||
%a{ :href => "#{url_for :admin_procedures_draft}" }
|
%a{ :href => "#{url_for :admin_procedures_draft}" }
|
||||||
%h5.text-primary
|
%h5.text-primary
|
||||||
- if Flipflop.publish_draft?
|
En test
|
||||||
En test
|
|
||||||
- else
|
|
||||||
Brouillons
|
|
||||||
|
|
||||||
%li{ class: @active_class }
|
%li{ class: @active_class }
|
||||||
%a{ :href => "#{url_for :admin_procedures}" }
|
%a{ :href => "#{url_for :admin_procedures}" }
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
= form_for @procedure, url: { controller: 'admin/procedures', action: :create }, multipart: true do |f|
|
= form_for @procedure, url: { controller: 'admin/procedures', action: :create }, multipart: true do |f|
|
||||||
= render partial: 'informations', locals: { f: f }
|
= render partial: 'informations', locals: { f: f }
|
||||||
.text-right
|
.text-right
|
||||||
- if !Flipflop.publish_draft? || @availability.in?(Procedure::PATH_CAN_PUBLISH)
|
- if @availability.in?(Procedure::PATH_CAN_PUBLISH)
|
||||||
= f.button 'Valider', class: 'btn btn-info', id: 'save-procedure'
|
= f.button 'Valider', class: 'btn btn-info', id: 'save-procedure'
|
||||||
- else
|
- else
|
||||||
= f.button 'Valider', class: 'btn btn-info', id: 'save-procedure', disabled: true
|
= f.button 'Valider', class: 'btn btn-info', id: 'save-procedure', disabled: true
|
||||||
|
|
|
@ -11,10 +11,7 @@
|
||||||
#procedure-list
|
#procedure-list
|
||||||
%a#draft-procedures{ :href => "#{url_for :admin_procedures_draft}" }
|
%a#draft-procedures{ :href => "#{url_for :admin_procedures_draft}" }
|
||||||
.procedure-list-element{ class: @draft_class }
|
.procedure-list-element{ class: @draft_class }
|
||||||
- if Flipflop.publish_draft?
|
En test
|
||||||
En test
|
|
||||||
- else
|
|
||||||
Brouillons
|
|
||||||
.badge.progress-bar-default
|
.badge.progress-bar-default
|
||||||
= current_administrateur.procedures.brouillons.count
|
= current_administrateur.procedures.brouillons.count
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,6 @@ Flipflop.configure do
|
||||||
end
|
end
|
||||||
|
|
||||||
feature :web_hook
|
feature :web_hook
|
||||||
feature :publish_draft
|
|
||||||
feature :enable_email_login_token
|
feature :enable_email_login_token
|
||||||
feature :new_champs_editor
|
feature :new_champs_editor
|
||||||
|
|
||||||
|
|
|
@ -303,10 +303,6 @@ describe Admin::ProceduresController, type: :controller do
|
||||||
let!(:dossiers_count) { procedure.dossiers.count }
|
let!(:dossiers_count) { procedure.dossiers.count }
|
||||||
|
|
||||||
describe 'dossiers are dropped' do
|
describe 'dossiers are dropped' do
|
||||||
before do
|
|
||||||
Flipflop::FeatureSet.current.test!.switch!(:publish_draft, true)
|
|
||||||
end
|
|
||||||
|
|
||||||
subject { update_procedure }
|
subject { update_procedure }
|
||||||
|
|
||||||
it {
|
it {
|
||||||
|
@ -378,7 +374,7 @@ describe Admin::ProceduresController, type: :controller do
|
||||||
|
|
||||||
it 'does not publish the given procedure' do
|
it 'does not publish the given procedure' do
|
||||||
expect(procedure.publiee?).to be_falsey
|
expect(procedure.publiee?).to be_falsey
|
||||||
expect(procedure.path).to be_nil
|
expect(procedure.path).not_to match(path)
|
||||||
expect(response.status).to eq 200
|
expect(response.status).to eq 200
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -394,7 +390,7 @@ describe Admin::ProceduresController, type: :controller do
|
||||||
|
|
||||||
it 'does not publish the given procedure' do
|
it 'does not publish the given procedure' do
|
||||||
expect(procedure.publiee?).to be_falsey
|
expect(procedure.publiee?).to be_falsey
|
||||||
expect(procedure.path).to be_nil
|
expect(procedure.path).not_to match(path)
|
||||||
expect(response).to redirect_to :admin_procedures
|
expect(response).to redirect_to :admin_procedures
|
||||||
expect(flash[:alert]).to have_content 'Lien de la démarche invalide'
|
expect(flash[:alert]).to have_content 'Lien de la démarche invalide'
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,7 +7,6 @@ feature 'As an administrateur I wanna clone a procedure', js: true do
|
||||||
let(:administrateur) { create(:administrateur) }
|
let(:administrateur) { create(:administrateur) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
Flipflop::FeatureSet.current.test!.switch!(:publish_draft, true)
|
|
||||||
login_as administrateur, scope: :administrateur
|
login_as administrateur, scope: :administrateur
|
||||||
visit new_from_existing_admin_procedures_path
|
visit new_from_existing_admin_procedures_path
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,7 +8,6 @@ feature 'As an administrateur I wanna create a new procedure', js: true do
|
||||||
let(:test_strategy) { Flipflop::FeatureSet.current.test! }
|
let(:test_strategy) { Flipflop::FeatureSet.current.test! }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
test_strategy.switch!(:publish_draft, true)
|
|
||||||
test_strategy.switch!(:new_champs_editor, true)
|
test_strategy.switch!(:new_champs_editor, true)
|
||||||
login_as administrateur, scope: :administrateur
|
login_as administrateur, scope: :administrateur
|
||||||
visit root_path
|
visit root_path
|
||||||
|
@ -50,29 +49,6 @@ feature 'As an administrateur I wanna create a new procedure', js: true do
|
||||||
expect(page).to have_current_path(champs_procedure_path(Procedure.last))
|
expect(page).to have_current_path(champs_procedure_path(Procedure.last))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when publish_draft disabled" do
|
|
||||||
before do
|
|
||||||
test_strategy.switch!(:publish_draft, false)
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario 'Finding save button for new procedure, libelle, description and cadre_juridique required' do
|
|
||||||
expect(page).to have_selector('#new-procedure')
|
|
||||||
find('#new-procedure').click
|
|
||||||
click_on 'from-scratch'
|
|
||||||
|
|
||||||
expect(page).to have_current_path(new_admin_procedure_path)
|
|
||||||
fill_in 'procedure_duree_conservation_dossiers_dans_ds', with: '3'
|
|
||||||
fill_in 'procedure_duree_conservation_dossiers_hors_ds', with: '6'
|
|
||||||
click_on 'save-procedure'
|
|
||||||
|
|
||||||
expect(page).to have_text('Libelle doit être rempli')
|
|
||||||
fill_in_dummy_procedure_details(fill_path: false)
|
|
||||||
click_on 'save-procedure'
|
|
||||||
|
|
||||||
expect(page).to have_current_path(champs_procedure_path(Procedure.last))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'Editing a new procedure' do
|
context 'Editing a new procedure' do
|
||||||
|
|
|
@ -14,7 +14,6 @@ feature 'Administrateurs can edit procedures', js: true do
|
||||||
end
|
end
|
||||||
|
|
||||||
before do
|
before do
|
||||||
Flipflop::FeatureSet.current.test!.switch!(:publish_draft, true)
|
|
||||||
login_as administrateur, scope: :administrateur
|
login_as administrateur, scope: :administrateur
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -14,14 +14,14 @@ describe Gestionnaire, type: :model do
|
||||||
|
|
||||||
describe '#visible_procedures' do
|
describe '#visible_procedures' do
|
||||||
let(:procedure_not_assigned) { create :procedure, administrateur: admin }
|
let(:procedure_not_assigned) { create :procedure, administrateur: admin }
|
||||||
let(:procedure_without_link) { create :procedure, administrateur: admin }
|
let(:procedure_with_default_path) { create :procedure, administrateur: admin }
|
||||||
let(:procedure_with_link) { create :procedure, :with_path, administrateur: admin }
|
let(:procedure_with_custom_path) { create :procedure, :with_path, administrateur: admin }
|
||||||
let(:procedure_archived_manually) { create :procedure, :archived, administrateur: admin }
|
let(:procedure_archived_manually) { create :procedure, :archived, administrateur: admin }
|
||||||
let(:procedure_archived_automatically) { create :procedure, :archived_automatically, administrateur: admin }
|
let(:procedure_archived_automatically) { create :procedure, :archived_automatically, administrateur: admin }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
assign(procedure_without_link)
|
assign(procedure_with_default_path)
|
||||||
assign(procedure_with_link)
|
assign(procedure_with_custom_path)
|
||||||
assign(procedure_archived_manually)
|
assign(procedure_archived_manually)
|
||||||
assign(procedure_archived_automatically)
|
assign(procedure_archived_automatically)
|
||||||
end
|
end
|
||||||
|
@ -30,8 +30,8 @@ describe Gestionnaire, type: :model do
|
||||||
|
|
||||||
it do
|
it do
|
||||||
expect(subject).not_to include(procedure_not_assigned)
|
expect(subject).not_to include(procedure_not_assigned)
|
||||||
expect(subject).not_to include(procedure_without_link)
|
expect(subject).to include(procedure_with_default_path)
|
||||||
expect(subject).to include(procedure_with_link)
|
expect(subject).to include(procedure_with_custom_path)
|
||||||
expect(subject).to include(procedure_archived_manually)
|
expect(subject).to include(procedure_archived_manually)
|
||||||
expect(subject).to include(procedure_archived_automatically)
|
expect(subject).to include(procedure_archived_automatically)
|
||||||
end
|
end
|
||||||
|
|
|
@ -386,7 +386,7 @@ describe Procedure do
|
||||||
|
|
||||||
cloned_procedure = subject
|
cloned_procedure = subject
|
||||||
cloned_procedure.parent_procedure_id = nil
|
cloned_procedure.parent_procedure_id = nil
|
||||||
expect(cloned_procedure).to have_same_attributes_as(procedure)
|
expect(cloned_procedure).to have_same_attributes_as(procedure, except: ["path"])
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should not clone piece justificatives but create corresponding champs' do
|
it 'should not clone piece justificatives but create corresponding champs' do
|
||||||
|
@ -479,7 +479,7 @@ describe Procedure do
|
||||||
expect(subject.published_at).to be_nil
|
expect(subject.published_at).to be_nil
|
||||||
expect(subject.test_started_at).to be_nil
|
expect(subject.test_started_at).to be_nil
|
||||||
expect(subject.aasm_state).to eq "brouillon"
|
expect(subject.aasm_state).to eq "brouillon"
|
||||||
expect(subject.path).to be_nil
|
expect(subject.path).not_to be_nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -638,9 +638,11 @@ describe Procedure do
|
||||||
end
|
end
|
||||||
|
|
||||||
context "without a path" do
|
context "without a path" do
|
||||||
let(:procedure) { create(:procedure) }
|
let(:procedure) { create(:procedure, :archived) }
|
||||||
|
|
||||||
it { is_expected.to eq("dossiers_procedure-#{procedure.id}_2018-01-02_23-11.csv") }
|
it do
|
||||||
|
is_expected.to eq("dossiers_procedure-#{procedure.id}_2018-01-02_23-11.csv")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -158,9 +158,12 @@ RSpec.configure do |config|
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
RSpec::Matchers.define :have_same_attributes_as do |expected|
|
RSpec::Matchers.define :have_same_attributes_as do |expected, options|
|
||||||
match do |actual|
|
match do |actual|
|
||||||
ignored = [:id, :procedure_id, :updated_at, :created_at]
|
ignored = [:id, :procedure_id, :updated_at, :created_at]
|
||||||
|
if options.present? && options[:except]
|
||||||
|
ignored = ignored + options[:except]
|
||||||
|
end
|
||||||
actual.attributes.with_indifferent_access.except(*ignored) == expected.attributes.with_indifferent_access.except(*ignored)
|
actual.attributes.with_indifferent_access.except(*ignored) == expected.attributes.with_indifferent_access.except(*ignored)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -33,8 +33,8 @@ describe 'admin/procedures/show.html.haml', type: :view do
|
||||||
it { expect(rendered).not_to have_css('a#reopen-procedure') }
|
it { expect(rendered).not_to have_css('a#reopen-procedure') }
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'procedure link is not present' do
|
describe 'procedure path is not customized' do
|
||||||
it { expect(rendered).to have_content('Cette démarche n’a pas encore de lien, et n’est pas accessible par le public.') }
|
it { expect(rendered).to have_content('Cette démarche est actuellement en test') }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue