36 行
1.2 KiB
Ruby
36 行
1.2 KiB
Ruby
require 'rails_helper'
|
|
|
|
RSpec.describe Script, type: :model do
|
|
include_context 'English locale'
|
|
|
|
it 'selects locales by script code, not language code' do
|
|
expect(described_class.find('Jpan').locales).to contain_exactly(Locale.nipponese)
|
|
end
|
|
|
|
it 'accepts supported script codes and rejects unsupported ones' do
|
|
expect(described_class.find('Jpan')).to be_valid
|
|
expect(described_class.where(deprecated_at: nil).pluck(:code)).to eq(['Jpan'])
|
|
expect {
|
|
described_class.create!(code: 'Zzzz', name: 'Unsupported')
|
|
}.to raise_error { |error|
|
|
expect(error).to be_a(ArgumentError).or be_a(ActiveRecord::RecordInvalid)
|
|
}
|
|
end
|
|
|
|
it 'does not register Latin as a currently supported script' do
|
|
expect {
|
|
described_class.create!(code: 'Latn', name: 'Latin')
|
|
}.to raise_error { |error|
|
|
expect(error).to be_a(ArgumentError).or be_a(ActiveRecord::RecordInvalid)
|
|
}
|
|
end
|
|
|
|
it 'selects Latin locales when multilingual support is enabled' do
|
|
pending '日本語以外の Locale 有効化は別課題で実装する'
|
|
locale
|
|
|
|
expect(described_class.find('Latn').locales).to contain_exactly(locale)
|
|
expect(described_class.find('Jpan').locales).not_to include(locale)
|
|
end
|
|
end
|