Added projects
This commit is contained in:
parent
0964187f22
commit
8b4ffb83ec
37 changed files with 470 additions and 1935 deletions
55
test/controllers/projects_controller_test.rb
Normal file
55
test/controllers/projects_controller_test.rb
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
require "test_helper"
|
||||
|
||||
class ProjectsControllerTest < ::ControllerTest
|
||||
teardown do
|
||||
logout
|
||||
end
|
||||
|
||||
setup do
|
||||
@project = projects(:one)
|
||||
User.create!(email_address: "test@example.com", password: "password")
|
||||
login("test@example.com", "password")
|
||||
end
|
||||
|
||||
test "should get index" do
|
||||
get projects_url
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get new" do
|
||||
get new_project_url
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should create project" do
|
||||
assert_difference("Project.count") do
|
||||
post projects_url, params: { project: { name: @project.name } }
|
||||
end
|
||||
|
||||
assert_redirected_to project_url(Project.last)
|
||||
end
|
||||
|
||||
test "should show project" do
|
||||
get project_url(@project)
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get edit" do
|
||||
get edit_project_url(@project)
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should update project" do
|
||||
patch project_url(@project), params: { project: { name: @project.name } }
|
||||
assert_redirected_to project_url(@project)
|
||||
end
|
||||
|
||||
test "should destroy project" do
|
||||
p = Project.create!(name: "empty")
|
||||
assert_difference("Project.count", -1) do
|
||||
delete project_url(p)
|
||||
end
|
||||
|
||||
assert_redirected_to projects_url
|
||||
end
|
||||
end
|
||||
|
|
@ -14,18 +14,18 @@ class ReportsControllerTest < ::ControllerTest
|
|||
end
|
||||
|
||||
test "should get index" do
|
||||
get reports_url
|
||||
get project_reports_url(@report.project)
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get new" do
|
||||
get new_report_url
|
||||
get new_project_report_url(@report.project)
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should create report" do
|
||||
assert_difference("Report.count") do
|
||||
post reports_url, params: { report: { comment: @report.comment, name: @report.name } }
|
||||
post project_reports_url(@report.project), params: { report: { comment: @report.comment, name: @report.name } }
|
||||
end
|
||||
|
||||
assert_redirected_to report_url(Report.last)
|
||||
|
|
@ -51,6 +51,6 @@ class ReportsControllerTest < ::ControllerTest
|
|||
delete report_url(@report)
|
||||
end
|
||||
|
||||
assert_redirected_to reports_url
|
||||
assert_redirected_to project_url(@report.project)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
7
test/fixtures/projects.yml
vendored
Normal file
7
test/fixtures/projects.yml
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
name: MyString
|
||||
|
||||
two:
|
||||
name: MyString
|
||||
2
test/fixtures/reports.yml
vendored
2
test/fixtures/reports.yml
vendored
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
one:
|
||||
name: MyString
|
||||
project: one
|
||||
|
||||
two:
|
||||
name: MyString
|
||||
project: one
|
||||
|
|
|
|||
7
test/models/project_test.rb
Normal file
7
test/models/project_test.rb
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
require "test_helper"
|
||||
|
||||
class ProjectTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
||||
47
test/system/projects_test.rb
Normal file
47
test/system/projects_test.rb
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
require "application_system_test_case"
|
||||
|
||||
class ProjectsTest < ApplicationSystemTestCase
|
||||
setup do
|
||||
@project = projects(:one)
|
||||
login_test
|
||||
end
|
||||
|
||||
teardown do
|
||||
logout
|
||||
end
|
||||
|
||||
test "visiting the index" do
|
||||
visit projects_url
|
||||
assert_selector "h1", text: "Projekte"
|
||||
end
|
||||
|
||||
test "should create project" do
|
||||
visit projects_url
|
||||
click_on "Projekt hinzufügen"
|
||||
|
||||
fill_in "Name", with: @project.name
|
||||
click_on "Projekt erstellen"
|
||||
|
||||
assert_text "Project was successfully created"
|
||||
click_on "Projekte Liste"
|
||||
end
|
||||
|
||||
test "should update Project" do
|
||||
visit project_url(@project)
|
||||
click_on "Projekt bearbeiten", match: :first
|
||||
|
||||
fill_in "Name", with: @project.name
|
||||
click_on "Projekt aktualisieren"
|
||||
|
||||
assert_text "Project was successfully updated"
|
||||
click_on "Projekte Liste"
|
||||
end
|
||||
|
||||
test "should destroy Project" do
|
||||
empty = Project.create!(name: "empty")
|
||||
visit project_url(empty)
|
||||
click_on "Projekt löschen", match: :first
|
||||
|
||||
assert_text "Project was successfully destroyed"
|
||||
end
|
||||
end
|
||||
|
|
@ -13,12 +13,12 @@ class ReportsTest < ApplicationSystemTestCase
|
|||
end
|
||||
|
||||
test "visiting the index" do
|
||||
visit reports_url
|
||||
visit project_reports_url(@report.project)
|
||||
assert_selector "h1", text: "Prüfberichte"
|
||||
end
|
||||
|
||||
test "should create report" do
|
||||
visit reports_url
|
||||
visit project_reports_url(@report.project)
|
||||
click_on "Prüfbericht hinzufügen"
|
||||
|
||||
fill_in_rich_text_area "Projektbeschreibung", with: @report.comment
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue