summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMarius Peter <marius.peter@tutanota.com>2025-08-29 14:22:37 +0200
committerMarius Peter <marius.peter@tutanota.com>2025-08-29 14:22:37 +0200
commit075665c588989ed0decdfb20d83f32b33eed4639 (patch)
treed9ec78be7338bd51c895b7fb311f081a7c77c45f /test
parent52b044d6a4278c229992404ad5801769c2d13363 (diff)
Properly implement bed and raft management logic.
Diffstat (limited to 'test')
-rw-r--r--test/controllers/beds_controller_test.rb48
-rw-r--r--test/fixtures/beds.yml14
-rw-r--r--test/system/beds_test.rb39
3 files changed, 96 insertions, 5 deletions
diff --git a/test/controllers/beds_controller_test.rb b/test/controllers/beds_controller_test.rb
new file mode 100644
index 0000000..7afd166
--- /dev/null
+++ b/test/controllers/beds_controller_test.rb
@@ -0,0 +1,48 @@
+require "test_helper"
+
+class BedsControllerTest < ActionDispatch::IntegrationTest
+ setup do
+ @bed = beds(:one)
+ end
+
+ test "should get index" do
+ get beds_url
+ assert_response :success
+ end
+
+ test "should get new" do
+ get new_bed_url
+ assert_response :success
+ end
+
+ test "should create bed" do
+ assert_difference("Bed.count") do
+ post beds_url, params: { bed: {} }
+ end
+
+ assert_redirected_to bed_url(Bed.last)
+ end
+
+ test "should show bed" do
+ get bed_url(@bed)
+ assert_response :success
+ end
+
+ test "should get edit" do
+ get edit_bed_url(@bed)
+ assert_response :success
+ end
+
+ test "should update bed" do
+ patch bed_url(@bed), params: { bed: {} }
+ assert_redirected_to bed_url(@bed)
+ end
+
+ test "should destroy bed" do
+ assert_difference("Bed.count", -1) do
+ delete bed_url(@bed)
+ end
+
+ assert_redirected_to beds_url
+ end
+end
diff --git a/test/fixtures/beds.yml b/test/fixtures/beds.yml
index 330db85..d7a3329 100644
--- a/test/fixtures/beds.yml
+++ b/test/fixtures/beds.yml
@@ -1,7 +1,11 @@
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
-one:
- number: 1
-
-two:
- number: 1
+# This model initially had no columns defined. If you add columns to the
+# model remove the "{}" from the fixture names and add the columns immediately
+# below each fixture, per the syntax in the comments below
+#
+one: {}
+# column: value
+#
+two: {}
+# column: value
diff --git a/test/system/beds_test.rb b/test/system/beds_test.rb
new file mode 100644
index 0000000..b5e6a86
--- /dev/null
+++ b/test/system/beds_test.rb
@@ -0,0 +1,39 @@
+require "application_system_test_case"
+
+class BedsTest < ApplicationSystemTestCase
+ setup do
+ @bed = beds(:one)
+ end
+
+ test "visiting the index" do
+ visit beds_url
+ assert_selector "h1", text: "Beds"
+ end
+
+ test "should create bed" do
+ visit beds_url
+ click_on "New bed"
+
+ click_on "Create Bed"
+
+ assert_text "Bed was successfully created"
+ click_on "Back"
+ end
+
+ test "should update Bed" do
+ visit bed_url(@bed)
+ click_on "Edit this bed", match: :first
+
+ click_on "Update Bed"
+
+ assert_text "Bed was successfully updated"
+ click_on "Back"
+ end
+
+ test "should destroy Bed" do
+ visit bed_url(@bed)
+ click_on "Destroy this bed", match: :first
+
+ assert_text "Bed was successfully destroyed"
+ end
+end
Copyright 2019--2025 Marius PETER