Merge pull request #1092 from sgmap/fix-sentry-2139
Fix sentry issue #2139 when published_at is nil
This commit is contained in:
commit
feb1c927a8
2 changed files with 17 additions and 2 deletions
|
@ -10,8 +10,10 @@ class ProcedureDecorator < Draper::Decorator
|
|||
end
|
||||
|
||||
def published_at_fr
|
||||
if published_at.present?
|
||||
published_at.localtime.strftime('%d/%m/%Y %H:%M')
|
||||
end
|
||||
end
|
||||
|
||||
def logo_img
|
||||
if logo.blank?
|
||||
|
|
|
@ -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)}/) }
|
||||
|
|
Loading…
Reference in a new issue