-
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.
* Rewrite education tests for activities * Add spec that tests the deleting of activities * Make click_link utilize link text instead of href * Revert unwanted changes in capybara.rb * Fix activity specs to not be flaky anymore * Move code to savely open person_relation create field to helper method and use helper method in specs * Rewrite logic to open person relation new form and move code to open person relation edit form to helper method * add default structure * add structure of old project view and edit * add tests for projects * clean up rebase * use same edit method --------- Co-authored-by: Jannik Pulfer <[email protected]> Co-authored-by: Yanick Minder <[email protected]>
- Loading branch information
1 parent
bf5f200
commit bdce658
Showing
8 changed files
with
195 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# frozen_string_literal: true | ||
|
||
class ProjectsController < People::PersonRelationsController | ||
self.permitted_attrs = %i[description title role technology | ||
month_from year_from month_to year_to 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,11 @@ | ||
= form_with model: ([entry.person, entry]) do |f| | ||
= render('people/person_relations/form', form: f) do | ||
- content_for :input do | ||
= t "activerecord.attributes.project.title" | ||
= f.text_field :title, placeholder: "Title", class: "form-control w-100" | ||
= t "activerecord.attributes.project.description" | ||
= f.text_area :description, placeholder: "Description", class: "form-control w-100" | ||
= t "activerecord.attributes.project.technology" | ||
= f.text_area :technology, placeholder: "Description", class: "form-control w-100" | ||
= t "activerecord.attributes.project.role" | ||
= f.text_area :role, placeholder: "Description", 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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
%div.border-top | ||
%turbo-frame{id: dom_id(project)} | ||
= link_to edit_person_project_path(project.person, project), data:{turbo_prefetch: :false, turbo_frame: dom_id(project)}, class: "text-decoration-none text-dark bg-hover-gray d-block" do | ||
%div.border.border-secondary-subtle.border-1.d-flex.flex-column | ||
%div.profile-header.mw-100.border-bottom | ||
= "#{date_range_label project} | #{project.title}" | ||
%div.d-flex.flex-column.ms-5.mt-3.mb-3 | ||
%div.d-flex.gap-1.flex-column | ||
%div.row | ||
%span.fw-bold.col-12.col-lg-2 | ||
= t "activerecord.attributes.project.description" | ||
%span.col | ||
= project.description | ||
%div.row | ||
%span.fw-bold.col-12.col-lg-2 | ||
= t "activerecord.attributes.project.role" | ||
%span.col | ||
= project.role | ||
%div.row | ||
%span.fw-bold.col-12.col-lg-2 | ||
= t "activerecord.attributes.project.technology" | ||
%span.col | ||
= project.technology |
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 |
---|---|---|
|
@@ -4,6 +4,7 @@ en: | |
cancel: Cancel | ||
delete: Delete | ||
save-and-new: Save & new | ||
edit: Edit | ||
skills: | ||
table: | ||
skill: Skill | ||
|
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,142 @@ | ||
require 'rails_helper' | ||
|
||
describe 'Projects', 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#project') do | ||
person.projects.each do |project| | ||
expect(page).to have_content(project.role) | ||
expect(page).to have_content(project.description) | ||
expect(page).to have_content(project.title) | ||
expect(page).to have_content(project.technology) | ||
end | ||
end | ||
end | ||
|
||
it 'creates and saves new project' do | ||
role = 'Pressure-washer dealer' | ||
description = 'Deals with pressure-washers' | ||
title = 'new title' | ||
technology = 'This technology' | ||
|
||
open_create_form(Project) | ||
|
||
within('turbo-frame#new_project') do | ||
select '2024', from: 'project_year_from' | ||
fill_in 'project_role', with: role | ||
fill_in 'project_description', with: description | ||
fill_in 'project_title', with: title | ||
fill_in 'project_technology', with: technology | ||
click_default_submit | ||
end | ||
|
||
|
||
expect(page).to have_content(role) | ||
expect(page).to have_content(description) | ||
expect(page).to have_content(title) | ||
expect(page).to have_content(technology) | ||
end | ||
|
||
it 'Create new with save & new' do | ||
role = "This is a new project with a role created by the save & new functionality" | ||
description = "This is a new project with a description created by the save & new functionality" | ||
title = "This is a new project with a title created by the save & new functionality" | ||
technology = "This is a new project with a technology created by the save & new functionality" | ||
|
||
open_create_form(Project) | ||
|
||
within('turbo-frame#new_project') do | ||
fill_in 'project_role', with: role | ||
fill_in 'project_description', with: description | ||
fill_in 'project_title', with: title | ||
fill_in 'project_technology', with: technology | ||
select 'Januar', from: 'project_month_from' | ||
select '2020', from: 'project_year_from' | ||
|
||
click_save_and_new_submit | ||
end | ||
expect(page).to have_content(role) | ||
expect(page).to have_content(description) | ||
expect(page).to have_content(title) | ||
expect(page).to have_content(technology) | ||
|
||
expect(page).to have_select('project_year_from', selected: "") | ||
expect(page).to have_select('project_month_from', selected: "-") | ||
expect(page).to have_field('project_role', with: "") | ||
expect(page).to have_field('project_description', with: "") | ||
expect(page).to have_field('project_title', with: "") | ||
expect(page).to have_field('project_technology', with: "") | ||
end | ||
|
||
it 'updates project' do | ||
updated_description = 'I am an updated description' | ||
project = person.projects.first | ||
|
||
open_edit_form(project) | ||
within("turbo-frame##{dom_id project}") do | ||
fill_in 'project_description', with: updated_description | ||
click_default_submit | ||
end | ||
expect(page).to have_content(updated_description) | ||
end | ||
|
||
it 'cancels without saving' do | ||
project = person.projects.first | ||
old_description = project.description | ||
updated_description = 'I like long descriptions' | ||
|
||
open_edit_form(project) | ||
within("turbo-frame##{dom_id project}") do | ||
fill_in 'project_description', with: updated_description | ||
find('a', text: 'Abbrechen').click | ||
end | ||
expect(page).to have_content(old_description) | ||
end | ||
|
||
it 'deletes project' do | ||
project = person.projects.first | ||
role = project.role | ||
open_edit_form(project) | ||
within("turbo-frame##{dom_id project}") do | ||
click_link("Löschen") | ||
end | ||
expect(page).not_to have_content(role) | ||
end | ||
end | ||
|
||
describe 'Error handling' do | ||
it 'create new project without role' do | ||
open_create_form(Project) | ||
|
||
within("turbo-frame##{dom_id Project.new}") do | ||
click_default_submit | ||
end | ||
expect(page).to have_css(".alert.alert-danger", text: "Rolle und Aufgaben muss ausgefüllt werden") | ||
end | ||
|
||
it 'Update entry and clear role' do | ||
project = person.projects.first | ||
open_edit_form(project) | ||
within("turbo-frame#project_#{project.id}") do | ||
fill_in 'project_role', with: "" | ||
click_default_submit | ||
end | ||
expect(page).to have_css(".alert.alert-danger", text: "Rolle und Aufgaben 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 |