Migrate from Refile and Carrierwave to ActiveStorage

This commit is contained in:
Petko Bordjukov 2024-02-20 02:27:07 +02:00
parent 281b69e66d
commit 4c96ba1e9c
35 changed files with 118 additions and 182 deletions

1
.gitignore vendored
View File

@ -23,3 +23,4 @@
.sass-cache/ .sass-cache/
/coverage/ /coverage/
/db/structure.sql /db/structure.sql
/storage/

13
Gemfile
View File

@ -26,15 +26,6 @@ gem "simple_form"
gem "phony" gem "phony"
gem "phony_rails" gem "phony_rails"
# Picture uploads
gem "carrierwave"
# gem 'rmagick'
gem "mini_magick"
gem "refile", git: "https://github.com/refile/refile", require: ["refile/rails", "refile/simple_form"]
gem "refile-mini_magick"
gem "image_processing"
gem "puma", group: :production gem "puma", group: :production
gem "globalize" gem "globalize"
@ -74,10 +65,6 @@ group :development do
gem "pry-rails" gem "pry-rails"
# gem 'hirb' # gem 'hirb'
gem "awesome_print" gem "awesome_print"
gem "capistrano"
gem "capistrano-rails"
gem 'capistrano-rvm'
gem "capistrano3-puma"
gem "better_errors" gem "better_errors"
gem "binding_of_caller" gem "binding_of_caller"
end end

View File

