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
11 changes: 11 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ jobs:
version: '7.2'
database: 'sqlite3'
experimental: false
- ruby: 'truffleruby'
feature: 'unit'
orm:
name: 'active_record'
version: '7.2'
database: 'sqlite3'
experimental: false

# i18n fallbacks
- ruby: '3.3'
Expand All @@ -77,6 +84,10 @@ jobs:
feature: 'unit'
orm:
experimental: false
- ruby: 'truffleruby'
feature: 'unit'
orm:
experimental: false
exclude:
- ruby: '3.2'
database: 'sqlite3'
Expand Down
5 changes: 4 additions & 1 deletion lib/mobility/backends/active_record/table.rb
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,10 @@ def in_locale(locale)

# Destroys translations with all empty values
def destroy_empty_translations(required_attributes)
empty_translations = select{ |t| required_attributes.map(&t.method(:send)).none? }
empty_translations = select do |translation|
required_attributes.none? { |attribute| translation.read_attribute(attribute) }
end

destroy(empty_translations) if empty_translations.any?
end
end
Expand Down
5 changes: 3 additions & 2 deletions spec/mobility/backends/active_record/serialized_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@

describe "non-text values" do
it "converts non-string types to strings when saving" do
value = { foo: :bar }
post = SerializedPost.new
backend = post.mobility_backends[:title]
backend.write(:en, { foo: :bar } )
backend.write(:en, value)
post.save
expect(post[column_affix % "title"]).to match_hash({ en: "{:foo=>:bar}" })
expect(post[column_affix % "title"]).to match_hash({ en: value.to_s })
end
end

Expand Down
Loading