1
0
Fork 0

Add method Passport#image

This commit is contained in:
Alex Kotov 2018-12-01 15:23:58 +05:00
parent 40ac9c674b
commit 734e2c6828
No known key found for this signature in database
GPG key ID: 4E831250F47DE154
3 changed files with 6 additions and 1 deletions

View file

@ -24,6 +24,10 @@ class Passport < ApplicationRecord
self.patronymic = nil if patronymic.blank?
end
def image
images.order(created_at: :desc).last
end
def enough_confirmations?
passport_confirmations.count >= REQUIRED_CONFIRMATIONS
end

View file

@ -137,7 +137,7 @@
</dl>
</div>
<% @passport.images.order(created_at: :desc).limit(1).each do |image| %>
<% @passport.image.try do |image| %>
<div class="col-md-8 col-lg-6">
<%= image_tag url_for(image), class: 'img-fluid' %>
</div>

View file

@ -23,6 +23,7 @@ RSpec.describe Passport do
it { is_expected.to validate_presence_of :unit_code }
it { is_expected.to validate_presence_of :date_of_issue }
pending '#image'
pending '#enough_confirmations?'
describe '#patronymic' do