-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve resume skills description #744
base: main
Are you sure you want to change the base?
Changes from all commits
f681ca3
9e3c30c
71c04a4
7fe539e
70930d2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,32 +4,33 @@ | |
# | ||
# Table name: resumes | ||
# | ||
# id :integer not null, primary key | ||
# about_myself :text | ||
# answers_count :integer default(0), not null | ||
# awards_description :text | ||
# city :string | ||
# contact :string | ||
# contact_email :string | ||
# contact_phone :string | ||
# contact_telegram :string | ||
# english_fluency :string | ||
# evaluated_ai :boolean | ||
# evaluated_ai_state :string | ||
# github_url :string | ||
# hexlet_url :string | ||
# impressions_count :integer default(0) | ||
# locale :string | ||
# name :string not null | ||
# projects_description :text | ||
# relocation :string | ||
# skills_description :text | ||
# state :string | ||
# summary :text | ||
# url :string | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# user_id :integer not null | ||
# id :integer not null, primary key | ||
# about_myself :text | ||
# answers_count :integer default(0), not null | ||
# awards_description :text | ||
# city :string | ||
# contact :string | ||
# contact_email :string | ||
# contact_phone :string | ||
# contact_telegram :string | ||
# english_fluency :string | ||
# evaluated_ai :boolean | ||
# evaluated_ai_state :string | ||
# github_url :string | ||
# hexlet_url :string | ||
# impressions_count :integer default(0) | ||
# locale :string | ||
# name :string not null | ||
# projects_description :text | ||
# relocation :string | ||
# skills_description :text(250) | ||
# skills_description_old :text | ||
# state :string | ||
# summary :text | ||
# url :string | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# user_id :integer not null | ||
# | ||
# Indexes | ||
# | ||
|
@@ -43,6 +44,7 @@ class Resume < ApplicationRecord | |
include StateConcern | ||
extend Enumerize | ||
extend TagResumePresenter | ||
include ResumePresenter | ||
|
||
mark_as_outdated :hexlet_url, :awards_description | ||
|
||
|
@@ -58,10 +60,11 @@ class Resume < ApplicationRecord | |
validates :name, presence: true | ||
validates :github_url, presence: true, unless: :draft? | ||
validates :summary, length: { minimum: 200 }, presence: true, unless: :draft? | ||
validates :skills_description, presence: true, unless: :draft? | ||
validates :skills_description, length: { maximum: 250 }, presence: true, unless: :draft? | ||
eKulshan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
validates :contact_email, presence: true, unless: :draft? | ||
validates :contact_email, 'valid_email_2/email': true | ||
validates :contact_phone, phone: true | ||
validate :skills_description_valid_format, unless: :draft? | ||
|
||
belongs_to :user | ||
has_many :answers, inverse_of: :resume, dependent: :destroy | ||
|
@@ -128,6 +131,12 @@ def initialize(attribute = nil) | |
super(attrs_with_defaults) | ||
end | ||
|
||
def skills_description_valid_format | ||
return unless skills.size > 10 || skills.any? { |element| element.size > 25 } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. почему или, должно же быть и - длинна скила не больше 25 и не больше 10 скилов |
||
|
||
errors.add(:skills_description) | ||
end | ||
|
||
def to_s | ||
name | ||
end | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
module ResumePresenter | ||
def skills | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. У модели резюме уже есть метод skills, через который работает гем ActsAsTaggableOn, тут ты его переопределил, нужно выбрать другое имя метода |
||
skills_description&.split("\n") || [] | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class UpdateResumeSkillDescription < ActiveRecord::Migration[7.0] | ||
def change | ||
rename_column :resumes, :skills_description, :skills_description_old | ||
add_column :resumes, :skills_description, :text | ||
end | ||
eKulshan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
# | ||
# It's strongly recommended that you check this file into your version control system. | ||
|
||
ActiveRecord::Schema[7.0].define(version: 2024_01_19_100332) do | ||
ActiveRecord::Schema[7.0].define(version: 2024_05_08_043924) do | ||
create_table "career_items", force: :cascade do |t| | ||
t.integer "order" | ||
t.integer "career_id", null: false | ||
|
@@ -215,7 +215,7 @@ | |
t.datetime "updated_at", null: false | ||
t.string "url" | ||
t.text "summary" | ||
t.text "skills_description" | ||
t.text "skills_description_old" | ||
t.string "github_url" | ||
t.text "awards_description" | ||
t.string "english_fluency" | ||
|
@@ -233,6 +233,7 @@ | |
t.string "evaluated_ai_state" | ||
t.text "projects_description" | ||
t.text "about_myself" | ||
t.text "skills_description", limit: 250 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. прогони плиз еще раз миграцию, в схеме осталась валидация на длину на уровне базы |
||
t.index ["user_id"], name: "index_resumes_on_user_id" | ||
end | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -190,4 +190,28 @@ class Web::Account::ResumesControllerTest < ActionDispatch::IntegrationTest | |
resume = Resume.find_by(name: attrs[:name]) | ||
assert { !resume } | ||
end | ||
|
||
test '#create fail with invalid skills_description format' do | ||
attrs = FactoryBot.attributes_for :resume | ||
attrs[:skills_description] = "Too_many_skills\n" * 15 | ||
|
||
params = { | ||
publish: true, | ||
resume: attrs | ||
} | ||
|
||
post(account_resumes_path, params:) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. в параметры добавь пожалуйста locale, что бы тест прогонялся для двух локалей post account_resumes_path, params:, locale: I18n.locale |
||
assert_response :unprocessable_entity | ||
|
||
resume = Resume.find_by(name: attrs[:name]) | ||
assert { !resume } | ||
|
||
attrs[:skills_description] = 'Invalid_skill_lenght' * 2 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Если тестируешь два разных кейса то лучше разделить на два теста |
||
|
||
post(account_resumes_path, params:) | ||
assert_response :unprocessable_entity | ||
|
||
resume = Resume.find_by(name: attrs[:name]) | ||
assert { !resume } | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Вроде в задачу не входило добавление гемов)