23 行
874 B
Ruby
23 行
874 B
Ruby
RSpec.shared_context 'Ainu locale contract' do
|
|
let(:ainu_locale) { instance_double(Locale, language_code: 'ain', script_code: 'Jpan') }
|
|
|
|
before do
|
|
# Only the foreign-key reference is seeded; no Locale or enum is enabled.
|
|
Language.connection.execute(<<~SQL)
|
|
INSERT IGNORE INTO languages (code, name, created_at)
|
|
VALUES ('ain', 'Ainu', CURRENT_TIMESTAMP)
|
|
SQL
|
|
allow(Locale).to receive(:find_by).and_call_original
|
|
allow(Locale).to receive(:find_by).with(code: 'ain').and_return(ainu_locale)
|
|
end
|
|
|
|
def add_ainu_name tag, name
|
|
TagName.insert_all!([{
|
|
tag_id: tag.id, language_code: 'ain', script_code: 'Jpan', name:,
|
|
primary_flg: true, auto_generated: false,
|
|
created_at: Time.current, updated_at: Time.current }])
|
|
tag.tag_names.reset
|
|
TagName.find_by!(tag_id: tag.id, language_code: 'ain', name:)
|
|
end
|
|
end
|