File tree Expand file tree Collapse file tree 4 files changed +54
-1
lines changed
Expand file tree Collapse file tree 4 files changed +54
-1
lines changed Original file line number Diff line number Diff line change 66
77default: &default
88 adapter: mysql2
9- encoding: utf8
9+ encoding: utf8mb4
10+ collation: utf8mb4_unicode_ci
1011 username: root
1112 password: root
1213 host: <%= host %>
Original file line number Diff line number Diff line change 1+ class ConvertToUtf8mb4 < ActiveRecord ::Migration [ 7.2 ]
2+ # Tables that need utf8mb4 for emoji support in their text fields
3+ TABLES_TO_CONVERT = %w[
4+ announcements
5+ comments
6+ faqs
7+ projects
8+ updates
9+ ] . freeze
10+
11+ def up
12+ # Convert the database default charset
13+ execute "ALTER DATABASE `#{ connection . current_database } ` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"
14+
15+ TABLES_TO_CONVERT . each do |table |
16+ execute "ALTER TABLE #{ table } CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"
17+ end
18+ end
19+
20+ def down
21+ TABLES_TO_CONVERT . each do |table |
22+ execute "ALTER TABLE #{ table } CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;"
23+ end
24+
25+ execute "ALTER DATABASE `#{ connection . current_database } ` CHARACTER SET utf8 COLLATE utf8_general_ci;"
26+ end
27+ end
Original file line number Diff line number Diff line change 66 comment . destroy!
77 expect ( Comment . count ) . to eq 0
88 end
9+
10+ describe 'emoji support' do
11+ it 'saves and retrieves comments with emoji characters' do
12+ emoji_text = 'This is a great idea! π±ππ'
13+ comment = create ( :comment , text : emoji_text )
14+ comment . reload
15+ expect ( comment . text ) . to eq ( emoji_text )
16+ end
17+ end
918end
Original file line number Diff line number Diff line change 175175 expect ( Notification . where ( recipient : user ) . count ) . to eq ( 1 )
176176 end
177177 end
178+
179+ describe 'emoji support' do
180+ it 'saves and retrieves project descriptions with emoji characters' do
181+ emoji_description = 'Project with emojis π±ππ and more text'
182+ project = create ( :project , description : emoji_description )
183+ project . reload
184+ expect ( project . description ) . to eq ( emoji_description )
185+ end
186+
187+ it 'saves and retrieves project titles with emoji characters' do
188+ emoji_title = 'My Awesome Project π'
189+ project = create ( :project , title : emoji_title )
190+ project . reload
191+ expect ( project . title ) . to eq ( emoji_title )
192+ end
193+ end
178194end
You canβt perform that action at this time.
0 commit comments