adding teacher profiles

This commit is contained in:
2023-01-15 14:52:40 +02:00
parent 45f59f174b
commit 750bd76a7e
21 changed files with 288 additions and 32 deletions

View File

@ -0,0 +1,48 @@
require "test_helper"
class TeachersControllerTest < ActionDispatch::IntegrationTest
setup do
@teacher = teachers(:one)
end
test "should get index" do
get teachers_url
assert_response :success
end
test "should get new" do
get new_teacher_url
assert_response :success
end
test "should create teacher" do
assert_difference("Teacher.count") do
post teachers_url, params: { teacher: { bio: @teacher.bio, member_id: @teacher.member_id, name: @teacher.name, picture: @teacher.picture } }
end
assert_redirected_to teacher_url(Teacher.last)
end
test "should show teacher" do
get teacher_url(@teacher)
assert_response :success
end
test "should get edit" do
get edit_teacher_url(@teacher)
assert_response :success
end
test "should update teacher" do
patch teacher_url(@teacher), params: { teacher: { bio: @teacher.bio, member_id: @teacher.member_id, name: @teacher.name, picture: @teacher.picture } }
assert_redirected_to teacher_url(@teacher)
end
test "should destroy teacher" do
assert_difference("Teacher.count", -1) do
delete teacher_url(@teacher)
end
assert_redirected_to teachers_url
end
end

13
test/fixtures/teachers.yml vendored Normal file
View File

@ -0,0 +1,13 @@
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one:
name: MyString
bio: MyString
picture: MyString
member: one
two:
name: MyString
bio: MyString
picture: MyString
member: two

View File

@ -0,0 +1,7 @@
require "test_helper"
class TeacherTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end

View File

@ -0,0 +1,47 @@
require "application_system_test_case"
class TeachersTest < ApplicationSystemTestCase
setup do
@teacher = teachers(:one)
end
test "visiting the index" do
visit teachers_url
assert_selector "h1", text: "Teachers"
end
test "should create teacher" do
visit teachers_url
click_on "New teacher"
fill_in "Bio", with: @teacher.bio
fill_in "Member", with: @teacher.member_id
fill_in "Name", with: @teacher.name
fill_in "Picture", with: @teacher.picture
click_on "Create Teacher"
assert_text "Teacher was successfully created"
click_on "Back"
end
test "should update Teacher" do
visit teacher_url(@teacher)
click_on "Edit this teacher", match: :first
fill_in "Bio", with: @teacher.bio
fill_in "Member", with: @teacher.member_id
fill_in "Name", with: @teacher.name
fill_in "Picture", with: @teacher.picture
click_on "Update Teacher"
assert_text "Teacher was successfully updated"
click_on "Back"
end
test "should destroy Teacher" do
visit teacher_url(@teacher)
click_on "Destroy this teacher", match: :first
assert_text "Teacher was successfully destroyed"
end
end