From d63c6cde8c5a7926f8bb892325f60e1d67d67ce9 Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Fri, 6 Mar 2026 08:58:26 -0800 Subject: [PATCH 1/2] more system specs --- spec/system/authentication_spec.rb | 30 ++++++++++++++++++++++++++++-- spec/system/feed_edit_spec.rb | 17 +++++++++++++++++ spec/system/feed_show_spec.rb | 16 ++++++++++++++++ spec/system/heroku_spec.rb | 21 +++++++++++++++++++++ spec/system/profile_spec.rb | 7 +++++++ spec/system/starred_spec.rb | 22 ++++++++++++++++++++++ spec/system/stories_index_spec.rb | 9 +++++++++ 7 files changed, 120 insertions(+), 2 deletions(-) create mode 100644 spec/system/heroku_spec.rb diff --git a/spec/system/authentication_spec.rb b/spec/system/authentication_spec.rb index 686b61744..16ad32b59 100644 --- a/spec/system/authentication_spec.rb +++ b/spec/system/authentication_spec.rb @@ -1,11 +1,37 @@ # frozen_string_literal: true RSpec.describe "authentication" do - it "redirects to login when accessing a protected page while logged out" do - create(:user) + before { create(:user) } + it "redirects to login when accessing news while logged out" do visit(news_path) expect(page).to have_current_path(login_path) end + + it "redirects to login when accessing starred while logged out" do + visit(starred_path) + + expect(page).to have_current_path(login_path) + end + + it "redirects to login when accessing archive while logged out" do + visit(archive_path) + + expect(page).to have_current_path(login_path) + end + + it "redirects to login when accessing feeds while logged out" do + visit(feeds_path) + + expect(page).to have_current_path(login_path) + end + + it "redirects to login when accessing a feed while logged out" do + feed = create(:feed) + + visit("/feed/#{feed.id}") + + expect(page).to have_current_path(login_path) + end end diff --git a/spec/system/feed_edit_spec.rb b/spec/system/feed_edit_spec.rb index 02d13e345..86e23d38b 100644 --- a/spec/system/feed_edit_spec.rb +++ b/spec/system/feed_edit_spec.rb @@ -26,6 +26,23 @@ def visit_edit_feed expect(page).to have_content("Updated the feed") end + it "pre-selects the feed's current group in the dropdown" do + login_as(default_user) + feed = create(:feed, :with_group) + a11y_skip = [ + "aria-required-children", + "color-contrast", + "label", + "landmark-one-main", + "page-has-heading-one", + "region", + "select-name" + ] + visit("/feeds/#{feed.id}/edit", a11y_skip:) + + expect(page).to have_select("group-id", selected: feed.group.name) + end + it "allows removing a group from a feed" do login_as(default_user) feed = create(:feed, :with_group) diff --git a/spec/system/feed_show_spec.rb b/spec/system/feed_show_spec.rb index c60103967..1673ae6b0 100644 --- a/spec/system/feed_show_spec.rb +++ b/spec/system/feed_show_spec.rb @@ -81,6 +81,22 @@ def create_and_visit_feed(story_title: nil) expect(page).to have_content("Read Story") end + it "navigates home with the home button" do + login_as(default_user) + create_and_visit_feed + + find_by_id("home").click + + expect(page).to have_current_path(news_path) + end + + it "shows the unread count in the page title" do + login_as(default_user) + create_and_visit_feed(story_title: "My Story") + + expect(page).to have_title("(1)") + end + it "only marks stories from the current feed as read" do login_as(default_user) other_feed = create(:feed) diff --git a/spec/system/heroku_spec.rb b/spec/system/heroku_spec.rb new file mode 100644 index 000000000..2a0a2e3d0 --- /dev/null +++ b/spec/system/heroku_spec.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +RSpec.describe "heroku setup" do + it "displays the heroku setup page without authentication" do + visit("/heroku") + + expect(page).to have_content("One more thing") + end + + it "displays the scheduler task instructions" do + visit("/heroku") + + expect(page).to have_content("rake lazy_fetch") + end + + it "links to the home page" do + visit("/heroku") + + expect(page).to have_link("Okay, it's ready!", href: "/") + end +end diff --git a/spec/system/profile_spec.rb b/spec/system/profile_spec.rb index c3fcc85d4..0e3a31ee5 100644 --- a/spec/system/profile_spec.rb +++ b/spec/system/profile_spec.rb @@ -42,6 +42,13 @@ def fill_in_password_fields(existing_password, new_password) expect(default_user.reload).to be_stories_order_asc end + it "reflects the current stories order in the dropdown" do + default_user.update!(stories_order: "asc") + visit(edit_profile_path) + + expect(page).to have_select("Stories feed order", selected: "Oldest first") + end + it "rejects username change with wrong password" do fill_in_username_fields("wrong_password") click_on("Update username") diff --git a/spec/system/starred_spec.rb b/spec/system/starred_spec.rb index abfafa236..daf47caa2 100644 --- a/spec/system/starred_spec.rb +++ b/spec/system/starred_spec.rb @@ -98,4 +98,26 @@ def create_starred_stories(count) expect(page).to have_content("2 of 2") end + + it "navigates to the previous page" do + login_as(default_user) + create_starred_stories(21) + visit(starred_path) + click_on("Next") + + click_on("Previous") + + expect(page).to have_content("1 of 2") + end + + it "navigates to the previous page with arrow keys" do + login_as(default_user) + create_starred_stories(21) + visit(starred_path) + send_keys(:arrow_right) + + send_keys(:arrow_left) + + expect(page).to have_content("1 of 2") + end end diff --git a/spec/system/stories_index_spec.rb b/spec/system/stories_index_spec.rb index 4b84a4895..bb9592e2e 100644 --- a/spec/system/stories_index_spec.rb +++ b/spec/system/stories_index_spec.rb @@ -183,6 +183,15 @@ def open_story_and_find_unread_icon(story_title) expect(titles).to eq(["Older Story", "Newer Story"]) end + it "shows the unread count in the page title" do + create(:story, title: "My Story") + login_as(default_user) + + visit news_path + + expect(page).to have_title("(1)") + end + it "allows viewing a story with hot keys" do create(:story, title: "My Story", body: "My Body") login_as(default_user) From f994cc2b3a22f46aa6f3881ae38f6db127b1605d Mon Sep 17 00:00:00 2001 From: Robert Fletcher Date: Tue, 10 Mar 2026 10:36:44 -0700 Subject: [PATCH 2/2] more system tests --- spec/system/authentication_spec.rb | 32 +++++++++++++++++++ spec/system/multi_user_isolation_spec.rb | 39 ++++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 spec/system/multi_user_isolation_spec.rb diff --git a/spec/system/authentication_spec.rb b/spec/system/authentication_spec.rb index 16ad32b59..164935f95 100644 --- a/spec/system/authentication_spec.rb +++ b/spec/system/authentication_spec.rb @@ -34,4 +34,36 @@ expect(page).to have_current_path(login_path) end + + it "redirects to login when accessing profile while logged out" do + visit(edit_profile_path) + + expect(page).to have_current_path(login_path) + end + + it "redirects to login when accessing new feed while logged out" do + visit(feeds_new_path) + + expect(page).to have_current_path(login_path) + end + + it "redirects to login when accessing feed import while logged out" do + visit(feeds_import_path) + + expect(page).to have_current_path(login_path) + end + + it "redirects to login when accessing feed export while logged out" do + visit(feeds_export_path) + + expect(page).to have_current_path(login_path) + end + + it "redirects to login when accessing feed edit while logged out" do + feed = create(:feed) + + visit("/feeds/#{feed.id}/edit") + + expect(page).to have_current_path(login_path) + end end diff --git a/spec/system/multi_user_isolation_spec.rb b/spec/system/multi_user_isolation_spec.rb new file mode 100644 index 000000000..f8670cff4 --- /dev/null +++ b/spec/system/multi_user_isolation_spec.rb @@ -0,0 +1,39 @@ +# frozen_string_literal: true + +RSpec.describe "multi-user data isolation" do + it "does not show another user's stories on the news page" do + create(:story, feed: create(:feed, user: create(:user))) + login_as(default_user) + + visit(news_path) + + expect(page).to have_content("You've reached RSS Zero") + end + + it "does not show another user's starred stories" do + create(:story, :starred, feed: create(:feed, user: create(:user))) + login_as(default_user) + + visit(starred_path) + + expect(page).to have_content("you haven't starred any stories") + end + + it "does not show another user's read stories in the archive" do + create(:story, :read, feed: create(:feed, user: create(:user))) + login_as(default_user) + + visit(archive_path) + + expect(page).to have_content("you haven't read any stories") + end + + it "does not show another user's feeds on the feeds page" do + create(:feed, user: create(:user)) + login_as(default_user) + + visit(feeds_path) + + expect(page).to have_content("Hey, you should add some feeds") + end +end