refactor: let test produce empty template

This commit is contained in:
Max Hohlfeld 2025-07-09 20:40:51 +02:00
parent 1515f50ed9
commit 28cc3cd9ae
2 changed files with 7 additions and 41 deletions

View File

@ -9,20 +9,8 @@ snapshot_kind: text
<h3 class="title is-3">geplante Veranstaltungen</h3>
<p class="subtitle is-5">in den nächsten 31 Tagen</p>
<div class="panel p-2">
<div class="panel-block is-justify-content-space-between">
<span>
<b>WGT</b> &nbsp; Sonntag, 06.07.2025 10:00 - 20:00
</span>
<a class="button is-small is-link is-light" href="/calendar?date=2025-07-06">
<svg class="icon">
<use href="/static/feather-sprite.svg#calendar" />
</svg>
<span>im Kalender anzeigen</span>
</a>
</div>
<div class="notification">
Keine Veranstaltungen für diesen Zeitraum geplant.
</div>

View File

@ -15,7 +15,11 @@ use brass_db::models::{Assignment, Availability, Event, Role, User};
#[derive(Template)]
#[cfg_attr(not(test), template(path = "overview.html"))]
#[cfg_attr(test, template(path = "overview.html", block = "content"), allow(dead_code))]
#[cfg_attr(
test,
template(path = "overview.html", block = "content"),
allow(dead_code)
)]
struct OverviewTemplate {
user: User,
events: Vec<Event>,
@ -68,9 +72,7 @@ async fn get(
#[cfg(test)]
mod tests {
use actix_http::StatusCode;
use brass_db::models::{Clothing, Event, EventChangeset, Location};
use brass_macros::db_test;
use chrono::Utc;
use crate::utils::test_helper::{
assert_snapshot, test_get, DbTestContext, RequestConfig, ServiceResponseExt,
@ -79,30 +81,6 @@ mod tests {
#[db_test]
fn endpoint_produces_template(context: &DbTestContext) {
let app = context.app().await;
Location::create(&context.db_pool, "Arena Abc", 1)
.await
.unwrap();
Clothing::create(&context.db_pool, "Anzugsordnung")
.await
.unwrap();
let event_changeset = EventChangeset {
time: (
Utc::now().date_naive().and_hms_opt(10, 0, 0).unwrap(),
Utc::now().date_naive().and_hms_opt(20, 0, 0).unwrap(),
),
name: "WGT".to_string(),
location_id: 1,
voluntary_wachhabender: false,
voluntary_fuehrungsassistent: false,
amount_of_posten: 1,
clothing: 1,
note: None,
};
Event::create(&context.db_pool, event_changeset)
.await
.unwrap();
let config = RequestConfig::new("/");
let response = test_get(&context.db_pool, app, &config).await;