@ -1,11 +1,3 @@
GIT
remote: https://github.com/refile/refile
revision: c4ac577c6fdad92bc079a62a0e82888319daedc8
specs:
refile (0.7.0)
mime-types
sinatra (>= 2.0.0, <= 3.0.0)
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
@ -89,8 +81,6 @@ GEM
tzinfo (~> 2.0) tzinfo (~> 2.0)
addressable (2.8.6) addressable (2.8.6)
public_suffix (>= 2.0.2, < 6.0) public_suffix (>= 2.0.2, < 6.0)
airbrussh (1.5.1)
sshkit (>= 1.6.1, != 1.7.0)
ast (2.4.2) ast (2.4.2)
autoprefixer-rails (10.4.16.0) autoprefixer-rails (10.4.16.0)
execjs (~> 2) execjs (~> 2)
@ -122,23 +112,6 @@ GEM
railties (>= 3.1) railties (>= 3.1)
builder (3.2.4) builder (3.2.4)
byebug (11.1.3) byebug (11.1.3)
capistrano (3.18.0)
airbrussh (>= 1.0.0)
i18n
rake (>= 10.0.0)
sshkit (>= 1.9.0)
capistrano-bundler (2.1.0)
capistrano (~> 3.1)
capistrano-rails (1.6.3)
capistrano (~> 3.1)
capistrano-bundler (>= 1.1, < 3)
capistrano-rvm (0.1.2)
capistrano (~> 3.0)
sshkit (~> 1.2)
capistrano3-puma (5.2.0)
capistrano (~> 3.7)
capistrano-bundler
puma (>= 4.0, < 6.0)
capybara (3.40.0) capybara (3.40.0)
addressable addressable
matrix matrix
@ -291,16 +264,11 @@ GEM
marcel (1.0.2) marcel (1.0.2)
matrix (0.4.2) matrix (0.4.2)
method_source (1.0.0) method_source (1.0.0)
mime-types (3.5.2)
mime-types-data (~> 3.2015)
mime-types-data (3.2024.0206)
mini_magick (4.12.0) mini_magick (4.12.0)
mini_mime (1.1.5) mini_mime (1.1.5)
mini_portile2 (2.8.5) mini_portile2 (2.8.5)
minitest (5.22.2) minitest (5.22.2)
msgpack (1.7.2) msgpack (1.7.2)
mustermann (3.0.0)
ruby2_keywords (~> 0.0.1)
mutex_m (0.2.0) mutex_m (0.2.0)
nenv (0.3.0) nenv (0.3.0)
nested_form (0.3.2) nested_form (0.3.2)
@ -313,13 +281,8 @@ GEM
net-protocol net-protocol
net-protocol (0.2.2) net-protocol (0.2.2)
timeout timeout
net-scp (4.0.0)
net-ssh (>= 2.6.5, < 8.0.0)
net-sftp (4.0.0)
net-ssh (>= 5.0.0, < 8.0.0)
net-smtp (0.4.0.1) net-smtp (0.4.0.1)
net-protocol net-protocol
net-ssh (7.2.1)
nio4r (2.7.0) nio4r (2.7.0)
nokogiri (1.16.2) nokogiri (1.16.2)
mini_portile2 (~> 2.8.2) mini_portile2 (~> 2.8.2)
@ -345,19 +308,17 @@ GEM
psych (5.1.2) psych (5.1.2)
stringio stringio
public_suffix (5.0.4) public_suffix (5.0.4)
puma (5.6.8) puma (6.4.2)
nio4r (~> 2.0) nio4r (~> 2.0)
racc (1.7.3) racc (1.7.3)
rack (2.2.8) rack (3.0.9)
rack-protection (3.0.0) rack-session (2.0.0)
rack rack (>= 3.0.0)
rack-session (1.0.2)
rack (< 3)
rack-test (2.1.0) rack-test (2.1.0)
rack (>= 1.3) rack (>= 1.3)
rackup (1.0.0) rackup (2.1.0)
rack (< 3) rack (>= 3)
webrick webrick (~> 1.8)
rails (7.1.3) rails (7.1.3)
actioncable (= 7.1.3) actioncable (= 7.1.3)
actionmailbox (= 7.1.3) actionmailbox (= 7.1.3)
@ -403,9 +364,6 @@ GEM
ffi (~> 1.0) ffi (~> 1.0)
rdoc (6.6.2) rdoc (6.6.2)
psych (>= 4.0.0) psych (>= 4.0.0)
refile-mini_magick (0.2.0)
mini_magick (~> 4.0)
refile (~> 0.5)
regexp_parser (2.9.0) regexp_parser (2.9.0)
reline (0.4.2) reline (0.4.2)
io-console (~> 0.5) io-console (~> 0.5)
@ -480,7 +438,7 @@ GEM
sprockets-rails sprockets-rails
tilt tilt
search_object (1.2.5) search_object (1.2.5)
selenium-webdriver (4.18.0) selenium-webdriver (4.18.1)
base64 (~> 0.2) base64 (~> 0.2)
rexml (~> 3.2, >= 3.2.5) rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2, < 3.0) rubyzip (>= 1.2.2, < 3.0)
@ -495,11 +453,6 @@ GEM
simplecov_json_formatter (~> 0.1) simplecov_json_formatter (~> 0.1)
simplecov-html (0.12.3) simplecov-html (0.12.3)
simplecov_json_formatter (0.1.4) simplecov_json_formatter (0.1.4)
sinatra (3.0.0)
mustermann (~> 3.0)
rack (~> 2.2, >= 2.2.4)
rack-protection (= 3.0.0)
tilt (~> 2.0)
slim (5.2.1) slim (5.2.1)
temple (~> 0.10.0) temple (~> 0.10.0)
tilt (>= 2.1.0) tilt (>= 2.1.0)
@ -520,11 +473,6 @@ GEM
sprockets (>= 3.0.0) sprockets (>= 3.0.0)
sqlite3 (1.7.2) sqlite3 (1.7.2)
mini_portile2 (~> 2.8.0) mini_portile2 (~> 2.8.0)
sshkit (1.22.0)
mutex_m
net-scp (>= 1.1.2)
net-sftp (>= 2.1.2)
net-ssh (>= 2.8.0)
ssrf_filter (1.1.2) ssrf_filter (1.1.2)
standard (1.34.0) standard (1.34.0)
language_server-protocol (~> 3.17.0.2) language_server-protocol (~> 3.17.0.2)
@ -578,12 +526,7 @@ DEPENDENCIES
bootstrap-sass-extras bootstrap-sass-extras
bootswatch-rails bootswatch-rails
byebug byebug
capistrano
capistrano-rails
capistrano-rvm
capistrano3-puma
capybara capybara
carrierwave
coffee-rails coffee-rails
copy_carrierwave_file copy_carrierwave_file
database_cleaner database_cleaner
@ -599,11 +542,9 @@ DEPENDENCIES
guard-rspec guard-rspec
i18n-tasks i18n-tasks
icalendar icalendar
image_processing
jbuilder jbuilder
jquery-datatables-rails jquery-datatables-rails
jquery-rails jquery-rails
mini_magick
nested_form nested_form
pg pg
phony phony
@ -614,8 +555,6 @@ DEPENDENCIES
rails-erd rails-erd
rails-i18n rails-i18n
raphael-rails raphael-rails
refile!
refile-mini_magick
rqrcode rqrcode
rspec-rails rspec-rails
sass-rails sass-rails
@ -633,4 +572,4 @@ DEPENDENCIES
yaml_db yaml_db
BUNDLED WITH BUNDLED WITH
2.4.12 2.5.6

