From 075665c588989ed0decdfb20d83f32b33eed4639 Mon Sep 17 00:00:00 2001 From: Marius Peter Date: Fri, 29 Aug 2025 14:22:37 +0200 Subject: Properly implement bed and raft management logic. --- test/controllers/beds_controller_test.rb | 48 ++++++++++++++++++++++++++++++++ test/fixtures/beds.yml | 14 ++++++---- test/system/beds_test.rb | 39 ++++++++++++++++++++++++++ 3 files changed, 96 insertions(+), 5 deletions(-) create mode 100644 test/controllers/beds_controller_test.rb create mode 100644 test/system/beds_test.rb (limited to 'test') 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 -- cgit v1.2.3