From fb7411e1630162dcc6d4f7ba09e7e48f8408cbd2 Mon Sep 17 00:00:00 2001 From: Dwight Watson Date: Mon, 5 Feb 2024 10:39:38 +1100 Subject: [PATCH] Add PagesControllerTest with authentication (#288) * Add PagesControllerTest with authentication * Rubocop fixes * Move sign_in to setup block * Remove instance variable --- test/controllers/pages_controller_test.rb | 12 ++++++++++++ test/test_helper.rb | 3 +++ 2 files changed, 15 insertions(+) create mode 100644 test/controllers/pages_controller_test.rb diff --git a/test/controllers/pages_controller_test.rb b/test/controllers/pages_controller_test.rb new file mode 100644 index 00000000..5083248e --- /dev/null +++ b/test/controllers/pages_controller_test.rb @@ -0,0 +1,12 @@ +require "test_helper" + +class PagesControllerTest < ActionDispatch::IntegrationTest + setup do + sign_in users(:bob) + end + + test "dashboard" do + get root_path + assert_response :ok + end +end diff --git a/test/test_helper.rb b/test/test_helper.rb index 0c22470e..118dc97e 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -11,5 +11,8 @@ module ActiveSupport fixtures :all # Add more helper methods to be used by all tests here... + def sign_in(user) + post session_path, params: { email: user.email, password: "password" } + end end end