forked from paper-trail-gem/paper_trail
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request paper-trail-gem#681 from airblade/fix_651_mysql_ch…
…arset MySQL: Specify UTF-8 charset for versions table
- Loading branch information
Showing
4 changed files
with
98 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
spec/generators/paper_trail/templates/create_versions_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
require "rails_helper" | ||
require "generators/paper_trail/templates/create_versions" | ||
|
||
RSpec.describe CreateVersions do | ||
describe "#change", verify_stubs: false do | ||
let(:migration) { described_class.new } | ||
|
||
before do | ||
allow(migration).to receive(:add_index) | ||
allow(migration).to receive(:create_table) | ||
end | ||
|
||
it "creates the versions table" do | ||
migration.change | ||
expect(migration).to have_received(:create_table) do |arg1| | ||
expect(arg1).to eq(:versions) | ||
end | ||
end | ||
|
||
case ENV["DB"] | ||
when "mysql" | ||
it "uses InnoDB engine" do | ||
migration.change | ||
expect(migration).to have_received(:create_table) do |_, arg2| | ||
expect(arg2[:options]).to match(/ENGINE=InnoDB/) | ||
end | ||
end | ||
|
||
it "uses utf8mb4 character set" do | ||
migration.change | ||
expect(migration).to have_received(:create_table) do |_, arg2| | ||
expect(arg2[:options]).to match(/DEFAULT CHARSET=utf8mb4/) | ||
end | ||
end | ||
|
||
it "uses utf8mb4_col collation" do | ||
migration.change | ||
expect(migration).to have_received(:create_table) do |_, arg2| | ||
expect(arg2[:options]).to match(/COLLATE=utf8mb4_col/) | ||
end | ||
end | ||
else | ||
it "passes an empty options hash to create_table" do | ||
migration.change | ||
expect(migration).to have_received(:create_table) do |_, arg2| | ||
expect(arg2).to eq({}) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters