|
124 | 124 |
|
125 | 125 | context "when fallbacks are defined" do
|
126 | 126 |
|
127 |
| - before do |
| 127 | + around do |example| |
| 128 | + prev_fallbacks = I18n.fallbacks.dup |
128 | 129 | ::I18n.fallbacks[:de] = [ :de, :en, :es ]
|
| 130 | + example.run |
| 131 | + I18n.fallbacks = prev_fallbacks |
129 | 132 | end
|
130 | 133 |
|
131 | 134 | context "when the first fallback translation exists" do
|
|
164 | 167 |
|
165 | 168 | context "when no fallbacks are defined" do
|
166 | 169 |
|
167 |
| - before do |
| 170 | + around do |example| |
| 171 | + prev_fallbacks = I18n.fallbacks.dup |
168 | 172 | ::I18n.fallbacks[:de] = [ :de ]
|
| 173 | + example.run |
| 174 | + I18n.fallbacks = prev_fallbacks |
169 | 175 | end
|
170 | 176 |
|
171 | 177 | let(:value) do
|
|
179 | 185 |
|
180 | 186 | context 'when fallbacks are empty' do
|
181 | 187 |
|
182 |
| - before do |
| 188 | + around do |example| |
| 189 | + prev_fallbacks = I18n.fallbacks.dup |
183 | 190 | ::I18n.fallbacks[:de] = [ ]
|
| 191 | + example.run |
| 192 | + I18n.fallbacks = prev_fallbacks |
184 | 193 | end
|
185 | 194 |
|
186 | 195 | let(:value) do
|
|
282 | 291 |
|
283 | 292 | context "when fallbacks are defined" do
|
284 | 293 |
|
285 |
| - before do |
| 294 | + around do |example| |
| 295 | + prev_fallbacks = I18n.fallbacks.dup |
286 | 296 | ::I18n.fallbacks[:de] = [ :de, :en, :es ]
|
| 297 | + example.run |
| 298 | + I18n.fallbacks = prev_fallbacks |
287 | 299 | end
|
288 | 300 |
|
289 | 301 | context 'when fallbacks are enabled' do
|
|
340 | 352 |
|
341 | 353 | context "when no fallbacks are defined" do
|
342 | 354 |
|
343 |
| - before do |
| 355 | + around do |example| |
| 356 | + prev_fallbacks = I18n.fallbacks.dup |
344 | 357 | ::I18n.fallbacks[:de] = [ :de ]
|
| 358 | + example.run |
| 359 | + I18n.fallbacks = prev_fallbacks |
345 | 360 | end
|
346 | 361 |
|
347 | 362 | let(:value) do
|
|
485 | 500 |
|
486 | 501 | context "when the value is false" do
|
487 | 502 |
|
488 |
| - before do |
| 503 | + around do |example| |
| 504 | + prev_fallbacks = I18n.fallbacks.dup |
489 | 505 | ::I18n.fallbacks[:de] = [:en, :es]
|
| 506 | + example.run |
| 507 | + I18n.fallbacks = prev_fallbacks |
490 | 508 | end
|
491 | 509 |
|
492 | 510 | let(:field) do
|
|
504 | 522 |
|
505 | 523 | context "when the value is true" do
|
506 | 524 |
|
507 |
| - before do |
| 525 | + around do |example| |
| 526 | + prev_fallbacks = I18n.fallbacks.dup |
508 | 527 | ::I18n.fallbacks[:de] = [:en, :es]
|
| 528 | + example.run |
| 529 | + I18n.fallbacks = prev_fallbacks |
509 | 530 | end
|
510 | 531 |
|
511 | 532 | let(:field) do
|
|
525 | 546 | end
|
526 | 547 | end
|
527 | 548 | end
|
| 549 | + |
| 550 | + describe "localize: :present" do |
| 551 | + |
| 552 | + let(:field) do |
| 553 | + described_class.new(:description, localize: :present, type: String) |
| 554 | + end |
| 555 | + |
| 556 | + context "when setting the localize to present" do |
| 557 | + |
| 558 | + it "is localized?" do |
| 559 | + expect(field.localized?).to be true |
| 560 | + end |
| 561 | + |
| 562 | + it "is localize_present?" do |
| 563 | + expect(field.localize_present?).to be true |
| 564 | + end |
| 565 | + end |
| 566 | + |
| 567 | + context "when localize is not localize_present" do |
| 568 | + |
| 569 | + let(:field) do |
| 570 | + described_class.new(:description, localize: true, type: String) |
| 571 | + end |
| 572 | + |
| 573 | + it "is localized?" do |
| 574 | + expect(field.localized?).to be true |
| 575 | + end |
| 576 | + |
| 577 | + it "is not localize_present?" do |
| 578 | + expect(field.localize_present?).to be false |
| 579 | + end |
| 580 | + end |
| 581 | + end |
528 | 582 | end
|
0 commit comments