Add tests
This commit is contained in:
parent
363dfaa7d3
commit
cdea0e1218
14 changed files with 116 additions and 52 deletions
23
.forgejo/workflows/test.yml
Normal file
23
.forgejo/workflows/test.yml
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
on: [push]
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: docker
|
||||||
|
image: ruby:3.3.4
|
||||||
|
name: Text
|
||||||
|
steps:
|
||||||
|
- name: Cache repository
|
||||||
|
uses: actions/cache@v4
|
||||||
|
id: cache-repository
|
||||||
|
with:
|
||||||
|
path: repository
|
||||||
|
key: ${{ runner.os }}-repository-${{ github.sha }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-repository-
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
path: repository
|
||||||
|
submodules: recursive
|
||||||
|
- run: cd repository
|
||||||
|
- run: bundle install
|
||||||
|
- run: bundle exec rails test
|
||||||
|
|
@ -24,7 +24,7 @@ class ChecklistsController < ApplicationController
|
||||||
@checklist = Checklist.new(checklist_params)
|
@checklist = Checklist.new(checklist_params)
|
||||||
|
|
||||||
if @checklist.save
|
if @checklist.save
|
||||||
redirect_to [:edit, @checklist], notice: 'Checklist was successfully created.'
|
redirect_to @checklist, notice: 'Checklist was successfully created.'
|
||||||
else
|
else
|
||||||
render :new, status: :unprocessable_entity
|
render :new, status: :unprocessable_entity
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -42,8 +42,13 @@ class SuccessCriteriaController < ApplicationController
|
||||||
# DELETE /success_criteria/1
|
# DELETE /success_criteria/1
|
||||||
def destroy
|
def destroy
|
||||||
@success_criterion.destroy!
|
@success_criterion.destroy!
|
||||||
|
respond_to do |format|
|
||||||
|
format.html do
|
||||||
redirect_to success_criteria_url, notice: 'Success criterion was successfully destroyed.', status: :see_other
|
redirect_to success_criteria_url, notice: 'Success criterion was successfully destroyed.', status: :see_other
|
||||||
end
|
end
|
||||||
|
format.turbo_stream
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,4 +10,20 @@ module SuccessCriteriaHelper
|
||||||
'bi bi-question text-warning'
|
'bi bi-question text-warning'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def success_criterion_edit_button(success_criterion, edit_mode)
|
||||||
|
path = if success_criterion.persisted?
|
||||||
|
if edit_mode
|
||||||
|
success_criterion
|
||||||
|
else
|
||||||
|
[:edit,
|
||||||
|
success_criterion]
|
||||||
|
end
|
||||||
|
else
|
||||||
|
success_criterion.element
|
||||||
|
end
|
||||||
|
link_to tag.i(class: 'bi bi-pencil'),
|
||||||
|
path,
|
||||||
|
class: "btn btn-#{edit_mode ? 'link text-warning' : 'link text-secondary'}"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
<td><%= link_to(element.title, url_for(element)) %></td>
|
<td><%= link_to(element.title, url_for(element)) %></td>
|
||||||
|
|
||||||
<td><%= link_to(truncate(strip_tags(element.description_html)), url_for(element)) %></td>
|
<td><%= link_to(truncate(element.description_html&.to_plain_text), url_for(element)) %></td>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
<i class="bi bi-pencil text-warning"></i>
|
<i class="bi bi-pencil text-warning"></i>
|
||||||
<% end %>
|
<% end %>
|
||||||
</h3>
|
</h3>
|
||||||
<%= link_to tag.i(class: "bi bi-#{edit_mode ? "pencil" : "pencil"}"), edit_mode ? success_criterion : [:edit, success_criterion], class: "btn btn-#{edit_mode ? "link text-warning" : "link text-secondary"}" %>
|
<%= success_criterion_edit_button(success_criterion, edit_mode) %>
|
||||||
<div class="flex-fill d-flex justify-content-end">
|
<div class="flex-fill d-flex justify-content-end">
|
||||||
<button class="btn btn-link text-body"
|
<button class="btn btn-link text-body"
|
||||||
data-controller="collapse-chevron-toggler"
|
data-controller="collapse-chevron-toggler"
|
||||||
|
|
|
||||||
1
app/views/success_criteria/destroy.turbo_stream.erb
Normal file
1
app/views/success_criteria/destroy.turbo_stream.erb
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
<%= turbo_stream.delete dom_id(@success_criterion) %>
|
||||||
|
|
@ -27,13 +27,13 @@
|
||||||
|
|
||||||
<td><%= link_to(success_criterion.title, url_for(success_criterion)) %></td>
|
<td><%= link_to(success_criterion.title, url_for(success_criterion)) %></td>
|
||||||
|
|
||||||
<td><%= link_to(truncate(strip_tags(success_criterion.description_html)), url_for(success_criterion)) %></td>
|
<td><%= link_to(truncate(success_criterion.description_html.to_plain_text), url_for(success_criterion)) %></td>
|
||||||
|
|
||||||
<td><%= link_to(success_criterion.level, url_for(success_criterion)) %></td>
|
<td><%= link_to(success_criterion.level, url_for(success_criterion)) %></td>
|
||||||
|
|
||||||
<td><%= link_to(success_criterion.result, url_for(success_criterion)) %></td>
|
<td><%= link_to(success_criterion.result, url_for(success_criterion)) %></td>
|
||||||
|
|
||||||
<td><%= link_to(truncate(strip_tags(success_criterion.comment_html)), url_for(success_criterion)) %></td>
|
<td><%= link_to(truncate(success_criterion.comment_html.to_plain_text), url_for(success_criterion)) %></td>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
||||||
|
|
@ -1,45 +1,49 @@
|
||||||
require "test_helper"
|
require 'test_helper'
|
||||||
|
|
||||||
class ChecklistEntriesControllerTest < ActionDispatch::IntegrationTest
|
class ChecklistEntriesControllerTest < ActionDispatch::IntegrationTest
|
||||||
setup do
|
setup do
|
||||||
@checklist_entry = checklist_entries(:one)
|
@checklist_entry = checklist_entries(:one)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should get index" do
|
test 'should get index' do
|
||||||
get checklist_entries_url
|
get checklist_entries_url
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should get new" do
|
test 'should get new' do
|
||||||
get new_checklist_entry_url
|
get new_checklist_entry_url(checklist_id: @checklist_entry.checklist_id)
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should create checklist_entry" do
|
test 'should create checklist_entry' do
|
||||||
assert_difference("ChecklistEntry.count") do
|
assert_difference('ChecklistEntry.count') do
|
||||||
post checklist_entries_url, params: { checklist_entry: { check_id: @checklist_entry.check_id, checklist_id: @checklist_entry.checklist_id, position: @checklist_entry.position } }
|
post checklist_entries_url,
|
||||||
|
params: { checklist_entry: { check_id: @checklist_entry.check_id, checklist_id: @checklist_entry.checklist_id,
|
||||||
|
position: @checklist_entry.position } }
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_redirected_to checklist_entry_url(ChecklistEntry.last)
|
assert_redirected_to checklist_url(ChecklistEntry.last.checklist)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should show checklist_entry" do
|
test 'should show checklist_entry' do
|
||||||
get checklist_entry_url(@checklist_entry)
|
get checklist_entry_url(@checklist_entry)
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should get edit" do
|
test 'should get edit' do
|
||||||
get edit_checklist_entry_url(@checklist_entry)
|
get edit_checklist_entry_url(@checklist_entry)
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should update checklist_entry" do
|
test 'should update checklist_entry' do
|
||||||
patch checklist_entry_url(@checklist_entry), params: { checklist_entry: { check_id: @checklist_entry.check_id, checklist_id: @checklist_entry.checklist_id, position: @checklist_entry.position } }
|
patch checklist_entry_url(@checklist_entry),
|
||||||
assert_redirected_to checklist_entry_url(@checklist_entry)
|
params: { checklist_entry: { check_id: @checklist_entry.check_id, checklist_id: @checklist_entry.checklist_id,
|
||||||
|
position: @checklist_entry.position } }
|
||||||
|
assert_redirected_to checklist_url(@checklist_entry.checklist)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should destroy checklist_entry" do
|
test 'should destroy checklist_entry' do
|
||||||
assert_difference("ChecklistEntry.count", -1) do
|
assert_difference('ChecklistEntry.count', -1) do
|
||||||
delete checklist_entry_url(@checklist_entry)
|
delete checklist_entry_url(@checklist_entry)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,45 +1,49 @@
|
||||||
require "test_helper"
|
require 'test_helper'
|
||||||
|
|
||||||
class ChecksControllerTest < ActionDispatch::IntegrationTest
|
class ChecksControllerTest < ActionDispatch::IntegrationTest
|
||||||
setup do
|
setup do
|
||||||
@check = checks(:one)
|
@check = checks(:deletable)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should get index" do
|
test 'should get index' do
|
||||||
get checks_url
|
get checks_url
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should get new" do
|
test 'should get new' do
|
||||||
get new_check_url
|
get new_check_url
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should create check" do
|
test 'should create check' do
|
||||||
assert_difference("Check.count") do
|
assert_difference('Check.count') do
|
||||||
post checks_url, params: { check: { level: @check.level, name: @check.name, position: @check.position, success_criterion: @check.success_criterion } }
|
post checks_url,
|
||||||
|
params: { check: { level: @check.level, name: @check.name, position: @check.position,
|
||||||
|
success_criterion: @check.success_criterion } }
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_redirected_to check_url(Check.last)
|
assert_redirected_to check_url(Check.last)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should show check" do
|
test 'should show check' do
|
||||||
get check_url(@check)
|
get check_url(@check)
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should get edit" do
|
test 'should get edit' do
|
||||||
get edit_check_url(@check)
|
get edit_check_url(@check)
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should update check" do
|
test 'should update check' do
|
||||||
patch check_url(@check), params: { check: { level: @check.level, name: @check.name, position: @check.position, success_criterion: @check.success_criterion } }
|
patch check_url(@check),
|
||||||
|
params: { check: { level: @check.level, name: @check.name, position: @check.position,
|
||||||
|
success_criterion: @check.success_criterion } }
|
||||||
assert_redirected_to check_url(@check)
|
assert_redirected_to check_url(@check)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should destroy check" do
|
test 'should destroy check' do
|
||||||
assert_difference("Check.count", -1) do
|
assert_difference('Check.count', -1) do
|
||||||
delete check_url(@check)
|
delete check_url(@check)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,45 +1,50 @@
|
||||||
require "test_helper"
|
require 'test_helper'
|
||||||
|
|
||||||
class ElementsControllerTest < ActionDispatch::IntegrationTest
|
class ElementsControllerTest < ActionDispatch::IntegrationTest
|
||||||
setup do
|
setup do
|
||||||
@element = elements(:one)
|
@element = elements(:one)
|
||||||
|
@checklist = checklists(:one)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should get index" do
|
test 'should get index' do
|
||||||
get elements_url
|
get elements_url
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should get new" do
|
test 'should get new' do
|
||||||
get new_element_url
|
get new_element_url
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should create element" do
|
test 'should create element' do
|
||||||
assert_difference("Element.count") do
|
assert_difference('Element.count') do
|
||||||
post elements_url, params: { element: { description: @element.description, path: @element.path, report_id: @element.report_id, title: @element.title } }
|
post elements_url,
|
||||||
|
params: { element: { description: @element.description, path: @element.path, report_id: @element.report_id,
|
||||||
|
title: @element.title, checklist_id: @checklist.id } }
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_redirected_to element_url(Element.last)
|
assert_redirected_to report_url(Element.last.report)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should show element" do
|
test 'should show element' do
|
||||||
get element_url(@element)
|
get element_url(@element)
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should get edit" do
|
test 'should get edit' do
|
||||||
get edit_element_url(@element)
|
get edit_element_url(@element)
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should update element" do
|
test 'should update element' do
|
||||||
patch element_url(@element), params: { element: { description: @element.description, path: @element.path, report_id: @element.report_id, title: @element.title } }
|
patch element_url(@element),
|
||||||
|
params: { element: { description: @element.description, path: @element.path, report_id: @element.report_id,
|
||||||
|
title: @element.title } }
|
||||||
assert_redirected_to element_url(@element)
|
assert_redirected_to element_url(@element)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should destroy element" do
|
test 'should destroy element' do
|
||||||
assert_difference("Element.count", -1) do
|
assert_difference('Element.count', -1) do
|
||||||
delete element_url(@element)
|
delete element_url(@element)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ require 'test_helper'
|
||||||
|
|
||||||
class HomeControllerTest < ActionDispatch::IntegrationTest
|
class HomeControllerTest < ActionDispatch::IntegrationTest
|
||||||
test 'should get show' do
|
test 'should get show' do
|
||||||
get home_show_url
|
get root_url
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
6
test/fixtures/checks.yml
vendored
6
test/fixtures/checks.yml
vendored
|
|
@ -11,3 +11,9 @@ two:
|
||||||
name: MyString
|
name: MyString
|
||||||
success_criterion: MyText
|
success_criterion: MyText
|
||||||
level: 1
|
level: 1
|
||||||
|
|
||||||
|
deletable:
|
||||||
|
position: MyString
|
||||||
|
name: MyString
|
||||||
|
success_criterion: MyText
|
||||||
|
level: 1
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
require "test_helper"
|
require 'test_helper'
|
||||||
|
|
||||||
class ReportTest < ActiveSupport::TestCase
|
class ReportTest < ActiveSupport::TestCase
|
||||||
# test "the truth" do
|
test 'the truth' do
|
||||||
# assert true
|
assert_not Report.new.valid?
|
||||||
# end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue