-
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.
TESTING Feature/590 add skill (#611)
* start adding simple create test * add capybara tests * add controller test for create * specify exact controller in api/skillsController test * implemnt review * fix tests * start adding simple create test * add capybara tests * add controller test for create * implemnt review * fix tests * fix tests * fix rebase * fix tests * remove accidently added files * clean up --------- Co-authored-by: Yanick Minder <[email protected]>
- Loading branch information
1 parent
8233202
commit 3f6c69b
Showing
5 changed files
with
76 additions
and
1 deletion.
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
File renamed without changes.
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,19 +1,46 @@ | ||
require 'rails_helper' | ||
|
||
describe SkillsController do | ||
describe 'Update Skill' do | ||
describe 'SkillsController as user' do | ||
|
||
before(:each) do | ||
load_pictures | ||
sign_in(auth_users(:admin)) | ||
end | ||
render_views | ||
|
||
|
||
let(:edited_skill) { {"id" => skills(:rails).id, "category_parent" => categories('system-engineering').id, | ||
"title" => "UpdatedSkill", "radar" => "adopt", "portfolio" => "passiv", "default_set" => false, | ||
"category_id" => categories(:ruby).id} } | ||
let(:bob) { people(:bob) } | ||
|
||
|
||
it 'index returns all skills ' do | ||
get :index | ||
skills = assigns(:skills) | ||
expect(skills.sort).to eq skills().sort | ||
expect(response).to render_template("index") | ||
end | ||
|
||
it 'should switch category' do | ||
patch :update, params: {id: edited_skill["id"], skill: edited_skill, validate_only: true} | ||
expect(response.body).to have_select("skill_category_id", with_options: ['Linux-Engineering']) | ||
end | ||
|
||
it 'post returns all skills ' do | ||
title = 'new skill' | ||
category_id = categories(:java).id | ||
radar = "hold" | ||
portfolio = "passiv" | ||
|
||
post :create , params: { skill: { title: title, category_id: category_id, radar: radar, portfolio: portfolio} } | ||
skill = assigns(:skill) | ||
expect(skill.title).to eq title | ||
expect(skill.category_id).to eq category_id | ||
expect(skill.radar).to eq radar | ||
expect(skill.portfolio).to eq portfolio | ||
expect(response).to redirect_to(skills_path) | ||
end | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
require 'rails_helper' | ||
|
||
|
||
describe 'Skill Form', type: :feature, js:true do | ||
|
||
before(:each) do | ||
sign_in auth_users(:admin), scope: :auth_user | ||
visit skills_path | ||
click_link(href: new_skill_path) | ||
@category = categories(:ruby) | ||
@radar = "hold" | ||
@portfolio = "passiv" | ||
end | ||
|
||
it 'creates the skill when the form is submitted' do | ||
fill_in 'skill_title', with: 'New Skill Title' | ||
select @category.title, from: 'skill_category_id' | ||
select @radar, from: 'skill_radar' | ||
select @portfolio, from: 'skill_portfolio' | ||
click_button 'Skill erstellen' | ||
# Check for the skill names instead of the amount | ||
expect(page).to have_content('Bash') | ||
expect(page).to have_content('cunit') | ||
expect(page).to have_content('ember') | ||
expect(page).to have_content('JUnit') | ||
expect(page).to have_content('Rails') | ||
expect(page).to have_content('New Skill Title') | ||
end | ||
|
||
it 'displays error messages when present' do | ||
fill_in 'skill_title', with: '' | ||
click_button 'Skill erstellen' | ||
|
||
expect(page).to have_css('.alert.alert-danger') | ||
end | ||
|
||
it 'redirects to the skills index when the cancel button is clicked' do | ||
click_link(href:skills_path, text: "Cancel") | ||
all 'turbo-frame[id^="skill"]', count: 5 | ||
end | ||
end |