Merge branch 'dev'
This commit is contained in:
commit
d027330bb6
4 changed files with 20 additions and 12 deletions
|
@ -0,0 +1,7 @@
|
|||
class AddUniqConstraintOnGestionnaireDossierCouple < ActiveRecord::Migration[5.0]
|
||||
def up
|
||||
change_column_null :follows, :gestionnaire_id, false
|
||||
change_column_null :follows, :dossier_id, false
|
||||
add_index :follows, [:gestionnaire_id, :dossier_id], unique: true
|
||||
end
|
||||
end
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20170711125726) do
|
||||
ActiveRecord::Schema.define(version: 20170713151123) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -230,9 +230,10 @@ ActiveRecord::Schema.define(version: 20170711125726) do
|
|||
end
|
||||
|
||||
create_table "follows", force: :cascade do |t|
|
||||
t.integer "gestionnaire_id"
|
||||
t.integer "dossier_id"
|
||||
t.integer "gestionnaire_id", null: false
|
||||
t.integer "dossier_id", null: false
|
||||
t.index ["dossier_id"], name: "index_follows_on_dossier_id", using: :btree
|
||||
t.index ["gestionnaire_id", "dossier_id"], name: "index_follows_on_gestionnaire_id_and_dossier_id", unique: true, using: :btree
|
||||
t.index ["gestionnaire_id"], name: "index_follows_on_gestionnaire_id", using: :btree
|
||||
end
|
||||
|
||||
|
|
|
@ -488,11 +488,11 @@ describe Dossier do
|
|||
context 'when dossier is followed' do
|
||||
let(:procedure) { create(:procedure, :with_type_de_champ, :with_type_de_champ_private) }
|
||||
let(:gestionnaire) { create(:gestionnaire) }
|
||||
let(:follow) { create(:follow, gestionnaire: gestionnaire) }
|
||||
let(:date1) { 1.day.ago }
|
||||
let(:date2) { 1.hour.ago }
|
||||
let(:date3) { 1.minute.ago }
|
||||
let(:dossier) { create(:dossier, :with_entreprise, user: user, procedure: procedure, follows: [follow], initiated_at: date1, received_at: date2, processed_at: date3, motivation: "Motivation") }
|
||||
let(:dossier) { create(:dossier, :with_entreprise, user: user, procedure: procedure, initiated_at: date1, received_at: date2, processed_at: date3, motivation: "Motivation") }
|
||||
let!(:follow) { create(:follow, gestionnaire: gestionnaire, dossier: dossier) }
|
||||
|
||||
describe '#export_headers' do
|
||||
subject { dossier.export_headers }
|
||||
|
|
|
@ -3,26 +3,26 @@ require 'spec_helper'
|
|||
describe DossierTableExportSerializer do
|
||||
describe '#emails_accompagnateurs' do
|
||||
let(:gestionnaire){ create(:gestionnaire) }
|
||||
let(:follow) { create(:follow, gestionnaire: gestionnaire) }
|
||||
let(:gestionnaire2) { create :gestionnaire}
|
||||
let(:dossier) { create(:dossier) }
|
||||
|
||||
subject { DossierTableExportSerializer.new(dossier).emails_accompagnateurs }
|
||||
|
||||
context 'when there is no accompagnateurs' do
|
||||
let(:dossier) { create(:dossier, follows: []) }
|
||||
|
||||
it { is_expected.to eq('') }
|
||||
end
|
||||
|
||||
context 'when there one accompagnateur' do
|
||||
let(:dossier) { create(:dossier, follows: [follow]) }
|
||||
before { gestionnaire.followed_dossiers << dossier }
|
||||
|
||||
it { is_expected.to eq(gestionnaire.email) }
|
||||
end
|
||||
|
||||
context 'when there is 2 followers' do
|
||||
let(:gestionnaire2) { create :gestionnaire}
|
||||
let(:follow2) { create(:follow, gestionnaire: gestionnaire2) }
|
||||
let(:dossier) { create(:dossier, follows: [follow, follow2]) }
|
||||
before do
|
||||
gestionnaire.followed_dossiers << dossier
|
||||
gestionnaire2.followed_dossiers << dossier
|
||||
end
|
||||
|
||||
it { is_expected.to eq "#{gestionnaire.email} #{gestionnaire2.email}" }
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue