Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions spec/system/authentication_spec.rb
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions spec/system/feed_edit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
16 changes: 16 additions & 0 deletions spec/system/feed_show_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
21 changes: 21 additions & 0 deletions spec/system/heroku_spec.rb
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions spec/system/profile_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
22 changes: 22 additions & 0 deletions spec/system/starred_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 9 additions & 0 deletions spec/system/stories_index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down