File tree Expand file tree Collapse file tree 1 file changed +16
-12
lines changed
spec/jobs/better_together/metrics Expand file tree Collapse file tree 1 file changed +16
-12
lines changed Original file line number Diff line number Diff line change 2727 expect ( page_view . errors [ :page_url ] ) . to be_empty
2828 end
2929
30- it 'handles pageables with UTF-8 URLs' do
31- # Create a mock pageable that returns UTF-8 URL
32- utf8_pageable = instance_double ( Page )
33- allow ( utf8_pageable ) . to receive_messages ( url : 'https://example.com/café' , becomes : utf8_pageable ,
34- class : double ( base_class : double ) ) # rubocop:todo RSpec/VerifiedDoubles
35-
36- expect do
37- described_class . perform_now ( utf8_pageable , 'en' )
38- end . to change ( BetterTogether ::Metrics ::PageView , :count ) . by ( 1 )
39-
40- page_view = BetterTogether ::Metrics ::PageView . last
41- expect ( page_view . errors [ :page_url ] ) . to be_empty
30+ context 'handles pageables with UTF-8 URLs' do
31+ it 'creates page view when page URL contains UTF-8 characters' do
32+ # Create a page view with a UTF-8 URL
33+ page_view = BetterTogether ::Metrics ::PageView . new (
34+ viewed_at : Time . current ,
35+ locale : 'en'
36+ )
37+
38+ # Set UTF-8 page URL directly - this will be processed by set_page_url
39+ page_view . assign_attributes ( page_url : 'https://例え.テスト/ページ' )
40+
41+ expect ( page_view . save ) . to be true
42+ expect ( page_view . errors [ :page_url ] ) . to be_empty
43+ # The set_page_url method extracts the path and URL-encodes UTF-8 characters
44+ expect ( page_view . page_url ) . to eq ( '/%E3%83%9A%E3%83%BC%E3%82%B8' )
45+ end
4246 end
4347 end
4448end
You can’t perform that action at this time.
0 commit comments