diff --git a/app/helpers/sessions_helper.rb b/app/helpers/sessions_helper.rb new file mode 100644 index 0000000..309f8b2 --- /dev/null +++ b/app/helpers/sessions_helper.rb @@ -0,0 +1,2 @@ +module SessionsHelper +end diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb new file mode 100644 index 0000000..2310a24 --- /dev/null +++ b/app/helpers/users_helper.rb @@ -0,0 +1,2 @@ +module UsersHelper +end diff --git a/test/controllers/sessions_controller_test.rb b/test/controllers/sessions_controller_test.rb new file mode 100644 index 0000000..4c379c9 --- /dev/null +++ b/test/controllers/sessions_controller_test.rb @@ -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 diff --git a/test/controllers/test/images_controller_test.rb b/test/controllers/test/images_controller_test.rb index 4a9a08d..9536bf7 100644 --- a/test/controllers/test/images_controller_test.rb +++ b/test/controllers/test/images_controller_test.rb @@ -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 diff --git a/test/controllers/users_controller_test.rb b/test/controllers/users_controller_test.rb new file mode 100644 index 0000000..66cae48 --- /dev/null +++ b/test/controllers/users_controller_test.rb @@ -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 diff --git a/test/fixtures/files/.keep b/test/fixtures/files/.keep index e69de29..6dadb36 100644 --- a/test/fixtures/files/.keep +++ b/test/fixtures/files/.keep @@ -0,0 +1 @@ +# Keep these, they're silly \ No newline at end of file diff --git a/test/fixtures/files/test_image.jpg b/test/fixtures/files/test_image.jpg new file mode 100644 index 0000000..96e1de5 Binary files /dev/null and b/test/fixtures/files/test_image.jpg differ diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml new file mode 100644 index 0000000..6956558 --- /dev/null +++ b/test/fixtures/users.yml @@ -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') %> \ No newline at end of file diff --git a/test/models/user_test.rb b/test/models/user_test.rb new file mode 100644 index 0000000..5c07f49 --- /dev/null +++ b/test/models/user_test.rb @@ -0,0 +1,7 @@ +require "test_helper" + +class UserTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end