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
18 changes: 13 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ name: Tests

on:
push:
branches: [ master ]
branches: [ master, tailwind-redesign ]
pull_request:
branches: [ master ]
branches: [ master, tailwind-redesign ]

jobs:
test:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Install native dependencies
run: sudo apt-get update && sudo apt-get install -y libmagickwand-dev
- name: Set up Ruby
Expand All @@ -24,10 +24,18 @@ jobs:
ruby-version: 3.2
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Set up Node
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: 14.15.0
node-version: 22
cache: yarn
- name: Install JS dependencies
run: yarn install --frozen-lockfile
- name: Compile JS
run: RAILS_ENV=test bundle exec rake assets:precompile
env:
# webpack 4 uses OpenSSL's legacy md4 hash, removed by default in Node 17+
NODE_OPTIONS: --openssl-legacy-provider
- name: Run tests
run: RAILS_ENV=test bundle exec rails test
env:
NODE_OPTIONS: --openssl-legacy-provider
5 changes: 3 additions & 2 deletions app/services/documents/analysis/syllables_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ class SyllablesService < Service
def self.count(word)
word = word.downcase.gsub(/[^a-z]/, '')

return 1 if word.length <= 3
# Overrides must win before the short-word shortcut ("ion" is 2 syllables)
return SYLLABLE_COUNT_OVERRIDES[word] if SYLLABLE_COUNT_OVERRIDES.key?(word)
return 1 if word.length <= 3

word = word.sub(/(?:[^laeiouy]es|ed|[^laeiouy]e)$/, '').sub(/^y/, '')
count = word.scan(/[aeiouy]{1,2}/).length
count = word.scan(/[aeiouy]+/).length
count > 0 ? count : 1
end
end
Expand Down
6 changes: 5 additions & 1 deletion mise.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[tools]
node = "16"
node = "22"
yarn = "1.22.22"

[env]
# webpack 4 uses OpenSSL's legacy md4 hash, removed by default in Node 17+
NODE_OPTIONS = "--openssl-legacy-provider"
8 changes: 5 additions & 3 deletions test/controllers/content_controller_pin_edge_cases_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,15 @@ class ContentControllerPinEdgeCasesTest < ActionDispatch::IntegrationTest

threads.each(&:join)

# Both requests should complete without database lock errors
# Only one should be pinned
# Both requests should complete without database lock errors.
# Depending on interleaving, toggling the already-pinned image can land as an
# unpin (0 pinned) or a re-pin (1 pinned) — the invariant the controller
# guarantees is only that two images are never pinned simultaneously.
image1.reload
image2.reload

pinned_count = [image1, image2].count(&:pinned)
assert_equal 1, pinned_count, "Exactly one image should be pinned after concurrent requests"
assert_operator pinned_count, :<=, 1, "At most one image should be pinned after concurrent requests"
end

test "mixed type unpinning works correctly" do
Expand Down
6 changes: 4 additions & 2 deletions test/models/to_write/document_test.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
require 'test_helper'

class DocumentTest < ActiveSupport::TestCase
include ActiveJob::TestHelper

def setup
@user = users(:one)
@document = documents(:one)
Expand Down Expand Up @@ -61,9 +63,9 @@ def setup
assert_equal expected, Document.statuses.keys
end

test "status defaults to idea" do
test "status defaults to writing" do
doc = Document.new
assert_equal "idea", doc.status
assert_equal "writing", doc.status
end

test "status can be set via string" do
Expand Down
Loading