Configure tests and helpers for current backend state
This commit is contained in:
parent
471440804c
commit
4edae5e7bb
9 changed files with 85 additions and 11 deletions
2
app/helpers/sessions_helper.rb
Normal file
2
app/helpers/sessions_helper.rb
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
module SessionsHelper
|
||||
end
|
||||
2
app/helpers/users_helper.rb
Normal file
2
app/helpers/users_helper.rb
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
module UsersHelper
|
||||
end
|
||||
19
test/controllers/sessions_controller_test.rb
Normal file
19
test/controllers/sessions_controller_test.rb
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
require "test_helper"
|
||||
|
||||
class SessionsControllerTest < ActionDispatch::IntegrationTest
|
||||
test "should get new" do
|
||||
get new_sessions_path
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get create" do
|
||||
post sessions_path, params: { email: "test@email.com", password: "testpassword" }
|
||||
assert_redirected_to root_path
|
||||
end
|
||||
|
||||
test "should get destroy" do
|
||||
post sessions_path, params: { email: "test@email.com", password: "testpassword" }
|
||||
delete sessions_path
|
||||
assert_redirected_to root_path
|
||||
end
|
||||
end
|
||||
|
|
@ -1,23 +1,21 @@
|
|||
require "test_helper"
|
||||
include ActiveJob::TestHelper
|
||||
|
||||
class Test::ImagesControllerTest < ActionDispatch::IntegrationTest
|
||||
test "should get index" do
|
||||
get test_images_index_url
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get new" do
|
||||
get test_images_new_url
|
||||
get test_images_path
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get create" do
|
||||
get test_images_create_url
|
||||
assert_response :success
|
||||
file = fixture_file_upload("test_image.jpg", "image/jpeg")
|
||||
post test_images_path, params: { image: { file: file, title: "test" } }
|
||||
assert_redirected_to test_images_path
|
||||
end
|
||||
|
||||
test "should get show" do
|
||||
get test_images_show_url
|
||||
assert_response :success
|
||||
teardown do
|
||||
perform_enqueued_jobs do
|
||||
ActiveStorage::Blob.all.each(&:purge_later)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
38
test/controllers/users_controller_test.rb
Normal file
38
test/controllers/users_controller_test.rb
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
require "test_helper"
|
||||
|
||||
class UsersControllerTest < ActionDispatch::IntegrationTest
|
||||
setup do
|
||||
@user = users(:one) # Assuming you have a fixture or factory for @user
|
||||
end
|
||||
test "should get new" do
|
||||
get new_user_path
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get create" do
|
||||
post users_path
|
||||
assert_response :success
|
||||
|
||||
# post users_path, params: { user: { username: "testuser", password: "password123" } }
|
||||
# assert_redirected_to user_path(User.last)
|
||||
end
|
||||
|
||||
test "should get edit" do
|
||||
get edit_user_path(@user)
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get update" do
|
||||
patch user_path(@user)
|
||||
assert_response :success
|
||||
|
||||
# Probably also assert a successful redirect later and push correct data params
|
||||
end
|
||||
|
||||
test "should get destroy" do
|
||||
delete user_path(@user)
|
||||
assert_response :success
|
||||
|
||||
# Possibly this one too I suppose
|
||||
end
|
||||
end
|
||||
1
test/fixtures/files/.keep
vendored
1
test/fixtures/files/.keep
vendored
|
|
@ -0,0 +1 @@
|
|||
# Keep these, they're silly
|
||||
BIN
test/fixtures/files/test_image.jpg
vendored
Normal file
BIN
test/fixtures/files/test_image.jpg
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 439 KiB |
7
test/fixtures/users.yml
vendored
Normal file
7
test/fixtures/users.yml
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
name: testuser
|
||||
status: test
|
||||
email: test@email.com
|
||||
password_digest: <%= BCrypt::Password.create('testpassword') %>
|
||||
7
test/models/user_test.rb
Normal file
7
test/models/user_test.rb
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
require "test_helper"
|
||||
|
||||
class UserTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue