|
5 | 5 | RSpec.describe Uploadcare::CnameGenerator do |
6 | 6 | before do |
7 | 7 | # Reset memoized variables between tests |
8 | | - described_class.instance_variable_set(:@custom_cname, nil) |
9 | | - described_class.instance_variable_set(:@cdn_base_postfix, nil) |
| 8 | + described_class.instance_variable_set(:@custom_cname_cache, nil) |
| 9 | + described_class.instance_variable_set(:@cdn_base_postfix_cache, nil) |
10 | 10 | # Reset configuration |
11 | 11 | Uploadcare.instance_variable_set(:@configuration, nil) |
12 | 12 | end |
|
33 | 33 | end |
34 | 34 |
|
35 | 35 | it 'handles different CDN bases' do |
36 | | - described_class.instance_variable_set(:@cdn_base_postfix, nil) |
| 36 | + described_class.instance_variable_set(:@cdn_base_postfix_cache, nil) |
37 | 37 | allow(Uploadcare.configuration).to receive(:cdn_base_postfix).and_return('https://example.com') |
38 | 38 | allow(described_class).to receive(:custom_cname).and_return('xyz789') |
39 | 39 |
|
|
50 | 50 | end |
51 | 51 |
|
52 | 52 | it 'handles CDN base with path' do |
53 | | - described_class.instance_variable_set(:@cdn_base_postfix, nil) |
| 53 | + described_class.instance_variable_set(:@cdn_base_postfix_cache, nil) |
54 | 54 | allow(Uploadcare.configuration).to receive(:cdn_base_postfix).and_return('https://cdn.example.com/path/') |
55 | 55 | allow(described_class).to receive(:custom_cname).and_return('prefix123') |
56 | 56 |
|
|
72 | 72 |
|
73 | 73 | invalid_urls.each do |invalid_url| |
74 | 74 | # Reset memoization for each test |
75 | | - described_class.instance_variable_set(:@cdn_base_postfix, nil) |
| 75 | + described_class.instance_variable_set(:@cdn_base_postfix_cache, nil) |
76 | 76 | allow(Uploadcare.configuration).to receive(:cdn_base_postfix).and_return(invalid_url) |
77 | 77 | allow(described_class).to receive(:generate_cname).and_return('test123') |
78 | 78 |
|
|
110 | 110 | result1 = described_class.send(:custom_cname) |
111 | 111 |
|
112 | 112 | # Reset memoization |
113 | | - described_class.instance_variable_set(:@custom_cname, nil) |
| 113 | + described_class.instance_variable_set(:@custom_cname_cache, nil) |
114 | 114 |
|
115 | 115 | allow(Uploadcare.configuration).to receive(:public_key).and_return('key2') |
116 | 116 | result2 = described_class.send(:custom_cname) |
|
213 | 213 | ] |
214 | 214 |
|
215 | 215 | test_cases.each do |cdn_base| |
216 | | - described_class.instance_variable_set(:@cdn_base_postfix, nil) |
| 216 | + described_class.instance_variable_set(:@cdn_base_postfix_cache, nil) |
217 | 217 | allow(Uploadcare.configuration).to receive(:cdn_base_postfix).and_return(cdn_base) |
218 | 218 | allow(described_class).to receive(:custom_cname).and_return('test123') |
219 | 219 |
|
|
0 commit comments