Remove passport images feature
This commit is contained in:
parent
10e638f970
commit
0d39c24a86
15 changed files with 4 additions and 65 deletions
|
@ -7,20 +7,12 @@ class Passport < ApplicationRecord
|
|||
|
||||
belongs_to :person, optional: true
|
||||
|
||||
has_many_attached :images
|
||||
|
||||
has_many :passport_maps,
|
||||
dependent: :restrict_with_exception
|
||||
|
||||
accepts_nested_attributes_for :passport_maps,
|
||||
reject_if: :blank_passport_map?
|
||||
|
||||
###############
|
||||
# Validations #
|
||||
###############
|
||||
|
||||
validates :images, passport_image: true
|
||||
|
||||
###########
|
||||
# Methods #
|
||||
###########
|
||||
|
@ -29,10 +21,6 @@ class Passport < ApplicationRecord
|
|||
passport_maps.order(created_at: :asc).last
|
||||
end
|
||||
|
||||
def image
|
||||
images.order(created_at: :asc).last
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def blank_passport_map?(passport_map_attributes)
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class PassportImageValidator < ImageValidator
|
||||
class Validation < Validation
|
||||
MAX_SIZE = 20.megabytes
|
||||
|
||||
def max_size
|
||||
MAX_SIZE
|
||||
end
|
||||
end
|
||||
end
|
|
@ -41,7 +41,6 @@ en:
|
|||
native_name: Name
|
||||
passport:
|
||||
id: ID
|
||||
images: Images
|
||||
passport_map:
|
||||
id: ID
|
||||
first_name: First name
|
||||
|
|
|
@ -41,7 +41,6 @@ ru:
|
|||
native_name: Название
|
||||
passport:
|
||||
id: ID
|
||||
images: Изображения
|
||||
passport_map:
|
||||
id: ID
|
||||
first_name: Имя
|
||||
|
|
|
@ -9,33 +9,9 @@ FactoryBot.define do
|
|||
create :passport_map, passport: passport
|
||||
end
|
||||
end
|
||||
|
||||
trait :with_image do
|
||||
transient do
|
||||
image_filename { image_fixture }
|
||||
image_fixture { "passport_image_#{rand(1..4)}.jpg" }
|
||||
|
||||
image_path { Rails.root.join 'fixtures', image_fixture }
|
||||
end
|
||||
|
||||
after :build do |passport, evaluator|
|
||||
passport.images.attach(
|
||||
filename: evaluator.image_filename,
|
||||
io: File.open(evaluator.image_path),
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
factory :passport_with_map,
|
||||
parent: :empty_passport,
|
||||
traits: %i[with_map]
|
||||
|
||||
factory :passport_with_image,
|
||||
parent: :empty_passport,
|
||||
traits: %i[with_image]
|
||||
|
||||
factory :passport_with_map_and_image,
|
||||
parent: :empty_passport,
|
||||
traits: %i[with_map with_image]
|
||||
end
|
||||
|
|
|
@ -18,7 +18,7 @@ Feature: Staff person comments
|
|||
When I fill form with the following data:
|
||||
| key | value |
|
||||
| Текст | foobar |
|
||||
And I upload "passport_image_1.jpg" as "Приложение"
|
||||
And I upload "avatar.jpg" as "Приложение"
|
||||
And I click the form button "Отправить"
|
||||
Then I see text "foobar"
|
||||
And I see text "passport_image_1.jpg"
|
||||
And I see text "avatar.jpg"
|
||||
|
|
|
@ -72,8 +72,6 @@ When 'I fill the passport creation form' do
|
|||
fill_in 'Номер', with: @passport_attributes['Номер']
|
||||
fill_in 'Кем выдан', with: @passport_attributes['Кем выдан']
|
||||
fill_in 'Код подразделения', with: @passport_attributes['Код подразделения']
|
||||
|
||||
attach_file 'Изображения', Rails.root.join('fixtures', 'passport_image_1.jpg')
|
||||
end
|
||||
|
||||
Then 'I see the passport page' do
|
||||
|
|
BIN
fixtures/avatar.jpg
Normal file
BIN
fixtures/avatar.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 22 KiB |
Binary file not shown.
Before Width: | Height: | Size: 446 KiB |
Binary file not shown.
Before Width: | Height: | Size: 113 KiB |
Binary file not shown.
Before Width: | Height: | Size: 98 KiB |
Binary file not shown.
Before Width: | Height: | Size: 96 KiB |
|
@ -14,5 +14,4 @@ RSpec.describe Passport do
|
|||
end
|
||||
|
||||
pending '#passport_map'
|
||||
pending '#image'
|
||||
end
|
||||
|
|
|
@ -10,8 +10,6 @@ RSpec.describe 'GET /staff/people/:person_id/passports' do
|
|||
|
||||
create :empty_passport, person: person
|
||||
create :passport_with_map, person: person
|
||||
create :passport_with_image, person: person
|
||||
create :passport_with_map_and_image, person: person
|
||||
|
||||
get "/staff/people/#{person.to_param}/passports"
|
||||
end
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe PassportImageValidator do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
Reference in a new issue