diff --git a/app/controllers/backoffice/preference_list_dossier_controller.rb b/app/controllers/backoffice/preference_list_dossier_controller.rb index 0b9e564b3..645ddc049 100644 --- a/app/controllers/backoffice/preference_list_dossier_controller.rb +++ b/app/controllers/backoffice/preference_list_dossier_controller.rb @@ -8,7 +8,7 @@ class Backoffice::PreferenceListDossierController < ApplicationController def add PreferenceListDossier.create( libelle: params[:libelle], - table: params[:table], + table: (params[:table].empty? ? nil : params[:table]), attr: params[:attr], attr_decorate: params[:attr_decorate], bootstrap_lg: params[:bootstrap_lg], diff --git a/app/services/dossiers_list_gestionnaire_service.rb b/app/services/dossiers_list_gestionnaire_service.rb index cd6b04949..2433304c4 100644 --- a/app/services/dossiers_list_gestionnaire_service.rb +++ b/app/services/dossiers_list_gestionnaire_service.rb @@ -76,7 +76,7 @@ class DossiersListGestionnaireService @current_devise_profil.preference_list_dossiers .find_by(table: table, attr: attr, procedure: @procedure) - .update_column :order, order + .update order: order end def reset_sort! diff --git a/db/migrate/20160927154248_change_emptyto_nil_in_preference_list_dossier_table.rb b/db/migrate/20160927154248_change_emptyto_nil_in_preference_list_dossier_table.rb new file mode 100644 index 000000000..a5905c8e2 --- /dev/null +++ b/db/migrate/20160927154248_change_emptyto_nil_in_preference_list_dossier_table.rb @@ -0,0 +1,9 @@ +class ChangeEmptytoNilInPreferenceListDossierTable < ActiveRecord::Migration + class PreferenceListDossier < ActiveRecord::Base + + end + + def change + PreferenceListDossier.where(table: '').update_all table: nil + end +end diff --git a/db/schema.rb b/db/schema.rb index 7490e1253..a238ccf10 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20160926160051) do +ActiveRecord::Schema.define(version: 20160927154248) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" diff --git a/spec/facades/dossiers_list_facades_spec.rb b/spec/facades/dossiers_list_facades_spec.rb index 625643930..6741bb84c 100644 --- a/spec/facades/dossiers_list_facades_spec.rb +++ b/spec/facades/dossiers_list_facades_spec.rb @@ -12,13 +12,13 @@ describe DossiersListFacades do create :preference_list_dossier, gestionnaire: gestionnaire, - table: '', + table: nil, attr: 'state', attr_decorate: 'display_state' create :preference_list_dossier, gestionnaire: gestionnaire, - table: '', + table: nil, attr: 'state', attr_decorate: 'display_state', procedure_id: procedure.id diff --git a/spec/views/backoffice/dossiers/index_html.haml_spec.rb b/spec/views/backoffice/dossiers/index_html.haml_spec.rb index cd937d856..ddca9e976 100644 --- a/spec/views/backoffice/dossiers/index_html.haml_spec.rb +++ b/spec/views/backoffice/dossiers/index_html.haml_spec.rb @@ -28,7 +28,7 @@ describe 'backoffice/dossiers/index.html.haml', type: :view do create :preference_list_dossier, gestionnaire: gestionnaire, - table: '', + table: nil, attr: 'state', attr_decorate: 'display_state' @@ -46,7 +46,7 @@ describe 'backoffice/dossiers/index.html.haml', type: :view do create :preference_list_dossier, gestionnaire: gestionnaire, - table: '', + table: nil, attr: 'last_update', attr_decorate: 'last_update'