View File

@ -0,0 +1,6 @@
//= link_tree ../images
//= link_tree ../../../lib/initfest/assets/images
//= link_directory ../javascripts .js
//= link_directory ../stylesheets .css
//= link initfest/application.css
//= link initfest/application.js

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

@ -3,6 +3,5 @@
//= require jquery_nested_form //= require jquery_nested_form
//= require bootstrap-sprockets //= require bootstrap-sprockets
//= require raphael //= require raphael
//= require morris
//= require chroma-js/chroma //= require chroma-js/chroma
//= require_directory . //= require_directory .

View File

@ -6,7 +6,7 @@
@import "bootstrap"; @import "bootstrap";
@import "bootswatch/simplex/bootswatch"; @import "bootswatch/simplex/bootswatch";
@import "morris"; /* @import "morris"; */
@import "users"; @import "users";
@import "colors"; @import "colors";
@ -19,4 +19,4 @@
& > div { & > div {
display: inline-block; display: inline-block;
} }
} }

View File

@ -53,7 +53,7 @@ module Management
@conference = find_conference @conference = find_conference
@profile = find_profile @profile = find_profile
if @profile.update_attributes(profile_params) if @profile.update(profile_params)
redirect_to [:management, @conference, @profile] redirect_to [:management, @conference, @profile]
else else
render action: "edit" render action: "edit"

View File

@ -20,7 +20,7 @@ module Public
def update def update
@profile = current_user.personal_profile(current_conference) @profile = current_user.personal_profile(current_conference)
if @profile.update_attributes(profile_params) if @profile.update(profile_params)
flash[:notice] = t("views.personal_profiles.successfully_updated") flash[:notice] = t("views.personal_profiles.successfully_updated")
redirect_to root_path redirect_to root_path
else else

View File

@ -13,7 +13,7 @@ class PersonalProfile < ActiveRecord::Base
phony_normalize :mobile_phone, default_country_code: "BG", add_plus: false phony_normalize :mobile_phone, default_country_code: "BG", add_plus: false
mount_uploader :picture, PictureUploader has_one_attached :picture
accepts_nested_attributes_for :user accepts_nested_attributes_for :user

View File

@ -38,7 +38,7 @@ class User < ActiveRecord::Base
def build_personal_profile(conference, params = {}) def build_personal_profile(conference, params = {})
if personal_profiles.last.present? if personal_profiles.last.present?
new_personal_profile = personal_profiles.last.try(:dup) new_personal_profile = personal_profiles.last.try(:dup)
CopyCarrierwaveFile::CopyFileService.new(personal_profiles.last, new_personal_profile, :picture).set_file new_personal_profile.picture.attach(personal_profiles.last.picture.blob)
else else
new_personal_profile = personal_profiles.build new_personal_profile = personal_profiles.build
end end

View File

@ -3,7 +3,7 @@ class Volunteer < ActiveRecord::Base
TSHIRT_CUTS = [:unisex, :female] TSHIRT_CUTS = [:unisex, :female]
FOOD_PREFERENCES = [:none, :vegetarian, :vegan] FOOD_PREFERENCES = [:none, :vegetarian, :vegan]
attachment :picture, type: :image has_one_attached :picture
validates :name, :language, :tshirt_size, :tshirt_cut, :food_preferences, presence: true validates :name, :language, :tshirt_size, :tshirt_cut, :food_preferences, presence: true
validates :tshirt_size, inclusion: {in: TSHIRT_SIZES.map(&:to_s)} validates :tshirt_size, inclusion: {in: TSHIRT_SIZES.map(&:to_s)}

View File

