Merge pull request #1092 from sgmap/fix-sentry-2139

Fix sentry issue #2139 when published_at is nil
This commit is contained in:
Mathieu Magnin 2017-12-14 11:13:12 +01:00 committed by GitHub
commit feb1c927a8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 2 deletions

View file

@ -10,7 +10,9 @@ class ProcedureDecorator < Draper::Decorator
end
def published_at_fr
published_at.localtime.strftime('%d/%m/%Y %H:%M')
if published_at.present?
published_at.localtime.strftime('%d/%m/%Y %H:%M')
end
end
def logo_img

View file

@ -1,7 +1,10 @@
require 'spec_helper'
describe ProcedureDecorator do
let(:procedure) { create(:procedure, :published, created_at: Time.new(2015, 12, 24, 14, 10)) }
let(:published_at) { Time.new(2017, 12, 24, 14, 12) }
let(:procedure) { create(:procedure, published_at: published_at, created_at: Time.new(2015, 12, 24, 14, 10)) }
let!(:procedure_path) { create(:procedure_path, administrateur: create(:administrateur), procedure: procedure) }
subject { procedure.decorate }
describe 'lien' do
@ -14,6 +17,16 @@ describe ProcedureDecorator do
it { is_expected.to eq('24/12/2015 14:10') }
end
describe 'published_at_fr' do
subject { super().published_at_fr }
it { is_expected.to eq('24/12/2017 14:12') }
context 'published_at is nil' do
let(:published_at) { nil }
it { is_expected.to eq(nil) }
end
end
describe 'logo_img' do
subject { super().logo_img }
it { is_expected.to match(/http.*#{ActionController::Base.helpers.image_url(LOGO_NAME)}/) }