From 142ca444d31b7241d7004c27dd87eaf3c60e251f Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Thu, 13 Apr 2017 11:55:11 +0200 Subject: [PATCH 1/2] [Fix #93] Auto-deploy master after it has built --- .circleci/config.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 8fb45c9c5..6d340f0ef 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -64,3 +64,7 @@ jobs: if [ "${CIRCLE_BRANCH}" == "staging" ]; then bundle exec rake deploy_ha fi + + if [ "${CIRCLE_BRANCH}" == "master" ]; then + bundle exec rake deploy_ha to=production + fi From d531b02bc523a67ff87188c1874c6c9f03809514 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Thu, 13 Apr 2017 14:48:18 +0200 Subject: [PATCH 2/2] Order types_de_piece_justificative on Procedure So that /spec/controllers/api/v1/ dossiers_controller_spec.rb#L163-L179 (on commit 8852431 for example) does not randomly fail due to unordered types_de_piece_justificative --- app/models/procedure.rb | 8 ++------ app/views/admin/pieces_justificatives/_form.html.haml | 2 +- spec/factories/procedure.rb | 4 ++-- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/app/models/procedure.rb b/app/models/procedure.rb index 35ea1d7a8..3d4edf63f 100644 --- a/app/models/procedure.rb +++ b/app/models/procedure.rb @@ -1,5 +1,5 @@ class Procedure < ActiveRecord::Base - has_many :types_de_piece_justificative, dependent: :destroy + has_many :types_de_piece_justificative, -> { order "order_place ASC" }, dependent: :destroy has_many :types_de_champ, class_name: 'TypeDeChampPublic', dependent: :destroy has_many :types_de_champ_private, dependent: :destroy has_many :dossiers @@ -64,10 +64,6 @@ class Procedure < ActiveRecord::Base types_de_champ_private.order(:order_place) end - def types_de_piece_justificative_ordered - types_de_piece_justificative.order(:order_place) - end - def self.active id Procedure.where(archived: false, published: true).find(id) end @@ -81,7 +77,7 @@ class Procedure < ActiveRecord::Base end def switch_types_de_piece_justificative index_of_first_element - switch_list_order(types_de_piece_justificative_ordered, index_of_first_element) + switch_list_order(types_de_piece_justificative, index_of_first_element) end def switch_list_order(list, index_of_first_element) diff --git a/app/views/admin/pieces_justificatives/_form.html.haml b/app/views/admin/pieces_justificatives/_form.html.haml index 6bdb2c4b4..2499b7cad 100644 --- a/app/views/admin/pieces_justificatives/_form.html.haml +++ b/app/views/admin/pieces_justificatives/_form.html.haml @@ -1,6 +1,6 @@ = form_for [:admin, @procedure], url: admin_procedure_pieces_justificatives_path(@procedure), remote: true do |f| #liste_piece_justificative - = render partial: 'fields', locals: { types_de_piece_justificative: @procedure.types_de_piece_justificative_ordered.decorate, f: f } + = render partial: 'fields', locals: { types_de_piece_justificative: @procedure.types_de_piece_justificative.decorate, f: f } = f.submit "Enregistrer", class: 'btn btn-success', id: :save %hr #new_type_de_piece_justificative diff --git a/spec/factories/procedure.rb b/spec/factories/procedure.rb index e97e10ee1..30da5d76d 100644 --- a/spec/factories/procedure.rb +++ b/spec/factories/procedure.rb @@ -63,8 +63,8 @@ FactoryGirl.define do trait :with_two_type_de_piece_justificative do after(:build) do |procedure, _evaluator| - rib = create(:type_de_piece_justificative, :rib) - msa = create(:type_de_piece_justificative, :msa) + rib = create(:type_de_piece_justificative, :rib, order_place: 1) + msa = create(:type_de_piece_justificative, :msa, order_place: 2) procedure.types_de_piece_justificative << rib procedure.types_de_piece_justificative << msa