@ -1,53 +0,0 @@
class PictureUploader < CarrierWave::Uploader::Base
# Include RMagick or MiniMagick support:
# include CarrierWave::RMagick
include CarrierWave::MiniMagick
# Choose what kind of storage to use for this uploader:
storage :file
# storage :fog
# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted:
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
# Provide a default URL as a default if there hasn't been a file uploaded:
def default_url
ActionController::Base.helpers.asset_path("fallback/profile_picture/" + [version_name, "default.png"].compact.join("_"))
end
# Process files as they are uploaded:
# process :scale => [200, 300]
#
# def scale(width, height)
# # do something
# end
# Create different versions of your uploaded files:
version :medium do
process resize_to_fit: [171, 180]
end
version :thumb do
process resize_to_fit: [50, 50]
end
version :schedule do
process resize_to_fill: [100, 100]
end
# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
def extension_white_list
%w[jpg jpeg png]
end
# Override the filename of the uploaded files:
# Avoid using model.id or version_name here, see uploader/store.rb for details.
# def filename
# "something.jpg" if original_filename
# end
end

View File

@ -5,7 +5,7 @@
.panel.panel-default .panel.panel-default
- if personal_profile.present? - if personal_profile.present?
.panel-image .panel-image
= image_tag personal_profile.picture.url = image_tag personal_profile.picture
.panel-body .panel-body
.media .media
.media-body .media-body

View File

@ -10,9 +10,9 @@
.panel-body .panel-body
.row .row
.col-lg-12 .col-lg-12
- if f.object.picture.present? - if f.object.picture.attached?
.col-sm-offset-3.col-sm-9 .col-sm-offset-3.col-sm-9
= image_tag f.object.picture.medium.url, class: 'img-thumbnail' = image_tag f.object.picture.variant(resize_to_limit: [150, 150]), class: 'img-thumbnail'
= f.input :picture, wrapper: :horizontal_file_input = f.input :picture, wrapper: :horizontal_file_input

View File

@ -27,10 +27,9 @@
.media .media
.media-left .media-left
- if profile.present? - if profile.present?
= image_tag(profile.picture.thumb.url) = image_tag(profile.picture.variant(resize_to_fill: [50, 50]))
- else - else
= image_tag(PictureUploader.new.thumb.url) = image_tag('avatar-placeholder')
.media-body .media-body
h4.media-heading h4.media-heading
- if profile.try(:name).present? - if profile.try(:name).present?

View File

@ -9,7 +9,7 @@
.col-sm-5.col-md-4 .col-sm-5.col-md-4
.panel.panel-default .panel.panel-default
.panel-image .panel-image
= image_tag @profile.picture.url = image_tag @profile.picture
.panel-body .panel-body
.media .media
.media-body .media-body

View File

@ -5,9 +5,9 @@
.col-lg-12 .col-lg-12
- if f.object.picture.present? - if f.object.picture.present?
.col-sm-offset-3.col-sm-9 .col-sm-offset-3.col-sm-9
= attachment_image_tag(@volunteer, :picture, :fill, 150, 150) if @volunteer.picture.present? = @volunteer.picture.variant(resize_to_limit: [150, 150]) if @volunteer.picture.attached?
= f.input :picture, as: :attachment, wrapper: :horizontal_file_input, direct: true = f.input :picture, as: :file, wrapper: :horizontal_file_input, direct: true
= f.input :name, autofocus: true = f.input :name, autofocus: true
= f.input :email = f.input :email

View File

@ -41,9 +41,9 @@
.media .media
.media-left .media-left
- if volunteer.picture.present? - if volunteer.picture.present?
= attachment_image_tag(volunteer, :picture, :fill, 50, 50) = image_tag volunteer.picture.variant(resize_to_limit: [50, 50])
- else - else
= image_tag(PictureUploader.new.thumb.url) = image_tag('avatar-placeholder.png')
.media-body .media-body
h4.media-heading h4.media-heading
= volunteer.name = volunteer.name

View File

@ -10,17 +10,18 @@
.panel-body .panel-body
.media .media
.media-left.hidden-sm.hidden-xs .media-left.hidden-sm.hidden-xs
- if @volunteer.picture.present? - if @volunteer.picture.attached?
= attachment_image_tag(@volunteer, :picture, :fill, 150, 150) = image_tag @volunteer.picture.variant(resize_to_limit: [150, 150])
- else - else
= image_tag(PictureUploader.new.medium.url) = image_tag('avatar-placeholder.png')
.media-body .media-body
.text-center.visible-sm.visible-xs .text-center.visible-sm.visible-xs
- if @volunteer.picture.present? - if @volunteer.picture.attached?
= attachment_image_tag(@volunteer, :picture, :fill, 150, 150) = image_tag @volunteer.picture.variant(resize_to_limit: [150, 150])
- else - else
= image_tag(PictureUploader.new.medium.url) = image_tag('avatar-placeholder.png')
h4.media-heading h4.media-heading
= @volunteer.name = @volunteer.name
hr hr

