このコミットが含まれているのは:
@@ -23,9 +23,22 @@ RSpec.describe 'Locale activation', type: :model do
|
||||
.and_raise('backfill failed')
|
||||
end
|
||||
|
||||
it 'groups all tag histories from locale creation into one event' do
|
||||
previous_ids = TagVersion.pluck(:id)
|
||||
|
||||
expect { build_locale.save! }.to change { event_rows.length }.by(1)
|
||||
|
||||
event = event_rows.last
|
||||
expect(event).to include('event_type' => 'locales.create', 'created_by_user_id' => nil)
|
||||
versions = TagVersion.where.not(id: previous_ids)
|
||||
expect(versions.pluck(:tag_id)).to include(first.id, second.id)
|
||||
expect(versions.pluck(:event_id).uniq).to eq([event.fetch('id')])
|
||||
end
|
||||
|
||||
it 'rolls back a newly created locale and the preceding generated names' do
|
||||
locale = build_locale
|
||||
fail_second_generation!
|
||||
events = event_rows
|
||||
|
||||
expect { locale.save! }.to raise_error('backfill failed')
|
||||
|
||||
@@ -33,6 +46,7 @@ RSpec.describe 'Locale activation', type: :model do
|
||||
expect(generated_names).to be_empty
|
||||
expect(first.reload.name('ja')).to eq('activation_first')
|
||||
expect(second.reload.name('ja')).to eq('activation_second')
|
||||
expect(event_rows).to eq(events)
|
||||
end
|
||||
|
||||
it 'does not backfill while the locale is inactive' do
|
||||
@@ -45,7 +59,14 @@ RSpec.describe 'Locale activation', type: :model do
|
||||
locale = build_locale(deprecated_at: Time.current)
|
||||
locale.save!
|
||||
|
||||
locale.update!(deprecated_at: nil)
|
||||
previous_ids = TagVersion.pluck(:id)
|
||||
expect { locale.update!(deprecated_at: nil) }.to change { event_rows.length }.by(1)
|
||||
|
||||
event = event_rows.last
|
||||
expect(event).to include('event_type' => 'locales.restore', 'created_by_user_id' => nil)
|
||||
versions = TagVersion.where.not(id: previous_ids)
|
||||
expect(versions.pluck(:tag_id)).to include(first.id, second.id)
|
||||
expect(versions.pluck(:event_id).uniq).to eq([event.fetch('id')])
|
||||
|
||||
expect(generated_names.pluck(:tag_id)).to contain_exactly(first.id, second.id)
|
||||
expect(generated_names).to all(have_attributes(
|
||||
@@ -57,11 +78,13 @@ RSpec.describe 'Locale activation', type: :model do
|
||||
locale.save!
|
||||
previous_deprecated_at = locale.reload.deprecated_at
|
||||
fail_second_generation!
|
||||
events = event_rows
|
||||
|
||||
expect { locale.update!(deprecated_at: nil) }.to raise_error('backfill failed')
|
||||
|
||||
expect(locale.reload.deprecated_at).to eq(previous_deprecated_at)
|
||||
expect(generated_names).to be_empty
|
||||
expect(event_rows).to eq(events)
|
||||
end
|
||||
|
||||
it 'preserves a human primary through deactivation and repeated activation' do
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする