From: Aidan Cornelius-Bell Date: Sat, 11 Jan 2025 07:16:22 +0000 (+1030) Subject: Completely resetting the test suite X-Git-Url: https://gitweb.mndrdr.org/?a=commitdiff_plain;h=95d10982de91ef08efa9300756fbd73c6a68d25b;p=arelpe.git Completely resetting the test suite --- diff --git a/test/controllers/api_keys_controller_test.rb b/test/controllers/api_keys_controller_test.rb deleted file mode 100644 index a4807c8..0000000 --- a/test/controllers/api_keys_controller_test.rb +++ /dev/null @@ -1,7 +0,0 @@ -require "test_helper" - -class ApiKeysControllerTest < ActionDispatch::IntegrationTest - # test "the truth" do - # assert true - # end -end diff --git a/test/controllers/job_runner_controller_test.rb b/test/controllers/job_runner_controller_test.rb deleted file mode 100644 index 32e6b40..0000000 --- a/test/controllers/job_runner_controller_test.rb +++ /dev/null @@ -1,21 +0,0 @@ -require "test_helper" - -class JobRunnerControllerTest < ActionDispatch::IntegrationTest - setup do - sign_in users(:admin) - end - - test "should get index" do - get job_runner_url - assert_response :success - end - - test "should run job" do - post run_job_runner_url, params: { job: 'weekly_bookmarks_digest' } - assert_redirected_to job_runner_url - end - - test "should handle invalid job" do - assert_response :success - end -end diff --git a/test/controllers/mailing_lists_controller_test.rb b/test/controllers/mailing_lists_controller_test.rb deleted file mode 100644 index 08cf107..0000000 --- a/test/controllers/mailing_lists_controller_test.rb +++ /dev/null @@ -1,32 +0,0 @@ -require "test_helper" - -class MailingListsControllerTest < ActionDispatch::IntegrationTest - setup do - sign_in users(:regular_user) - end - - test "should get index" do - get mailing_lists_url - assert_response :success - end - - test "should subscribe" do - post subscribe_mailing_lists_url - assert_redirected_to mailing_lists_url - end - - test "should unsubscribe" do - delete unsubscribe_mailing_lists_url - assert_redirected_to mailing_lists_url - end - - test "should sync status" do - post sync_status_mailing_lists_url - assert_redirected_to mailing_lists_url - end - - test "should resync from buttondown" do - post resync_from_buttondown_mailing_lists_url - assert_redirected_to mailing_lists_url - end -end diff --git a/test/controllers/pages_controller_test.rb b/test/controllers/pages_controller_test.rb deleted file mode 100644 index a6aea51..0000000 --- a/test/controllers/pages_controller_test.rb +++ /dev/null @@ -1,66 +0,0 @@ -require "test_helper" - -class PagesTest < ApplicationSystemTestCase - setup do - sign_in users(:admin) - @page = pages(:about) - end - - test "can create and manage pages" do - visit new_page_url - - # Create a page - fill_in "Title", with: "New Test Page" - fill_in "Content", with: "This is a test page content" - select "visible", from: "Visibility" - click_on "Create Page" - - assert_text "Page was successfully created" - assert_equal "New Test Page", Page.last.title - - # Update the page - last_page = Page.last - visit edit_page_url(last_page) - fill_in "Title", with: "Updated Page Title" - click_on "Update Page" - - assert_text "Page was successfully updated" - assert_equal "Updated Page Title", last_page.reload.title - - # Delete the page - visit page_url(last_page) - accept_confirm do - click_on "Destroy this page" - end - - assert_text "Page was successfully destroyed" - assert_not Page.exists?(last_page.id) - end - - test "prevents non-admin users from managing pages" do - sign_out :user - sign_in users(:regular_user) - - visit pages_url - assert_current_path root_path - assert_text "You are not authorised to access this page" - end - - test "visibility controls work correctly" do - # Create pages with different visibilities - visit new_page_url - fill_in "Title", with: "Hidden Page" - fill_in "Content", with: "This page should be hidden" - select "hidden", from: "Visibility" - click_on "Create Page" - - hidden_page = Page.find_by(title: "Hidden Page") - - # Test that hidden page is not accessible - sign_out :user - visit public_page_path(hidden_page.slug) - - assert_current_path root_path - assert_text "Page not found" - end -end diff --git a/test/controllers/posts_controller_test.rb b/test/controllers/posts_controller_test.rb deleted file mode 100644 index 467f700..0000000 --- a/test/controllers/posts_controller_test.rb +++ /dev/null @@ -1,71 +0,0 @@ -require "test_helper" - -class PostsTest < ApplicationSystemTestCase - setup do - sign_in users(:admin) - @post = posts(:tech_dispatch) - end - - test "can create different types of posts" do - visit new_post_url - - # Test dispatch post creation - fill_in "Title", with: "New Tech Dispatch" - fill_in "Content", with: "Detailed analysis of emerging technologies" - select "dispatch", from: "Post type" - fill_in "Published at", with: Time.current - click_on "Create Post" - - assert_text "Post was successfully created" - assert_equal "New Tech Dispatch", Post.last.title - - # Test bookmark post creation - visit new_post_url - fill_in "Title", with: "Interesting Bookmark" - fill_in "Url", with: "https://example.com/tech-article" - select "bookmark", from: "Post type" - click_on "Create Post" - - assert_text "Post was successfully created" - assert_equal "Interesting Bookmark", Post.last.title - end - - test "can update and delete posts" do - visit post_url(@post) - - # Update post - click_on "Edit this post" - fill_in "Title", with: "Updated Tech Analysis" - click_on "Update Post" - - assert_text "Post was successfully updated" - assert_equal "Updated Tech Analysis", @post.reload.title - - # Delete post - visit post_url(@post) - accept_confirm do - click_on "Destroy this post" - end - - assert_text "Post was successfully destroyed" - assert_not Post.exists?(@post.id) - end - - test "validates post creation rules" do - visit new_post_url - - # Try creating a dispatch without content - fill_in "Title", with: "Invalid Dispatch" - select "dispatch", from: "Post type" - click_on "Create Post" - - assert_text "Content can't be blank" - - # Try creating a bookmark without URL - fill_in "Title", with: "Invalid Bookmark" - select "bookmark", from: "Post type" - click_on "Create Post" - - assert_text "Url can't be blank" - end -end diff --git a/test/controllers/pubview_controller_test.rb b/test/controllers/pubview_controller_test.rb deleted file mode 100644 index c93834e..0000000 --- a/test/controllers/pubview_controller_test.rb +++ /dev/null @@ -1,42 +0,0 @@ -require "test_helper" - -class PubviewControllerTest < ActionDispatch::IntegrationTest - include Rails.application.routes.url_helpers - - def default_url_options - { host: 'localhost', port: 3000 } - end - - test "should get index" do - get root_url - assert_response :success - end - - test "should get dispatch post" do - post = posts(:tech_dispatch) - get public_post_url(year: post.published_at.year, slug: post.slug) - assert_response :success - end - - test "should get bookmark post" do - post = posts(:tech_bookmark) - get public_post_url(year: post.published_at.year, slug: post.slug) - assert_response :success - end - - test "should get public page" do - page = pages(:about) - get public_page_url(slug: page.slug) - assert_response :success - end - - test "should get rss feed" do - get rss_url(format: :rss) - assert_response :success - end - - test "should get dispatches rss feed" do - get dispatches_rss_url(format: :rss) - assert_response :success - end -end diff --git a/test/controllers/subscriptions_controller_test.rb b/test/controllers/subscriptions_controller_test.rb deleted file mode 100644 index 644bbb1..0000000 --- a/test/controllers/subscriptions_controller_test.rb +++ /dev/null @@ -1,35 +0,0 @@ -require "test_helper" - - -class SubscriptionsControllerTest < ActionDispatch::IntegrationTest - setup do - sign_in users(:regular_user) - # Mock Stripe responses - @stripe_helper = StripeMock.create_test_helper - StripeMock.start - end - - teardown do - StripeMock.stop - end - - test "should handle one_time payment" do - token = @stripe_helper.generate_card_token - post subscriptions_url, params: { - support_type: 'one_time', - payment_amount: '10.00', - stripeToken: token - } - assert_redirected_to subscriptions_url - end - - test "should handle ongoing payment" do - token = @stripe_helper.generate_card_token - post subscriptions_url, params: { - support_type: 'ongoing', - payment_amount: '10.00', - stripeToken: token - } - assert_redirected_to subscriptions_url - end -end diff --git a/test/controllers/two_factor_controller_test.rb b/test/controllers/two_factor_controller_test.rb deleted file mode 100644 index bf64021..0000000 --- a/test/controllers/two_factor_controller_test.rb +++ /dev/null @@ -1,32 +0,0 @@ -require "test_helper" - -class TwoFactorControllerTest < ActionDispatch::IntegrationTest - setup do - sign_in users(:regular_user) - end - - test "should get new" do - get new_two_factor_url - assert_response :success - end - - test "should create" do - # First get the new page to set up 2FA - get new_two_factor_url - assert_response :success - - # Then attempt to create with OTP - post two_factor_url, params: { otp_attempt: "123456" } - assert_redirected_to backup_codes_two_factor_url - end - - test "should show backup codes" do - get backup_codes_two_factor_url - assert_response :success - end - - test "should destroy" do - delete two_factor_url - assert_redirected_to root_url - end -end diff --git a/test/controllers/user_manager_controller_test.rb b/test/controllers/user_manager_controller_test.rb deleted file mode 100644 index c20e553..0000000 --- a/test/controllers/user_manager_controller_test.rb +++ /dev/null @@ -1,7 +0,0 @@ -require "test_helper" - -class UserManagerControllerTest < ActionDispatch::IntegrationTest - # test "the truth" do - # assert true - # end -end diff --git a/test/fixtures/api_keys.yml b/test/fixtures/api_keys.yml deleted file mode 100644 index 9405e52..0000000 --- a/test/fixtures/api_keys.yml +++ /dev/null @@ -1,7 +0,0 @@ -# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html - -admin_key: - key: <%= SecureRandom.hex(20) %> - -test_key: - key: <%= SecureRandom.hex(20) %> diff --git a/test/fixtures/pages.yml b/test/fixtures/pages.yml deleted file mode 100644 index 389e804..0000000 --- a/test/fixtures/pages.yml +++ /dev/null @@ -1,17 +0,0 @@ -# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html - -about: - title: About mind reader - slug: about-<%= SecureRandom.hex(4) %> - content: | - Welcome to mind reader. This is a space for critical analysis of technology, capitalism, and social change. - The goal is to understand how these forces shape our world and imagine better futures. - visibility: 1 - -privacy: - title: Privacy Policy - slug: privacy-<%= SecureRandom.hex(4) %> - content: | - mind reader respects your privacy. We only collect essential data needed to provide our services. - Your data is never sold or shared with third parties. - visibility: 1 diff --git a/test/fixtures/posts.yml b/test/fixtures/posts.yml deleted file mode 100644 index d78e101..0000000 --- a/test/fixtures/posts.yml +++ /dev/null @@ -1,51 +0,0 @@ -# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html -# -tech_dispatch: - post_type: dispatch - title: The Hidden Costs of AI Development - slug: hidden-costs-ai-<%= SecureRandom.hex(4) %> - published_at: <%= Time.current - 2.days %> - excerpt: Examining the environmental and social impacts of training large language models - tags: AI, technology, climate - content: | - The rise of large language models has transformed the tech landscape, but at what cost? - This analysis explores the hidden environmental and social impacts of AI development. - - We need to consider: - - Energy consumption of training - - Data center infrastructure - - Labor conditions in the AI supply chain - url: - -social_dispatch: - post_type: dispatch - title: Reimagining Social Media - slug: reimagining-social-<%= SecureRandom.hex(4) %> - published_at: <%= Time.current - 5.days %> - excerpt: A critical look at alternative social media platforms - tags: social media, technology, community - content: | - What would social media look like if it was designed for human flourishing instead of profit? - - This piece explores existing alternatives and imagines new possibilities. - url: - -tech_bookmark: - post_type: bookmark - title: The Environmental Impact of ChatGPT - slug: chatgpt-environment-<%= SecureRandom.hex(4) %> - published_at: <%= Time.current - 1.day %> - excerpt: MIT Technology Review examines ChatGPT's carbon footprint - tags: AI, climate, technology - content: Fascinating analysis of the environmental costs of running large language models - url: https://example.com/chatgpt-impact - -social_bookmark: - post_type: bookmark - title: Platform Cooperativism Now - slug: platform-coop-<%= SecureRandom.hex(4) %> - published_at: <%= Time.current - 3.days %> - excerpt: How worker-owned platforms are challenging the gig economy - tags: cooperatives, technology, labor - content: Great overview of the growing platform cooperativism movement - url: https://example.com/platform-coops diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml deleted file mode 100644 index e825008..0000000 --- a/test/fixtures/users.yml +++ /dev/null @@ -1,38 +0,0 @@ -# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html - -# 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 -# -admin: - email: admin@example.com - first_name: Admin - last_name: User - admin: true - encrypted_password: <%= Devise::Encryptor.digest(User, 'password123') %> - confirmed_at: <%= Time.current - 1.month %> - support_type: ongoing - subscription_status: active - buttondown_status: premium - -regular_user: - email: user@example.com - first_name: Regular - last_name: User - admin: false - encrypted_password: <%= Devise::Encryptor.digest(User, 'password123') %> - confirmed_at: <%= Time.current - 2.weeks %> - support_type: non_financial - subscription_status: - buttondown_status: unpaid - -paid_user: - email: paid@example.com - first_name: Paid - last_name: User - admin: false - encrypted_password: <%= Devise::Encryptor.digest(User, 'password123') %> - confirmed_at: <%= Time.current - 1.week %> - support_type: one_time - subscription_status: one_time - buttondown_status: premium diff --git a/test/jobs/weekly_bookmarks_digest_job_test.rb b/test/jobs/weekly_bookmarks_digest_job_test.rb deleted file mode 100644 index f8c6173..0000000 --- a/test/jobs/weekly_bookmarks_digest_job_test.rb +++ /dev/null @@ -1,7 +0,0 @@ -require "test_helper" - -class WeeklyBookmarksDigestJobTest < ActiveJob::TestCase - # test "the truth" do - # assert true - # end -end diff --git a/test/mailers/admin_mailer_test.rb b/test/mailers/admin_mailer_test.rb deleted file mode 100644 index 7c48377..0000000 --- a/test/mailers/admin_mailer_test.rb +++ /dev/null @@ -1,34 +0,0 @@ -# test/mailers/admin_mailer_test.rb -require "test_helper" - -class AdminMailerTest < ActionMailer::TestCase - def setup - @admin_email = ENV.fetch('ADMIN_EMAIL', "admin@example.com") - @user = users(:paid_user) - @user.update(last_payment_at: Time.current) - end - - test "should send new paid member notification" do - mail = AdminMailer.new_paid_member(@user) - - assert_equal "mind reader :: New Paid Member", mail.subject - assert_equal [@admin_email], mail.to - assert_equal ["mr@mndrdr.org"], mail.from - assert_match @user.email, mail.body.encoded - assert_match @user.last_payment_at.strftime("%B %d, %Y"), mail.body.encoded - end - - test "should send new non_financial member notification" do - user = users(:regular_user) - # Set a specific timestamp for testing to match the current date - user.update!(created_at: Time.new(2025, 1, 11)) - - mail = AdminMailer.new_non_financial_member(user) - - assert_equal "mind reader :: New Non-Financial Member", mail.subject - assert_equal [@admin_email], mail.to - assert_equal ["mr@mndrdr.org"], mail.from - assert_match user.email, mail.body.encoded - assert_match "January 11, 2025", mail.body.encoded - end -end diff --git a/test/mailers/digest_mailer_test.rb b/test/mailers/digest_mailer_test.rb deleted file mode 100644 index ac6a646..0000000 --- a/test/mailers/digest_mailer_test.rb +++ /dev/null @@ -1,20 +0,0 @@ -# test/mailers/digest_mailer_test.rb -require "test_helper" - -class DigestMailerTest < ActionMailer::TestCase - test "should send weekly bookmarks digest" do - user = users(:paid_user) - bookmarks = Post.bookmarks.limit(5) - - mail = DigestMailer.weekly_bookmarks_digest(user, bookmarks) - - assert_equal "mind reader :: weekly digest", mail.subject - assert_equal [user.email], mail.to - assert_equal ["mr@mndrdr.org"], mail.from - assert_match user.first_name, mail.body.encoded - - bookmarks.each do |bookmark| - assert_match bookmark.title, mail.body.encoded - end - end -end diff --git a/test/mailers/previews/admin_mailer_preview.rb b/test/mailers/previews/admin_mailer_preview.rb deleted file mode 100644 index 48505d1..0000000 --- a/test/mailers/previews/admin_mailer_preview.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AdminMailerPreview < ActionMailer::Preview - def new_paid_member - AdminMailer.new_paid_member(User.first) - end - - def new_non_financial_member - AdminMailer.new_non_financial_member(User.first) - end -end diff --git a/test/mailers/previews/digest_mailer_preview.rb b/test/mailers/previews/digest_mailer_preview.rb deleted file mode 100644 index 8d0dc98..0000000 --- a/test/mailers/previews/digest_mailer_preview.rb +++ /dev/null @@ -1,5 +0,0 @@ -class DigestMailerPreview < ActionMailer::Preview - def weekly_bookmarks_digest - DigestMailer.weekly_bookmarks_digest(User.first, Post.bookmarks.limit(5)) - end -end diff --git a/test/mailers/previews/subscription_mailer_preview.rb b/test/mailers/previews/subscription_mailer_preview.rb deleted file mode 100644 index 72d91b9..0000000 --- a/test/mailers/previews/subscription_mailer_preview.rb +++ /dev/null @@ -1,5 +0,0 @@ -class SubscriptionMailerPreview < ActionMailer::Preview - def confirmation_email - SubscriptionMailer.confirmation_email(User.first, 10.00, "ongoing") - end -end diff --git a/test/mailers/previews/welcome_mailer_preview.rb b/test/mailers/previews/welcome_mailer_preview.rb deleted file mode 100644 index aa0f89e..0000000 --- a/test/mailers/previews/welcome_mailer_preview.rb +++ /dev/null @@ -1,5 +0,0 @@ -class WelcomeMailerPreview < ActionMailer::Preview - def welcome_email - WelcomeMailer.welcome_email(User.first) - end -end diff --git a/test/mailers/subscription_mailer_test.rb b/test/mailers/subscription_mailer_test.rb deleted file mode 100644 index 9cabbb4..0000000 --- a/test/mailers/subscription_mailer_test.rb +++ /dev/null @@ -1,18 +0,0 @@ -# test/mailers/subscription_mailer_test.rb -require "test_helper" - -class SubscriptionMailerTest < ActionMailer::TestCase - test "should send subscription confirmation email" do - user = users(:paid_user) - amount = 10.00 - support_type = "ongoing" - - mail = SubscriptionMailer.confirmation_email(user, amount, support_type) - - assert_equal "Thank you for supporting mind reader!", mail.subject - assert_equal [user.email], mail.to - assert_equal ["mr@mndrdr.org"], mail.from - assert_match support_type, mail.body.encoded - assert_match amount.to_s, mail.body.encoded if amount - end -end diff --git a/test/mailers/welcome_mailer_test.rb b/test/mailers/welcome_mailer_test.rb deleted file mode 100644 index d6daca8..0000000 --- a/test/mailers/welcome_mailer_test.rb +++ /dev/null @@ -1,27 +0,0 @@ -# test/mailers/welcome_mailer_test.rb -require "test_helper" - -class WelcomeMailerTest < ActionMailer::TestCase - test "should send basic welcome email" do - user = users(:regular_user) - mail = WelcomeMailer.welcome_email(user) - - assert_equal "Welcome to mind reader", mail.subject - assert_equal [user.email], mail.to - assert_equal ["mr@mndrdr.org"], mail.from - assert_match "Welcome", mail.body.encoded - assert_match user.first_name, mail.body.encoded - end - - test "should send paid user welcome email" do - user = users(:paid_user) - mail = WelcomeMailer.welcome_email(user) - - assert_equal "Welcome to mind reader", mail.subject - assert_equal [user.email], mail.to - assert_equal ["mr@mndrdr.org"], mail.from - assert_match "Welcome", mail.body.encoded - assert_match user.first_name, mail.body.encoded - assert_match "Premium", mail.body.encoded - end -end diff --git a/test/models/api_key_test.rb b/test/models/api_key_test.rb deleted file mode 100644 index 6dc74dc..0000000 --- a/test/models/api_key_test.rb +++ /dev/null @@ -1,7 +0,0 @@ -require "test_helper" - -class ApiKeyTest < ActiveSupport::TestCase - # test "the truth" do - # assert true - # end -end diff --git a/test/models/page_test.rb b/test/models/page_test.rb deleted file mode 100644 index fa25544..0000000 --- a/test/models/page_test.rb +++ /dev/null @@ -1,7 +0,0 @@ -require "test_helper" - -class PageTest < ActiveSupport::TestCase - # test "the truth" do - # assert true - # end -end diff --git a/test/models/post_test.rb b/test/models/post_test.rb deleted file mode 100644 index ff155c4..0000000 --- a/test/models/post_test.rb +++ /dev/null @@ -1,7 +0,0 @@ -require "test_helper" - -class PostTest < ActiveSupport::TestCase - # test "the truth" do - # assert true - # end -end diff --git a/test/models/user_test.rb b/test/models/user_test.rb deleted file mode 100644 index 5c07f49..0000000 --- a/test/models/user_test.rb +++ /dev/null @@ -1,7 +0,0 @@ -require "test_helper" - -class UserTest < ActiveSupport::TestCase - # test "the truth" do - # assert true - # end -end diff --git a/test/system/pages_test.rb b/test/system/pages_test.rb deleted file mode 100644 index 7ed1a94..0000000 --- a/test/system/pages_test.rb +++ /dev/null @@ -1,47 +0,0 @@ -require "application_system_test_case" - -class PagesTest < ApplicationSystemTestCase - setup do - @page = pages(:one) - end - - test "visiting the index" do - visit pages_url - assert_selector "h1", text: "Pages" - end - - test "should create page" do - visit pages_url - click_on "New page" - - fill_in "Content", with: @page.content - fill_in "Public", with: @page.public - fill_in "Slug", with: @page.slug - fill_in "Title", with: @page.title - click_on "Create Page" - - assert_text "Page was successfully created" - click_on "Back" - end - - test "should update Page" do - visit page_url(@page) - click_on "Edit this page", match: :first - - fill_in "Content", with: @page.content - fill_in "Public", with: @page.public - fill_in "Slug", with: @page.slug - fill_in "Title", with: @page.title - click_on "Update Page" - - assert_text "Page was successfully updated" - click_on "Back" - end - - test "should destroy Page" do - visit page_url(@page) - click_on "Destroy this page", match: :first - - assert_text "Page was successfully destroyed" - end -end diff --git a/test/system/posts_test.rb b/test/system/posts_test.rb deleted file mode 100644 index 2cdf1c3..0000000 --- a/test/system/posts_test.rb +++ /dev/null @@ -1,55 +0,0 @@ -require "application_system_test_case" - -class PostsTest < ApplicationSystemTestCase - setup do - @post = posts(:one) - end - - test "visiting the index" do - visit posts_url - assert_selector "h1", text: "Posts" - end - - test "should create post" do - visit posts_url - click_on "New post" - - fill_in "Content", with: @post.content - fill_in "Excerpt", with: @post.excerpt - fill_in "Post type", with: @post.post_type - fill_in "Published at", with: @post.published_at - fill_in "Slug", with: @post.slug - fill_in "Tags", with: @post.tags - fill_in "Title", with: @post.title - fill_in "Url", with: @post.url - click_on "Create Post" - - assert_text "Post was successfully created" - click_on "Back" - end - - test "should update Post" do - visit post_url(@post) - click_on "Edit this post", match: :first - - fill_in "Content", with: @post.content - fill_in "Excerpt", with: @post.excerpt - fill_in "Post type", with: @post.post_type - fill_in "Published at", with: @post.published_at.to_s - fill_in "Slug", with: @post.slug - fill_in "Tags", with: @post.tags - fill_in "Title", with: @post.title - fill_in "Url", with: @post.url - click_on "Update Post" - - assert_text "Post was successfully updated" - click_on "Back" - end - - test "should destroy Post" do - visit post_url(@post) - click_on "Destroy this post", match: :first - - assert_text "Post was successfully destroyed" - end -end diff --git a/test/test_helper.rb b/test/test_helper.rb index d464ea3..9c9ba95 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,59 +1,7 @@ -# test/test_helper.rb -ENV['RAILS_ENV'] ||= 'test' -require_relative "../config/environment" -require "rails/test_help" -require "devise" +require "test_helper" -Rails.application.reload_routes! -Rails.application.routes.default_url_options[:host] = 'localhost' -Rails.application.routes.default_url_options[:port] = '3000' - - -class ActionDispatch::IntegrationTest - include Rails.application.routes.url_helpers - - # Add default_url_options here - def default_url_options - { host: 'localhost', port: 3000 } - end -end - -class ActiveSupport::TestCase - include Devise::Test::IntegrationHelpers - include Rails.application.routes.url_helpers - - # Add default_url_options here too - def default_url_options - { host: 'www.example.com' } # or { host: 'localhost', port: 3000 } - end - - # Run tests in parallel with specified workers - parallelize(workers: :number_of_processors) - - # Setup all fixtures - fixtures :all - - setup do - Warden.test_mode! if defined?(Warden) # Add this - end - - teardown do - Warden.test_reset! if defined?(Warden) # Add this - end - - # Helper methods - def sign_in_admin - @admin = users(:admin) - sign_in @admin - end - - def sign_in_regular_user - @user = users(:regular_user) - sign_in @user - end - - def sign_in_paid_user - @paid_user = users(:paid_user) - sign_in @paid_user - end +class ArticleTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end end