View File

@ -4,7 +4,6 @@
Екипи: <%= @volunteer.volunteer_teams.map(&:name).join(', ') %> Екипи: <%= @volunteer.volunteer_teams.map(&:name).join(', ') %>
Снимка: <%= attachment_url(@volunteer, :picture, host: "https://#{@volunteer.conference.host_name}/") %>
Език: <%= @volunteer.language %> Език: <%= @volunteer.language %>
Телефон: <%= @volunteer.phone %> Телефон: <%= @volunteer.phone %>
Размер на тениска: <%= @volunteer.tshirt_size %> Размер на тениска: <%= @volunteer.tshirt_size %>

View File

@ -9,7 +9,7 @@ Bundler.require(*Rails.groups)
module Clarion module Clarion
class Application < Rails::Application class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version. # Initialize configuration defaults for originally generated Rails version.
config.load_defaults 5.2 config.load_defaults 7.1
# Please, add to the `ignore` list any other `lib` subdirectories that do # Please, add to the `ignore` list any other `lib` subdirectories that do
# not contain `.rb` files, or that should not be reloaded or eager loaded. # not contain `.rb` files, or that should not be reloaded or eager loaded.

View File

@ -76,4 +76,6 @@ Rails.application.configure do
# Raise error when a before_action's only/except options reference missing actions # Raise error when a before_action's only/except options reference missing actions
config.action_controller.raise_on_missing_callback_actions = true config.action_controller.raise_on_missing_callback_actions = true
config.hosts << "dev.openfest.org:3000"
end end

View File

@ -9,7 +9,7 @@ Rails.application.config.assets.version = "1.0"
Rails.application.config.assets.paths << "lib/initfest/assets/images" Rails.application.config.assets.paths << "lib/initfest/assets/images"
Rails.application.config.assets.paths << "lib/initfest/assets/javascripts" Rails.application.config.assets.paths << "lib/initfest/assets/javascripts"
Rails.application.config.assets.paths << "lib/initfest/assets/stylesheets" Rails.application.config.assets.paths << "lib/initfest/assets/stylesheets"
Rails.application.config.assets.precompile << /\.(?:png|jpg|jpeg|gif)\z/ #Rails.application.config.assets.precompile << /\.(?:png|jpg|jpeg|gif)\z/
# Precompile additional assets. # Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in the app/assets # application.js, application.css, and all non-JS/CSS in the app/assets

View File

@ -34,6 +34,8 @@ bg:
no_comments_received: Все още няма коментари. no_comments_received: Все още няма коментари.
private_email: Личен e-mail private_email: Личен e-mail
events: events:
update:
event_successfully_updated: Събитието беше обновено успешно
show: show:
average_grade: Средна оценка average_grade: Средна оценка
total_feedback_grades: total_feedback_grades:

View File

@ -0,0 +1,57 @@
# This migration comes from active_storage (originally 20170806125915)
class CreateActiveStorageTables < ActiveRecord::Migration[7.0]
def change
# Use Active Record's configured type for primary and foreign keys
primary_key_type, foreign_key_type = primary_and_foreign_key_types
create_table :active_storage_blobs, id: primary_key_type do |t|
t.string :key, null: false
t.string :filename, null: false
t.string :content_type
t.text :metadata
t.string :service_name, null: false
t.bigint :byte_size, null: false
t.string :checksum
if connection.supports_datetime_with_precision?
t.datetime :created_at, precision: 6, null: false
else
t.datetime :created_at, null: false
end
t.index [ :key ], unique: true
end
create_table :active_storage_attachments, id: primary_key_type do |t|
t.string :name, null: false
t.references :record, null: false, polymorphic: true, index: false, type: foreign_key_type
t.references :blob, null: false, type: foreign_key_type
if connection.supports_datetime_with_precision?
t.datetime :created_at, precision: 6, null: false
else
t.datetime :created_at, null: false
end
t.index [ :record_type, :record_id, :name, :blob_id ], name: :index_active_storage_attachments_uniqueness, unique: true
t.foreign_key :active_storage_blobs, column: :blob_id
end
create_table :active_storage_variant_records, id: primary_key_type do |t|
t.belongs_to :blob, null: false, index: false, type: foreign_key_type
t.string :variation_digest, null: false
t.index [ :blob_id, :variation_digest ], name: :index_active_storage_variant_records_uniqueness, unique: true
t.foreign_key :active_storage_blobs, column: :blob_id
end
end
private
def primary_and_foreign_key_types
config = Rails.configuration.generators
setting = config.options[config.orm][:primary_key_type]
primary_key_type = setting || :primary_key
foreign_key_type = setting || :bigint
[primary_key_type, foreign_key_type]
end
end

