diff --git a/app/models/passport.rb b/app/models/passport.rb index 85e6cca..a90f250 100644 --- a/app/models/passport.rb +++ b/app/models/passport.rb @@ -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) diff --git a/app/validators/passport_image_validator.rb b/app/validators/passport_image_validator.rb deleted file mode 100644 index 2a85fcd..0000000 --- a/app/validators/passport_image_validator.rb +++ /dev/null @@ -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 diff --git a/config/locales/activerecord/en.yml b/config/locales/activerecord/en.yml index 128bf0f..887b956 100644 --- a/config/locales/activerecord/en.yml +++ b/config/locales/activerecord/en.yml @@ -41,7 +41,6 @@ en: native_name: Name passport: id: ID - images: Images passport_map: id: ID first_name: First name diff --git a/config/locales/activerecord/ru.yml b/config/locales/activerecord/ru.yml index 8e640a7..4d35268 100644 --- a/config/locales/activerecord/ru.yml +++ b/config/locales/activerecord/ru.yml @@ -41,7 +41,6 @@ ru: native_name: Название passport: id: ID - images: Изображения passport_map: id: ID first_name: Имя diff --git a/factories/passports.rb b/factories/passports.rb index 589db08..58be143 100644 --- a/factories/passports.rb +++ b/factories/passports.rb @@ -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 diff --git a/features/desktop/staff_person_comments.feature b/features/desktop/staff_person_comments.feature index b778296..3e2e840 100644 --- a/features/desktop/staff_person_comments.feature +++ b/features/desktop/staff_person_comments.feature @@ -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" diff --git a/features/step_definitions/stepdefs.rb b/features/step_definitions/stepdefs.rb index 2f8668d..eced65b 100644 --- a/features/step_definitions/stepdefs.rb +++ b/features/step_definitions/stepdefs.rb @@ -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 diff --git a/fixtures/avatar.jpg b/fixtures/avatar.jpg new file mode 100644 index 0000000..35aa6f8 Binary files /dev/null and b/fixtures/avatar.jpg differ diff --git a/fixtures/passport_image_1.jpg b/fixtures/passport_image_1.jpg deleted file mode 100644 index 849f432..0000000 Binary files a/fixtures/passport_image_1.jpg and /dev/null differ diff --git a/fixtures/passport_image_2.jpg b/fixtures/passport_image_2.jpg deleted file mode 100644 index e63c634..0000000 Binary files a/fixtures/passport_image_2.jpg and /dev/null differ diff --git a/fixtures/passport_image_3.jpg b/fixtures/passport_image_3.jpg deleted file mode 100644 index 67fc564..0000000 Binary files a/fixtures/passport_image_3.jpg and /dev/null differ diff --git a/fixtures/passport_image_4.jpg b/fixtures/passport_image_4.jpg deleted file mode 100644 index f41d283..0000000 Binary files a/fixtures/passport_image_4.jpg and /dev/null differ diff --git a/spec/models/passport_spec.rb b/spec/models/passport_spec.rb index 85803e2..06c52ee 100644 --- a/spec/models/passport_spec.rb +++ b/spec/models/passport_spec.rb @@ -14,5 +14,4 @@ RSpec.describe Passport do end pending '#passport_map' - pending '#image' end diff --git a/spec/requests/staff/people/passports/index_spec.rb b/spec/requests/staff/people/passports/index_spec.rb index d89fcd6..16ee911 100644 --- a/spec/requests/staff/people/passports/index_spec.rb +++ b/spec/requests/staff/people/passports/index_spec.rb @@ -8,10 +8,8 @@ RSpec.describe 'GET /staff/people/:person_id/passports' do before do sign_in current_account.user if current_account&.user - 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 + create :empty_passport, person: person + create :passport_with_map, person: person get "/staff/people/#{person.to_param}/passports" end diff --git a/spec/validators/passport_image_validator_spec.rb b/spec/validators/passport_image_validator_spec.rb deleted file mode 100644 index d01cc4e..0000000 --- a/spec/validators/passport_image_validator_spec.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -require 'rails_helper' - -RSpec.describe PassportImageValidator do - pending "add some examples to (or delete) #{__FILE__}" -end