Skip to content

Commit

Permalink
add spec about removing empty locale hash after last attribute is del…
Browse files Browse the repository at this point in the history
…eted
  • Loading branch information
doits committed Dec 2, 2021
1 parent c21ee94 commit e7e0b4d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion spec/databases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ postgres:
host: localhost
port: 5432
database: mobility_test
username: markus
username: postgres
encoding: utf8

sqlite3:
Expand Down
12 changes: 12 additions & 0 deletions spec/mobility/backends/active_record/container_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@
.and not_change { post.changed? }.from(false)
end
end

it 'deletes locale hash if last attribute is removed' do
post = ContainerPost.create!

::Mobility.with_locale(:en) { post.title = 'Title en' }
::Mobility.with_locale(:de) { post.title = 'Title de' }

expect { post.title = nil }
.to change { post.translations }
.from({ "en" => { "title" => "Title en" }, "de" => { "title" => "Title de" }})
.to({ "de" => { "title" => "Title de" }})
end
end

context "with query plugin" do
Expand Down

0 comments on commit e7e0b4d

Please sign in to comment.