View File

@ -5,8 +5,10 @@
# #
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first # Mayor.create(name: 'Emanuel', city: cities.first
User.create(email: "foo@example.com", User.create(
password: "123qweASD", email: "foo@example.com",
password_confirmation: "123qweASD", password: "123qweASD",
confirmed_at: Time.current, password_confirmation: "123qweASD",
admin: true) confirmed_at: Time.current,
admin: true
)

View File

@ -13,3 +13,4 @@
//= require jquery //= require jquery
//= require jquery_ujs //= require jquery_ujs
//= require_tree . //= require_tree .
//= require activestorage

View File

@ -3,10 +3,9 @@
.form-inputs .form-inputs
.input .input
= image_tag(@profile.picture.medium.url) if @profile.picture? = image_tag(@profile.picture.variant(resize_to_limit: [150, 150])) if @profile.picture.attached?
= f.input :picture, as: :file, required: true, wrapper: false = f.hidden_field :picture, value: @profile.picture.signed_id if @profile.picture.attached?
= f.input :picture, as: :file, required: true, wrapper: false, input_html: {direct_upload: true}
= f.hidden_field :picture_cache, class: 'image_preview', wrapper: false
= f.input :first_name, autofocus: true = f.input :first_name, autofocus: true
= f.input :last_name = f.input :last_name
= f.input :public_email = f.input :public_email

View File

@ -5,8 +5,8 @@
.form-inputs .form-inputs
.input .input
= attachment_image_tag(@volunteer, :picture, :fill, 150, 150) if @volunteer.picture.present? = image_tag @volunteer.picture.variant(resize_to_limit: [150, 150]) if @volunteer.picture.attached?
= f.input :picture, as: :attachment, direct: true, wrapper: false = f.input :picture, as: :file, direct: true, wrapper: false
= f.input :name, autofocus: true = f.input :name, autofocus: true
= f.input :email = f.input :email
= f.input :phone, input_html: {value: @volunteer.phone.try(:phony_formatted, format: :international)} = f.input :phone, input_html: {value: @volunteer.phone.try(:phony_formatted, format: :international)}

View File

View File

@ -1,5 +0,0 @@
require "rails_helper"
RSpec.describe Volunteership, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@ -103,7 +103,7 @@ module FeatureHelpers
attach_file PersonalProfile.human_attribute_name(:picture), Rails.root.join("spec", "support", "picture.jpg") attach_file PersonalProfile.human_attribute_name(:picture), Rails.root.join("spec", "support", "picture.jpg")
fill_in PersonalProfile.human_attribute_name(:first_name), with: "Foo" fill_in PersonalProfile.human_attribute_name(:first_name), with: "Foo"
fill_in PersonalProfile.human_attribute_name(:last_name), with: "Bar" fill_in PersonalProfile.human_attribute_name(:last_name), with: "Bar"
fill_in PersonalProfile.human_attribute_name(:mobile_phone), with: "+359666666" fill_in PersonalProfile.human_attribute_name(:mobile_phone), with: "+359883123456"
fill_in PersonalProfile.human_attribute_name(:biography), with: "Lorem" fill_in PersonalProfile.human_attribute_name(:biography), with: "Lorem"
click_on I18n.t("helpers.submit.create", model: PersonalProfile.model_name.human) click_on I18n.t("helpers.submit.create", model: PersonalProfile.model_name.human)

View File

@ -1,6 +1,6 @@
RSpec::Matchers.define :have_error_on do |expected| RSpec::Matchers.define :have_error_on do |expected|
match do |actual| match do |actual|
expect(actual).to_not be_valid expect(actual).to_not be_valid
expect(actual.errors.keys).to include expected expect(actual.errors).to have_key expected
end end
end end