Skip to content
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

Resume preview #773

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions app/controllers/web/account/resumes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,17 @@ def update

def destroy; end

def preview
@resume = current_user.resumes.find(params[:id])
@resume_educations = @resume.educations.web
@resume_works = @resume.works.web
if @resume.draft?
render :preview
else
redirect_to account_resumes_path, alert: t('.not_accessible')
end
end

private

def change_state(resume)
Expand Down
3 changes: 3 additions & 0 deletions app/views/web/account/resumes/index.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
span.ms-3
= link_to edit_account_resume_path(resume) do
span.bi.bi-pencil-square.text-muted
span.ms-3
= link_to preview_account_resume_path(resume) do
span.bi.bi-eye-fill.text-muted
.card-body
h5.card-title
= link_to_unless resume.draft?, resume, resume_path(resume)
Expand Down
28 changes: 28 additions & 0 deletions app/views/web/account/resumes/preview.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
= content_for :meta do
= structured_data_tag 'resume',
resume: @resume, educations: @resume_educations, works: @resume_works

= content_for :header do
.d-flex.justify-content-center
.m-1
= link_to @resume.user.full_name, user_path(@resume.user)
- if current_user_or_guest.admin?
.m-1
= link_to edit_admin_resume_path(@resume), class: 'btn btn-outline-primary' do
span.bi.bi-gear

h3.text-center = @resume

- if @resume.archived?
.alert.alert-warning = t('.archived')

- if policy(@resume).download?
.mb-2.d-flex.justify-content-end
= link_to resume_pdf_path(@resume, 'base', format: :pdf),
class: 'me-3', title: t('web.resumes.show.print'), target: :_blank, rel: 'noopener' do
i.bi.bi-printer-fill
= link_to resume_pdf_path(@resume, 'base'), title: t('web.resumes.show.download') do
i.bi.bi-download

.mb-5
= render 'web/resumes/information'
2 changes: 2 additions & 0 deletions config/locales/ru.views.yml
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,8 @@ ru:
header: Редактирование резюме
index:
header: Мои резюме
preview:
not_accessible: Нет Доступа
profiles:
form:
info_for_user: Давайте познакомимся =). Заполните, пожалуйста, фамилию, имя и можете рассказать немного о себе.
Expand Down
6 changes: 5 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,15 @@
end

namespace :account do
resources :resumes
resources :vacancies
resources :notifications, only: %i[index update]
resource :newsletters, only: %i[edit update]
resource :profile, only: %i[edit update destroy]
resources :resumes do
member do
get :preview
end
end
scope module: :careers do
resources :members, only: %i[index]
end
Expand Down
17 changes: 17 additions & 0 deletions test/controllers/web/account/resumes_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
class Web::Account::ResumesControllerTest < ActionDispatch::IntegrationTest
setup do
@user = users(:one)
@other_user = users(:two)
sign_in(@user)
@draft_resume = resumes(:one_draft)
end

test '#index' do
Expand Down Expand Up @@ -190,4 +192,19 @@ class Web::Account::ResumesControllerTest < ActionDispatch::IntegrationTest
resume = Resume.find_by(name: attrs[:name])
assert { !resume }
end

test '#preview for draft resume' do
get preview_account_resume_path(@draft_resume)
assert_response :success
assert_select 'h1', @user.full_name
assert_select 'h3', @draft_resume.name
end

test '#preview for resume not owned by user' do
sign_out(@user)
sign_in(@other_user)
assert_raises ActiveRecord::RecordNotFound do
get preview_account_resume_path(@draft_resume)
end
end
end
6 changes: 6 additions & 0 deletions test/fixtures/resumes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,9 @@ full_en:
summary: |
A self-taught programmer who has chosen the path of constant self-improvement. I value beautiful and concise code, I love functional programming (the great trinity of map, filter, reduce). I work with languages ​​such as JS, Ruby, PHP, Python, Elixir, Clojure (to varying degrees of skill, of course). I admire the LISP family of languages, so much so that I am writing my own LISP interpreter in Elixir as a pet project. At the moment, I am delving into Unix OS in order to further improve my DevOps skills.
answers_count: 1

one_draft:
<<: *DEFAULTS
state: draft
user: one
contact_email: [email protected]
Loading