-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* readd base functionallity * fix styling of educations * add translations * add test * fix advanced trainings tests after changing translations * resolve bug for not refreshing after create * resolve error for error displaying * fix error in features/educations_spec * use helper instead of implement logic in view --------- Co-authored-by: Yanick Minder <[email protected]>
- Loading branch information
1 parent
eb2c213
commit c37f048
Showing
11 changed files
with
145 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
class EducationsController < People::PersonRelationsController | ||
self.permitted_attrs = %i[location title month_to year_to month_from year_from person_id] | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
%div.border-top | ||
%turbo-frame{id: dom_id(education)} | ||
= link_to edit_person_education_path(@person, education), data:{turbo_prefetch: :false}, class: "text-decoration-none text-dark bg-hover-gray d-block" do | ||
%div.d-flex.row.pt-3.pb-5 | ||
%span.col-3.ps-5 | ||
= date_range_label education | ||
%span.col.d-flex.flex-column | ||
%span.fw-bolder | ||
= education.title | ||
= education.location |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
= form_with model: ([entry.person, entry]) do |f| | ||
= render('people/person_relations/form', form: f) do | ||
- content_for :input do | ||
= t "activerecord.attributes.education.title" | ||
= f.text_area :title, placeholder: "Description", class: "form-control w-100" | ||
= t "activerecord.attributes.education.location" | ||
= f.text_area :location, placeholder: "Ein Ausbildungsort", class: "form-control w-100" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
= render('profile') | ||
= render('core_competences') | ||
= render('people/person_relations/index', list: @person.advanced_trainings) | ||
= render('people/person_relations/index', list: @person.advanced_trainings.list) | ||
= render('people/person_relations/index', list: @person.educations.list) |
4 changes: 4 additions & 0 deletions
4
app/views/people/person_relations/refresh_after_new.turbo_stream.haml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
= turbo_stream.remove dom_id(entry.class.new) | ||
|
||
= turbo_stream.update name_of_obj(entry) do | ||
= render entries |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
require 'rails_helper' | ||
|
||
describe 'Educations', type: :feature, js:true do | ||
let(:person) { people(:bob) } | ||
|
||
before(:each) do | ||
sign_in auth_users(:admin) | ||
visit person_path(person) | ||
end | ||
|
||
describe 'Crud actions' do | ||
it 'shows all' do | ||
within('turbo-frame#education') do | ||
person.educations.each do |education| | ||
expect(page).to have_content(education.title) | ||
expect(page).to have_content(education.location) | ||
end | ||
end | ||
end | ||
|
||
it 'creates and saves new education' do | ||
title = 'Döner-Verkäufer' | ||
new_location = 'Dönerbude' | ||
|
||
click_link(href: new_person_education_path(person)) | ||
|
||
within('turbo-frame#new_education') do | ||
select '2024', from: 'education_year_from' | ||
fill_in 'education_title', with: title | ||
fill_in 'education_location', with: new_location | ||
click_default_submit | ||
end | ||
|
||
expect(page).to have_content(title) | ||
expect(page).to have_content(new_location) | ||
end | ||
|
||
it 'updates education' do | ||
updated_location = 'Dönerbude des Vertrauens' | ||
|
||
education = person.educations.first | ||
within("turbo-frame#education_#{education.id}") do | ||
find("[href=\"#{edit_person_education_path(person, education)}\"]").all("*").first.click | ||
fill_in 'education_location', with: updated_location | ||
click_default_submit | ||
end | ||
expect(page).to have_content(updated_location) | ||
end | ||
|
||
it 'cancels without saving' do | ||
education = person.educations.first | ||
old_location = education.location | ||
updated_location = 'Dönerbude des Vertrauens' | ||
|
||
within("turbo-frame#education_#{education.id}") do | ||
find("[href=\"#{edit_person_education_path(person, education)}\"]").all("*").first.click | ||
fill_in 'education_location', with: updated_location | ||
find('a', text: 'Abbrechen').click | ||
end | ||
expect(person.educations.first.location).to eq(old_location) | ||
end | ||
end | ||
|
||
describe 'Error handling' do | ||
it 'create new education without title and location' do | ||
click_link(href: new_person_education_path(person)) | ||
|
||
within('turbo-frame#new_education') do | ||
click_default_submit | ||
end | ||
expect(page).to have_css(".alert.alert-danger", text: "Ausbildung muss ausgefüllt werden") | ||
expect(page).to have_css(".alert.alert-danger", text: "Ausbildungsort muss ausgefüllt werden") | ||
end | ||
|
||
it 'Update entry and clear title & description' do | ||
education = person.educations.first | ||
within("turbo-frame#education_#{education.id}") do | ||
find("[href=\"#{edit_person_education_path(person, education)}\"]").all("*").first.click | ||
fill_in 'education_title', with: "" | ||
fill_in 'education_location', with: "" | ||
click_default_submit | ||
end | ||
expect(page).to have_css(".alert.alert-danger", text: "Ausbildung muss ausgefüllt werden") | ||
expect(page).to have_css(".alert.alert-danger", text: "Ausbildungsort muss ausgefüllt werden") | ||
end | ||
end | ||
|
||
def click_default_submit | ||
find("button[type='submit'][name='save']").click | ||
end | ||
|
||
def click_save_and_new_submit | ||
find("button[type='submit'][name='render_new_after_save']").click | ||
end | ||
end |